refactor: destroy ship_group item

This commit is contained in:
Ilia Denisov
2026-02-04 20:27:25 +02:00
parent 46b4ab96f0
commit e90218368c
2 changed files with 20 additions and 3 deletions
+7 -3
View File
@@ -102,10 +102,14 @@ func (c *Cache) ShipGroupOwnerRace(groupIndex int) *game.Race {
return &c.g.Race[c.ShipGroupOwnerRaceIndex(groupIndex)]
}
func (c *Cache) ShipGroupNumber(i int, n uint) {
func (c *Cache) ShipGroupDestroyItem(i int) {
c.validateShipGroupIndex(i)
c.g.ShipGroups[i].Number = n
// FIXME: cargo load must be decreased proportionally
sg := &c.g.ShipGroups[i]
if sg.Number == 0 {
panic("group has no ships")
}
sg.Load = game.F(sg.Load.F() / float64(sg.Number) * float64(sg.Number-1))
sg.Number -= 1
}
func (c *Cache) DeleteShipGroup(i int) {