Auto-generate nicknames for invitees joining via link
Invitees no longer need to enter a nickname - they automatically join with a random name like "Swift Tiger" or "Happy Falcon". Game creators still enter their nickname manually.
This commit is contained in:
@@ -50,6 +50,24 @@ func GenerateID(size int) string {
|
||||
return hex.EncodeToString(b)
|
||||
}
|
||||
|
||||
func GenerateNickname() string {
|
||||
adjectives := []string{
|
||||
"Swift", "Happy", "Clever", "Brave", "Mighty",
|
||||
"Quick", "Calm", "Bold", "Lucky", "Wise",
|
||||
"Eager", "Noble", "Keen", "Bright", "Vivid",
|
||||
}
|
||||
nouns := []string{
|
||||
"Tiger", "Falcon", "Dragon", "Phoenix", "Wolf",
|
||||
"Eagle", "Panda", "Otter", "Fox", "Bear",
|
||||
"Hawk", "Lion", "Raven", "Shark", "Owl",
|
||||
}
|
||||
b := make([]byte, 2)
|
||||
rand.Read(b)
|
||||
adj := adjectives[int(b[0])%len(adjectives)]
|
||||
noun := nouns[int(b[1])%len(nouns)]
|
||||
return adj + " " + noun
|
||||
}
|
||||
|
||||
type GameInstance struct {
|
||||
game *Game
|
||||
gameMu sync.RWMutex
|
||||
|
||||
Reference in New Issue
Block a user