cmd: send fleet

This commit is contained in:
Ilia Denisov
2026-01-05 19:46:33 +02:00
parent a6093a1c29
commit 5f3a416abd
7 changed files with 271 additions and 38 deletions
+11
View File
@@ -235,3 +235,14 @@ func checkShipTypeValues(d, w, s, c float64, a int) error {
func checkShipTypeValueDWSC(v float64) bool {
return v == 0 || v >= 1
}
func ShipClass(g *Game, ri int, classID uuid.UUID) (ShipType, bool) {
if len(g.Race) < ri+1 {
panic(fmt.Sprintf("ShipClass: game race index %d invalid: len=%d", ri, len(g.Race)))
}
sti := slices.IndexFunc(g.Race[ri].ShipTypes, func(st ShipType) bool { return st.ID == classID })
if sti < 0 {
return ShipType{}, false
}
return g.Race[ri].ShipTypes[sti], true
}