knowyt/server/src/game/getPlayer.go
2021-09-06 23:31:09 +02:00

18 lines
278 B
Go

package game
import (
"fmt"
)
func (gm *Game) getPlayerById(id string) (*playerInfo, error) {
gm.mu.Lock()
defer gm.mu.Unlock()
plInfo := gm.players[id]
if plInfo.id == id {
return &plInfo, nil
}
return nil, fmt.Errorf("player id \"%s\" not found in game\n", id)
}