cmd: send fleet
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user