Transporter vessels, an explicit store button, and bottom-anchored menus

Forgejo #19, part 6 of #12. Transporters are built at the ship crafter,
fly themselves to the nearest hub and wait there. When a building is
short of what its queue needs, the nearest idle transporter runs
hub -> mothership -> building -> hub. Ore leaves the bank when it is
loaded and lands in the building's stock on arrival, so what is drawn
and what happens are the same event - the extractor hauler's rule.

Production orders are now TYPED (interceptor / transporter) rather than
a bare count, since the crafter builds two different things. One at a
time is dispatched per building: without that, every idle transporter
chases the same shortfall and they all arrive carrying ore nobody needs.

Three fixes from play-testing feedback:

- Storing ore into a building is now a deliberate button press, not a
  side effect of opening the menu.
- The mothership's load-ore controls were positioned from the TOP of the
  screen, so on any viewport shorter than ~1300px the label fell off the
  bottom. They are anchored to the bottom edge now, and the label had no
  explicit font size so it inherited the theme's 78px and wrapped off
  screen. Checked at 720x960 and 720x1280.
- The craft button looked live and did nothing. It was not the transport
  work: BASE_FLEET_SIZE is 5 and a new game starts with exactly 5 ships,
  so the fleet is at its cap from the first frame and every interceptor
  order was refused. The button is now visibly disabled and says why.
  The underlying balance (crafter useless until Wing Doctrine) is left
  alone - that is a design call, not a bug to quietly change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Loïc Wisniewski 2026-08-11 19:14:27 +02:00
commit d41128bc43
22 changed files with 753 additions and 54 deletions

View file

@ -0,0 +1 @@
uid://cuns23tjgn7fg

View file

@ -0,0 +1 @@
uid://djp66g3saubh4

View file

@ -0,0 +1,27 @@
extends Node2D
# Preview, not a test. Opens the CraftMenu so its layout can be checked on a
# real viewport - the mothership's "Load ore" label was falling off the bottom
# of shorter screens, which no headless test can see.
#
# bash tests/screenshot.sh res://tests/_craft_menu_preview.tscn /tmp/m.png 20 720x1280
# ... and again at 720x960 to check a shorter screen format.
func _ready() -> void:
GameState.buildings.clear()
GameState.extractors.clear()
GameState.transporters.clear()
GameState.rocks = 180
GameState.fleet_cargo = 24
GameState.unlocked = ["shipyards", "logistics", "freight"]
var main: Node = load("res://Main.tscn").instantiate()
add_child(main)
main.get_node("BuildingField").place(GameState.BUILDING_TRANSPORT_HUB, Vector2(400.0, 0.0))
var bc: Node = main.get_node("BuildController")
bc.craft_building_id = 1
main.get_node("UI/CraftMenu").visible = true
if "Craft" == "Craft":
bc._refresh_craft_status()
else:
bc._refresh_load_ore()

View file

@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://tests/_craft_menu_preview.gd" id="1"]
[node name="CraftMenuPreview" type="Node2D"]
script = ExtResource("1")

View file

@ -1,29 +1,27 @@
extends Node2D
# Preview scene - NOT run by run_tests.sh (underscore prefix). Opens the
# mothership's research tree with one branch already bought and a node
# selected, so the laid-out tree, its state colours and the detail panel can
# all be checked in one render.
# Preview, not a test. Opens the SkillMenu so its layout can be checked on a
# real viewport - the mothership's "Load ore" label was falling off the bottom
# of shorter screens, which no headless test can see.
#
# bash tests/screenshot.sh res://tests/_skill_menu_preview.tscn out.png 30 720x1280
# bash tests/screenshot.sh res://tests/_skill_menu_preview.tscn /tmp/m.png 20 720x1280
# ... and again at 720x960 to check a shorter screen format.
func _ready() -> void:
GameState.buildings.clear()
GameState.extractors.clear()
GameState.reset_progression()
GameState.rocks = 60
# One branch researched, so the render shows all three node states at
# once: done, reachable, and still locked further out.
GameState.unlock("shipyards")
GameState.unlock("coordination")
GameState.transporters.clear()
GameState.rocks = 180
GameState.fleet_cargo = 24
GameState.unlocked = ["shipyards", "logistics", "freight"]
var main: Node = load("res://Main.tscn").instantiate()
add_child(main)
main.get_node("AsteroidField").set_process(false)
main.get_node("EnemySpawner").set_process(false)
var controller: Node = main.get_node("BuildController")
controller.skill_menu.visible = true
controller.skill_tree.selected_id = "wing"
controller._refresh_skill_menu("wing")
main.get_node("BuildingField").place(GameState.BUILDING_TRANSPORT_HUB, Vector2(400.0, 0.0))
var bc: Node = main.get_node("BuildController")
bc.craft_building_id = 1
main.get_node("UI/SkillMenu").visible = true
if "Skill" == "Craft":
bc._refresh_craft_status()
else:
bc._refresh_load_ore()

View file

@ -0,0 +1,38 @@
extends Node2D
# Preview, not a test. A transporter mid-run between the mothership and a
# building it is supplying, so the #19 vessel can actually be looked at
# alongside the hub that stations it. Headless draws no pixels.
#
# bash tests/screenshot.sh res://tests/_transporter_preview.tscn /tmp/t.png 25 1280x720
func _ready() -> void:
GameState.buildings.clear()
GameState.extractors.clear()
GameState.transporters.clear()
GameState.rocks = 200
GameState.add_building(GameState.BUILDING_MOTHERSHIP, Vector2(-420.0, 0.0))
GameState.add_building(GameState.BUILDING_TRANSPORT_HUB, Vector2(420.0, 0.0))
# One laden, mid-leg, and one running home empty, so both states show.
GameState.transporters.append({
"hub_id": 2, "state": GameState.TRANSPORTER_TO_BUILDING, "target_id": 2,
"carrying": 8, "progress": 0.45,
"from": Vector2(-420.0, 0.0), "to": Vector2(420.0, 0.0),
})
GameState.transporters.append({
"hub_id": 2, "state": GameState.TRANSPORTER_RETURNING, "target_id": 0,
"carrying": 0, "progress": 0.5,
"from": Vector2(-380.0, 150.0), "to": Vector2(420.0, 150.0),
})
var main: Node = load("res://Main.tscn").instantiate()
add_child(main)
main.get_node("AsteroidField").set_process(false)
main.get_node("EnemySpawner").set_process(false)
# Freeze the simulation so the vessels stay where they were placed.
GameState.set_process(false)
main.get_node("Fleet").move_to(Vector2(0.0, 260.0))
var cam: Camera2D = main.get_node("Camera2D")
cam.zoom = Vector2(0.85, 0.85)

View file

@ -0,0 +1 @@
uid://cqc5de83g4tr2

View file

@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://tests/_transporter_preview.gd" id="1"]
[node name="TransporterPreview" type="Node2D"]
script = ExtResource("1")

View file

@ -0,0 +1 @@
uid://b0364sukgpwow

View file

@ -0,0 +1 @@
uid://bpldq0su02w1v

View file

@ -0,0 +1 @@
uid://bjkqin5w5tah2

View file

@ -0,0 +1 @@
uid://ctplk4adbsi3a

View file

@ -0,0 +1,207 @@
extends SceneTree
# Headless gameplay test: run with
# godot --headless -s res://tests/test_transporter_supply.gd
# Forgejo #19 (part 6 of #12): transporters stationed at a hub fetch ore from
# the mothership and deliver it to whichever building is waiting on it, with
# no player input at all.
#
# Verifies:
# 1. a transporter is built at the CRAFTER and takes itself to the nearest
# hub, rather than appearing at the hub out of nowhere
# 2. a queued order the crafter cannot pay for is fulfilled end to end
# automatically - the whole point of the ticket
# 3. ore is conserved across the entire route (bank + hold + every
# building's stock), at every step, not just at the end
# 4. ore leaves the bank when it is LOADED, not when the order is placed -
# the vessel is carrying something real
# 5. transporters are not ordered when there is no hub to station them at
# 6. no unbounded node accumulation: the fleet of transporters is exactly
# what was built, however many runs they make
var game_state: Node
var scene: Node
var fleet: Node
var field: Node
var crafter_id: int = 0
var hub_id: int = 0
var stage: int = 0
var elapsed: float = 0.0
var total_at_start: int = 0
var bank_when_ordered: int = 0
var conservation_broken: bool = false
# Ore legitimately consumed by completed production. Conservation means
# "nothing vanishes in TRANSIT", not "the total never falls" - building a
# vessel spends ore, and that is the one way it is allowed to leave.
var consumed: int = 0
const MOTHERSHIP_AT: Vector2 = Vector2(0.0, 0.0)
const HUB_AT: Vector2 = Vector2(600.0, 200.0)
const CRAFTER_AT: Vector2 = Vector2(900.0, -300.0)
func _total() -> int:
var sum: int = game_state.rocks + game_state.fleet_cargo
for b in game_state.buildings:
sum += int(b.get("stock", 0))
for t in game_state.transporters:
sum += int(t.get("carrying", 0))
return sum
func _initialize() -> void:
game_state = root.get_node("GameState")
game_state.buildings.clear()
game_state.extractors.clear()
game_state.transporters.clear()
game_state.rocks = 200
game_state.fleet_cargo = 0
game_state.ships_owed = 0
game_state.unlocked = ["shipyards", "logistics", "freight", "coordination", "wing", "squadron", "armada"]
scene = load("res://Main.tscn").instantiate()
root.add_child(scene)
fleet = scene.get_node("Fleet")
field = scene.get_node("BuildingField")
game_state.order_completed.connect(_on_order_completed)
func _on_order_completed(_building_id: int, product: String) -> void:
consumed += game_state.product_cost(product)
func _process(delta: float) -> bool:
elapsed += delta
# --- 3. conservation, checked EVERY tick ------------------------------
# Ore in flight is the easy thing to lose: a leg that loads without
# debiting, or delivers without crediting, would show up here and nowhere
# else. Checked continuously rather than at the end, so it cannot be
# masked by a later correction.
if stage >= 2 and _total() + consumed != total_at_start:
conservation_broken = true
match stage:
0:
scene.get_node("AsteroidField").set_process(false)
scene.get_node("EnemySpawner").set_process(false)
for a in get_nodes_in_group("asteroids"):
if is_instance_valid(a):
a.queue_free()
field.place(GameState.BUILDING_MOTHERSHIP, MOTHERSHIP_AT)
field.place(GameState.BUILDING_SHIP_CRAFTER, CRAFTER_AT)
crafter_id = int(game_state.buildings[-1].id)
# --- 5. no hub yet: a transporter cannot be ordered ----------
if game_state.queue_order(crafter_id, GameState.PRODUCT_TRANSPORTER):
print("TEST_TRANSPORTER_SUPPLY: FAIL (ordered a transporter with no hub to station it at)")
quit(1)
return true
print("no hub -> transporter order refused")
field.place(GameState.BUILDING_TRANSPORT_HUB, HUB_AT)
hub_id = int(game_state.buildings[-1].id)
elapsed = 0.0
stage = 1
return false
1:
if elapsed < 0.2:
return false
# --- 1. build a transporter at the crafter ------------------
if not game_state.queue_order(crafter_id, GameState.PRODUCT_TRANSPORTER):
print("TEST_TRANSPORTER_SUPPLY: FAIL (could not order a transporter with a hub built)")
quit(1)
return true
game_state.deposit_to_building(crafter_id, GameState.TRANSPORTER_COST)
elapsed = 0.0
stage = 2
total_at_start = _total()
return false
2:
if elapsed < 0.3:
return false
if game_state.transporters.size() != 1:
print("TEST_TRANSPORTER_SUPPLY: FAIL (built %d transporters from one order)" % game_state.transporters.size())
quit(1)
return true
var t: Dictionary = game_state.transporters[0]
if int(t.hub_id) != hub_id:
print("TEST_TRANSPORTER_SUPPLY: FAIL (transporter did not take the nearest hub)")
quit(1)
return true
# It must fly FROM the crafter TO the hub, not appear at the hub.
# Checked on the leg's endpoints rather than its current position,
# which is already partway there by now - and being partway is
# the correct behaviour.
if (t.from as Vector2).distance_to(CRAFTER_AT) > 1.0:
print("TEST_TRANSPORTER_SUPPLY: FAIL (transporter's first leg starts at %s, not at the crafter that built it)" % t.from)
quit(1)
return true
if (t.to as Vector2).distance_to(HUB_AT) > 1.0:
print("TEST_TRANSPORTER_SUPPLY: FAIL (transporter's first leg does not end at the hub: %s)" % t.to)
quit(1)
return true
print("transporter built at the crafter, heading for hub %d" % hub_id)
elapsed = 0.0
stage = 3
return false
3:
# Give it time to reach the hub and go idle.
if elapsed < 4.0:
return false
if game_state.transporters[0].state != GameState.TRANSPORTER_IDLE:
print("TEST_TRANSPORTER_SUPPLY: FAIL (never settled at its hub: state=%s)" % game_state.transporters[0].state)
quit(1)
return true
print("stationed at the hub, idle")
# --- 2 + 4. an order it cannot pay for ----------------------
game_state.queue_order(crafter_id, GameState.PRODUCT_SHIP)
bank_when_ordered = game_state.rocks
elapsed = 0.0
stage = 4
return false
4:
# One tick: placing the order must not touch the bank.
if elapsed < 0.1:
return false
if game_state.rocks != bank_when_ordered:
print("TEST_TRANSPORTER_SUPPLY: FAIL (bank moved on placing the order, before anything was loaded)")
quit(1)
return true
print("order placed, bank untouched at %d" % game_state.rocks)
elapsed = 0.0
stage = 5
return false
5:
# --- 2. the whole run, with no player input -----------------
if game_state.pending_orders(crafter_id) > 0:
if elapsed > 25.0:
print("TEST_TRANSPORTER_SUPPLY: FAIL (order never fulfilled: transporter state=%s carrying=%d crafter stock=%d)" % [
game_state.transporters[0].state,
int(game_state.transporters[0].carrying),
game_state.building_stock(crafter_id),
])
quit(1)
return true
return false
if conservation_broken:
print("TEST_TRANSPORTER_SUPPLY: FAIL (ore created or destroyed somewhere along the route)")
quit(1)
return true
print("order fulfilled automatically in %.1fs, no player input" % elapsed)
# --- 6. no vessel accumulation ------------------------------
if game_state.transporters.size() != 1:
print("TEST_TRANSPORTER_SUPPLY: FAIL (%d transporters exist after the run, one was built)" % game_state.transporters.size())
quit(1)
return true
print("still exactly 1 transporter after a full round trip")
print("bank=%d crafter stock=%d total=%d + %d consumed = %d (started %d)" % [
game_state.rocks, game_state.building_stock(crafter_id), _total(),
consumed, _total() + consumed, total_at_start
])
print("TEST_TRANSPORTER_SUPPLY: PASS")
quit(0)
return true
return false

View file

@ -0,0 +1 @@
uid://dxu5orxbivfpa