knowyt/server/src/game/saveSelection.go

23 lines
415 B
Go
Raw Normal View History

2021-08-30 08:55:07 +00:00
package game
import (
"fmt"
"sirlab.de/go/knyt/user"
)
func (gm *Game) SaveSelection(usr *user.User, selection string) error {
gm.mu.Lock()
defer gm.mu.Unlock()
id := usr.GetId()
if gm.players[id].id != id {
return fmt.Errorf("invalid user")
}
gm.round.selection[id] = selection
fmt.Printf("selections: %d\n", len(gm.round.selection))
fmt.Printf("SaveSelection: \"%s\"\n", selection)
return nil
}