Fleet carries mined ore until it delivers it to the mothership
Forgejo #14, part 1 of #12. Rock.gd credited GameState.rocks on pickup, so ore was banked instantly from anywhere on the map and a mining run had nothing at stake. Ore now goes into GameState.fleet_cargo and 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?", using the fleet CENTROID - the same stable single-number test Planet and Building use, rather than per-ship collision that 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 - cargo mined ON a surface would otherwise be dropped the moment the player took off. test_resources_and_buildings asserted the old behaviour (gathering a rock raises `rocks`) and now asserts the new one. That is a spec change, not a weakened test - the gathering assertion itself is intact. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
2eb779e5de
commit
fc32e26d1b
5 changed files with 235 additions and 6 deletions
32
GameState.gd
32
GameState.gd
|
|
@ -22,11 +22,41 @@ var explored_chunks: Dictionary = {}
|
|||
|
||||
# --- Resources -------------------------------------------------------------
|
||||
|
||||
# Rocks mined from asteroid-planet surfaces, spent on buildings and ships.
|
||||
# Ore that has been BANKED at the mothership. This is the only pool anything
|
||||
# can be bought with.
|
||||
# Starts stocked for play-testing so buildings can be tried without mining
|
||||
# first - drop this back to 0 for a real playthrough.
|
||||
var rocks: int = 500
|
||||
|
||||
# Ore the fleet is physically carrying and has not delivered yet (#14). Mining
|
||||
# fills this, not `rocks`: ore is cargo until the fleet brings it home, so a
|
||||
# long mining run is a real trip with something to lose rather than instant
|
||||
# income from anywhere on the map.
|
||||
#
|
||||
# Lives here, like everything else that has to survive Main.tscn being torn
|
||||
# down and rebuilt on every trip to a planet's surface - and cargo mined ON a
|
||||
# surface would otherwise be dropped the moment the player took off.
|
||||
var fleet_cargo: int = 0
|
||||
|
||||
signal cargo_delivered(amount: int)
|
||||
|
||||
|
||||
func collect_cargo(amount: int = 1) -> void:
|
||||
fleet_cargo += amount
|
||||
|
||||
|
||||
func deliver_cargo() -> int:
|
||||
# Everything the fleet is carrying, banked at once. Returns how much moved
|
||||
# so a caller can react to a delivery actually having happened rather than
|
||||
# to merely being in range.
|
||||
if fleet_cargo <= 0:
|
||||
return 0
|
||||
var delivered: int = fleet_cargo
|
||||
rocks += delivered
|
||||
fleet_cargo = 0
|
||||
cargo_delivered.emit(delivered)
|
||||
return delivered
|
||||
|
||||
const MOTHERSHIP_COST: int = 20
|
||||
const SHIP_CRAFTER_COST: int = 12
|
||||
const SHIP_COST: int = 6
|
||||
|
|
|
|||
Loading…
Reference in a new issue