refactor: destroy ship_group item
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user