cmd: planet production
This commit is contained in:
@@ -2,6 +2,7 @@ package game
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/google/uuid"
|
||||
@@ -33,6 +34,14 @@ func (g Game) hostRaceID(name string) (uuid.UUID, error) {
|
||||
return uuid.Nil, e.NewHostRaceUnknownError(name)
|
||||
}
|
||||
|
||||
func (g Game) raceIndex(name string) (int, error) {
|
||||
i := slices.IndexFunc(g.Race, func(r Race) bool { return r.Name == name })
|
||||
if i < 0 {
|
||||
return i, e.NewHostRaceUnknownError(name)
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func (g Game) opponentRaceID(name string) (uuid.UUID, error) {
|
||||
if v, ok := g.raceID(name); ok {
|
||||
return v, nil
|
||||
|
||||
Reference in New Issue
Block a user