wip: battle mechanism
This commit is contained in:
@@ -131,6 +131,7 @@ func (g Game) deleteShipTypeInternal(ri int, name string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// TODO: D A W S C
|
||||
func (g Game) CreateShipType(raceName, typeName string, d, w, s, c float64, a int) error {
|
||||
ri, err := g.raceIndex(raceName)
|
||||
if err != nil {
|
||||
@@ -251,3 +252,11 @@ func ShipClass(g *Game, ri int, classID uuid.UUID) (ShipType, bool) {
|
||||
}
|
||||
return g.Race[ri].ShipTypes[sti], true
|
||||
}
|
||||
|
||||
func ShipClassIndex(g *Game, ri int, classID uuid.UUID) (int, 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 })
|
||||
return sti, sti >= 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user