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
|
|
@ -3,7 +3,9 @@ extends SceneTree
|
|||
# Headless gameplay test: run with
|
||||
# godot --headless -s res://tests/test_resources_and_buildings.gd
|
||||
# Covers the resource/building loop end to end:
|
||||
# 1. flying a ship over a surface rock banks it in GameState
|
||||
# 1. flying a ship over a surface rock loads it into the fleet's hold
|
||||
# (banking it needs a trip to the mothership - see #14 and
|
||||
# tests/test_fleet_cargo.gd)
|
||||
# 2. buildings are paid for, persist in GameState, and respawn with the
|
||||
# space scene (they must survive the trip to a planet and back)
|
||||
# 3. a ship crafter adds a vessel to the fleet for rocks
|
||||
|
|
@ -21,6 +23,7 @@ var mothership_pos: Vector2 = Vector2(900.0, -400.0)
|
|||
func _initialize() -> void:
|
||||
game_state = root.get_node("GameState")
|
||||
game_state.rocks = 0
|
||||
game_state.fleet_cargo = 0
|
||||
game_state.buildings.clear()
|
||||
game_state.has_return_position = false
|
||||
|
||||
|
|
@ -49,12 +52,14 @@ func _process(delta: float) -> bool:
|
|||
1:
|
||||
if elapsed < 1.5:
|
||||
return false
|
||||
if game_state.rocks != 1:
|
||||
print("rocks=%d after flying a ship onto one" % game_state.rocks)
|
||||
# Into the hold, not the bank: since #14 ore is cargo until the
|
||||
# fleet delivers it to the mothership.
|
||||
if game_state.fleet_cargo != 1:
|
||||
print("fleet_cargo=%d after flying a ship onto one" % game_state.fleet_cargo)
|
||||
print("TEST_RESOURCES_AND_BUILDINGS: FAIL (rock not gathered)")
|
||||
quit(1)
|
||||
return true
|
||||
print("gathered rock -> rocks=%d" % game_state.rocks)
|
||||
print("gathered rock -> hold=%d bank=%d" % [game_state.fleet_cargo, game_state.rocks])
|
||||
|
||||
# Bank enough to build with, then move to the space scene.
|
||||
game_state.rocks = 60
|
||||
|
|
|
|||
Loading…
Reference in a new issue