knowyt/server/src/game/getPlayer.go

18 lines
278 B
Go
Raw Normal View History

2021-09-06 21:31:09 +00:00
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)
}