18 lines
278 B
Go
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)
|
|
}
|