fix: ship production math
This commit is contained in:
committed by
Ilia Denisov
parent
9088cc77c9
commit
327f2865d4
@@ -383,9 +383,9 @@ func (c *Cache) UnloadCargo(ri int, groupIndex uint, ships uint, quantity float6
|
||||
|
||||
toBeUnloaded := quantity
|
||||
if quantity == 0 {
|
||||
toBeUnloaded = c.ShipGroup(sgi).Load.F()
|
||||
toBeUnloaded = float64(c.ShipGroup(sgi).Load)
|
||||
}
|
||||
if toBeUnloaded > c.ShipGroup(sgi).Load.F() {
|
||||
if toBeUnloaded > float64(c.ShipGroup(sgi).Load) {
|
||||
return e.NewCargoUnoadNotEnoughError("load: %.03f", c.ShipGroup(sgi).Load)
|
||||
}
|
||||
|
||||
@@ -420,7 +420,7 @@ func (c *Cache) unsafeUnloadCargo(sgi int, q float64) {
|
||||
}
|
||||
*availableOnPlanet = (*availableOnPlanet).Add(q)
|
||||
|
||||
c.ShipGroup(sgi).Load = c.ShipGroup(sgi).Load.Add(-q) // TODO: apply rounding for Load property?
|
||||
c.ShipGroup(sgi).Load = c.ShipGroup(sgi).Load.Add(-q)
|
||||
if c.ShipGroup(sgi).Load == 0 {
|
||||
c.ShipGroup(sgi).CargoType = nil
|
||||
}
|
||||
@@ -536,7 +536,7 @@ func (c *Cache) breakGroupSafe(ri int, groupIndex uint, newGroupShips uint) (int
|
||||
func (c *Cache) breakGroupUnsafe(ri, sgi int, newGroupShips uint) int {
|
||||
newGroup := *c.ShipGroup(sgi)
|
||||
if c.ShipGroup(sgi).CargoType != nil {
|
||||
newGroup.Load = game.F(c.ShipGroup(sgi).Load.F() / float64(c.ShipGroup(sgi).Number) * float64(newGroupShips))
|
||||
newGroup.Load = game.F(float64(c.ShipGroup(sgi).Load) / float64(c.ShipGroup(sgi).Number) * float64(newGroupShips))
|
||||
}
|
||||
newGroup.Number = newGroupShips
|
||||
c.ShipGroupShipsNumber(sgi, c.ShipGroup(sgi).Number-newGroup.Number)
|
||||
|
||||
Reference in New Issue
Block a user