Remove the one-way ore API superseded by the transfer menu
The loose end from #24. withdraw_to_fleet, unload_into_building and deliver_cargo were the old one-way moves behind "Load ore" and "Store ore here"; every one of them is a special case of transfer_to_building / transfer_to_fleet, and none had a caller left outside tests. The cargo_delivered signal had no listeners at all. Not just tidying: unload_into_building routed through deposit_to_building, which does NOT special-case the mothership - it writes b.stock, while building_holdings() returns `rocks` for a mothership and ignores stock entirely. So unload_into_building( mothership_id) would have parked ore in a field nothing reads, with no error. Nothing called it that way, but it is a plausibly-named function sitting there to be reached for later. transfer_to_building handles it. CARGO_LOAD_BATCH stays - the transfer menu's batch buttons use it; only its role as withdraw_to_fleet's default argument is gone. The #24 note expected folding these in to be costly for test_cargo_readout, which places no buildings. It is not: the transfer primitives work off GameState records rather than spawned nodes, so a single add_building() in setup is enough and it stays a display test. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
fe1c721d64
commit
b6427b080d
27 changed files with 1085 additions and 275 deletions
|
|
@ -12,7 +12,10 @@ extends SceneTree
|
|||
#
|
||||
# Verifies:
|
||||
# 1. mining fills the hold and leaves the bank alone
|
||||
# 2. reaching the mothership banks the lot, and empties the hold
|
||||
# 2. unloading at the mothership banks the lot and empties the hold - but
|
||||
# only when the player asks. Arriving used to do it by itself; #24
|
||||
# removed that, so this now checks BOTH halves: parking changes
|
||||
# nothing, and the explicit transfer moves everything
|
||||
# 3. with no mothership there is nowhere to deliver, so cargo just
|
||||
# accumulates - it is never quietly banked anyway
|
||||
# 4. sitting on a DIFFERENT building is not a delivery
|
||||
|
|
@ -27,6 +30,7 @@ var field: Node
|
|||
var stage: int = 0
|
||||
var elapsed: float = 0.0
|
||||
var banked_before: int = 0
|
||||
var mothership_id: int = 0
|
||||
|
||||
const MOTHERSHIP_AT: Vector2 = Vector2(1200.0, 0.0)
|
||||
const CRAFTER_AT: Vector2 = Vector2(-4000.0, 0.0)
|
||||
|
|
@ -117,6 +121,7 @@ func _process(delta: float) -> bool:
|
|||
# --- 4. a different building is not a delivery point --------
|
||||
field.place(GameState.BUILDING_SHIP_CRAFTER, CRAFTER_AT)
|
||||
field.place(GameState.BUILDING_MOTHERSHIP, MOTHERSHIP_AT)
|
||||
mothership_id = int(game_state.buildings[-1].id)
|
||||
_park_fleet_on(CRAFTER_AT)
|
||||
elapsed = 0.0
|
||||
stage = 2
|
||||
|
|
@ -139,6 +144,14 @@ func _process(delta: float) -> bool:
|
|||
if elapsed < 0.4:
|
||||
return false
|
||||
var total_before: int = banked_before + 3
|
||||
# Parking alone must do nothing now (#24).
|
||||
if game_state.fleet_cargo != 3 or game_state.rocks != banked_before:
|
||||
print("TEST_FLEET_CARGO: FAIL (arriving at the mothership banked the hold by itself)")
|
||||
quit(1)
|
||||
return true
|
||||
print("parked on the mothership -> hold still %d (no auto-banking)" % game_state.fleet_cargo)
|
||||
|
||||
game_state.transfer_to_building(mothership_id, 999)
|
||||
print("delivered: hold=%d bank=%d (expected hold=0 bank=%d)" % [
|
||||
game_state.fleet_cargo, game_state.rocks, total_before
|
||||
])
|
||||
|
|
@ -156,10 +169,6 @@ func _process(delta: float) -> bool:
|
|||
# Not simulated by loading PlanetSurface.tscn here: the point is
|
||||
# that cargo lives in the autoload rather than in Main.tscn, so
|
||||
# tearing Main.tscn down must not touch it.
|
||||
# Fly off the mothership first, or this new cargo is (correctly)
|
||||
# banked the moment BuildingField next runs, and the teardown
|
||||
# check below would be measuring a delivery instead.
|
||||
_park_fleet_on(CRAFTER_AT)
|
||||
game_state.collect_cargo(5)
|
||||
scene.queue_free()
|
||||
elapsed = 0.0
|
||||
|
|
|
|||
Loading…
Reference in a new issue