knowyt/server/src/game/getPlayer.go
2022-08-28 20:01:30 +02:00

18 lines
276 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", id)
}