cmd: planet production

This commit is contained in:
Ilia Denisov
2025-10-02 02:05:00 +03:00
parent 8a7e2f57c7
commit 0890bf3009
7 changed files with 160 additions and 19 deletions
+9
View File
@@ -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