tests: produce on planets, unload on routes
This commit is contained in:
@@ -383,15 +383,18 @@ func (c *Cache) UnloadCargo(ri int, groupIndex uint, ships uint, quantity float6
|
||||
return e.NewCargoUnoadNotEnoughError("load: %.03f", c.ShipGroup(sgi).Load)
|
||||
}
|
||||
|
||||
c.unloadCargoUnsafe(sgi, toBeUnloaded)
|
||||
c.unsafeUnloadCargo(sgi, toBeUnloaded)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Cache) unloadCargoUnsafe(sgi int, q float64) {
|
||||
func (c *Cache) unsafeUnloadCargo(sgi int, q float64) {
|
||||
if q <= 0 {
|
||||
return
|
||||
}
|
||||
if st := c.ShipGroup(sgi).State(); st != game.StateInOrbit {
|
||||
panic(fmt.Sprintf("invalid group state: %v", st))
|
||||
}
|
||||
c.validateShipGroupIndex(sgi)
|
||||
p := c.MustPlanet(c.ShipGroup(sgi).Destination)
|
||||
ct := *c.ShipGroup(sgi).CargoType
|
||||
@@ -411,12 +414,13 @@ func (c *Cache) unloadCargoUnsafe(sgi int, q float64) {
|
||||
}
|
||||
*availableOnPlanet += q
|
||||
|
||||
// FIXME: unpack COL / CAP
|
||||
|
||||
c.ShipGroup(sgi).Load -= q
|
||||
c.ShipGroup(sgi).Load -= q // TODO: apply rounding for Load property?
|
||||
if c.ShipGroup(sgi).Load == 0 {
|
||||
c.ShipGroup(sgi).CargoType = nil
|
||||
}
|
||||
|
||||
p.UnpackColonists()
|
||||
p.UnpackCapital()
|
||||
}
|
||||
|
||||
func (c *Controller) GiveawayGroup(raceName, raceAcceptor string, groupIndex, quantity uint) error {
|
||||
|
||||
Reference in New Issue
Block a user