tests: produce on planets, unload on routes

This commit is contained in:
Ilia Denisov
2026-01-23 00:28:23 +02:00
parent 9825e05c0e
commit 812e0d4afd
15 changed files with 522 additions and 103 deletions
+9 -5
View File
@@ -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 {