23 lines
415 B
Go
23 lines
415 B
Go
|
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
|
||
|
}
|