package game import ( "fmt" "sirlab.de/go/knyt/user" ) func (gm *Game) SaveSelection(usr *user.User, selection string) { gm.updateSelection(usr, selection) gm.notifyClients() } func (gm *Game) updateSelection(usr *user.User, selection string) { gm.mu.Lock() defer gm.mu.Unlock() if selection == PLAYER_SELECTION_NONE { gm.round.selections[usr.GetId()] = PLAYER_SELECTION_NONE return } for _, source := range gm.round.sources { if source.id == selection { gm.round.selections[usr.GetId()] = selection return } } fmt.Printf("invalid selection id \"%s\"\n", selection) }