Fleet carries mined resources until it delivers them to the mothership #14

Closed
opened 2026-08-11 13:36:41 +00:00 by metaheavens · 1 comment
Owner

Part 1 of #12, and the foundation the rest of it stands on.

Today Rock.gd:83 does GameState.rocks += 1 the moment a rock is mined, so ore is banked globally and instantly wherever the fleet happens to be. #12 wants ore to be carried by the fleet and only counted once it reaches the mothership.

Scope

  • Add fleet-local cargo to GameState (survives the space <-> planet-surface scene swap, like everything else there).
  • Mining credits cargo, not rocks.
  • Cargo transfers to rocks when the fleet reaches the mothership. GameState.get_mothership_position() already exists; PlanetField already compares fleet CENTROID distance rather than per-ship collision, and this should do the same for the same reason (per-ship jostling makes boundary tests flicker).
  • Extractor haulers keep crediting rocks directly - delivering to the mothership is already their whole job (GameState._process, the HAULER_ARRIVAL payout).

Deliberately not here: the UI for it, and anything that spends resources. Those are separate tickets so this one can land verified on its own.

Acceptance

  • Mining raises cargo and leaves rocks unchanged.
  • Touching the mothership moves cargo into rocks and empties cargo.
  • With no mothership built, cargo accumulates and is never silently banked.
  • Cargo survives landing on a planet and returning to space.
Part 1 of #12, and the foundation the rest of it stands on. Today `Rock.gd:83` does `GameState.rocks += 1` the moment a rock is mined, so ore is banked globally and instantly wherever the fleet happens to be. #12 wants ore to be *carried* by the fleet and only counted once it reaches the mothership. **Scope** - Add fleet-local cargo to `GameState` (survives the space <-> planet-surface scene swap, like everything else there). - Mining credits cargo, not `rocks`. - Cargo transfers to `rocks` when the fleet reaches the mothership. `GameState.get_mothership_position()` already exists; `PlanetField` already compares fleet CENTROID distance rather than per-ship collision, and this should do the same for the same reason (per-ship jostling makes boundary tests flicker). - Extractor haulers keep crediting `rocks` directly - delivering to the mothership is already their whole job (`GameState._process`, the `HAULER_ARRIVAL` payout). **Deliberately not here:** the UI for it, and anything that spends resources. Those are separate tickets so this one can land verified on its own. **Acceptance** - Mining raises cargo and leaves `rocks` unchanged. - Touching the mothership moves cargo into `rocks` and empties cargo. - With no mothership built, cargo accumulates and is never silently banked. - Cargo survives landing on a planet and returning to space.
Author
Owner

Done in fc32e26.

Rock.gd credited GameState.rocks on pickup, so ore was banked instantly from anywhere on the map. Mining now fills GameState.fleet_cargo, and that only becomes spendable when the fleet reaches the mothership.

Delivery lives in BuildingField because that node already knows where the buildings are and already answers "is the fleet standing on one?". It uses the fleet CENTROID - the same stable single-number test Planet and Building already use - rather than per-ship collision, which flickers as ships jostle in formation.

Cargo lives in the GameState autoload so it survives Main.tscn being torn down on every trip to a planet's surface. Ore mined ON a surface would otherwise be dropped the moment the player took off, which is the one place mining actually happens.

Test

tests/test_fleet_cargo.gd covers: mining fills the hold and leaves the bank alone; reaching the mothership banks the lot and empties the hold; with no mothership cargo just accumulates; parking on a different building is not a delivery; ore is conserved across the transfer; and cargo survives the space scene being torn down.

The first version of it called collect_cargo() directly - which would have passed with Rock.gd completely untouched, since the entire change is which pool Rock.gd credits. It now flies a real ship over a real Rock.tscn instance. That is the same mistake I made on #9 (testing around the real path instead of through it), so I went looking for it deliberately this time.

mutation result
Rock.gd banks straight to rocks (pre-#14 behaviour) FAIL (flying over a rock put 0 in the hold)
no delivery at the mothership at all FAIL (hold not emptied on delivery)
any building accepts a delivery FAIL (the ship crafter accepted a delivery)
delivery banks but does not empty the hold FAIL (hold not emptied on delivery)

test_resources_and_buildings asserted the old behaviour and now asserts the new one. That is a spec change rather than a weakened test - the gathering assertion itself is unchanged.

Full suite: 41/41.

Note for #15

On its own this makes mining look broken: the top-left counter still shows only rocks, so gathering ore now visibly does nothing until the fleet happens to fly home. #15 is what closes that, so it should not sit unfinished for long.

Done in fc32e26. `Rock.gd` credited `GameState.rocks` on pickup, so ore was banked instantly from anywhere on the map. Mining now fills `GameState.fleet_cargo`, and that only becomes spendable when the fleet reaches the mothership. Delivery lives in `BuildingField` because that node already knows where the buildings are and already answers "is the fleet standing on one?". It uses the fleet CENTROID - the same stable single-number test `Planet` and `Building` already use - rather than per-ship collision, which flickers as ships jostle in formation. Cargo lives in the `GameState` autoload so it survives `Main.tscn` being torn down on every trip to a planet's surface. Ore mined ON a surface would otherwise be dropped the moment the player took off, which is the one place mining actually happens. ## Test `tests/test_fleet_cargo.gd` covers: mining fills the hold and leaves the bank alone; reaching the mothership banks the lot and empties the hold; with no mothership cargo just accumulates; parking on a *different* building is not a delivery; ore is conserved across the transfer; and cargo survives the space scene being torn down. The first version of it called `collect_cargo()` directly - which would have passed with `Rock.gd` completely untouched, since the entire change is which pool `Rock.gd` credits. It now flies a real ship over a real `Rock.tscn` instance. That is the same mistake I made on #9 (testing around the real path instead of through it), so I went looking for it deliberately this time. | mutation | result | |---|---| | `Rock.gd` banks straight to `rocks` (pre-#14 behaviour) | FAIL (flying over a rock put 0 in the hold) | | no delivery at the mothership at all | FAIL (hold not emptied on delivery) | | any building accepts a delivery | FAIL (the ship crafter accepted a delivery) | | delivery banks but does not empty the hold | FAIL (hold not emptied on delivery) | `test_resources_and_buildings` asserted the old behaviour and now asserts the new one. That is a spec change rather than a weakened test - the gathering assertion itself is unchanged. Full suite: **41/41**. ## Note for #15 On its own this makes mining look broken: the top-left counter still shows only `rocks`, so gathering ore now visibly does nothing until the fleet happens to fly home. #15 is what closes that, so it should not sit unfinished for long.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
metaheavens/spaceship#14
No description provided.