spaceship/tests/test_building_composition.gd
Loïc Wisniewski 265e121cb0 Build the logistics crews, and let them burn energy
#216: transport hubs and spacial workshops no longer conjure their crews.
Transporters and repair drones are ordered at a ship crafter, assigned per
building through a new Station menu, flown out from the mothership hangar,
and spent by the work they do - 20 runs, 12 repairs, counted where the run
ENDS so nothing retires with cargo in the air or a building half repaired.
A spent vessel is gone, so the structure is short again and the player has
to build another. The menu shows what each one has left, worst first.

Craftability needed its own flag: "the crafter can make it" and "it can take
a berth in the fleet" stopped being the same question.

#217: transporters crawl at 120 rather than 150, and a Burn Drive lets them
carry energy and spend it to travel far faster. Fetching it is a leg of its
own, to the nearest store that has any - so a refuelling transporter cannot
be dispatched mid-errand - and the leg flown to COLLECT fuel is not charged
for it. Unresearched, nothing detours and nothing changes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019AJMdB7iuHuLFZM1aBu3GD
2026-09-05 19:09:35 +02:00

51 lines
1.9 KiB
GDScript

extends SceneTree
const BUILDING_DEFINITIONS = preload("res://buildings/BuildingDefinitions.gd")
func _initialize() -> void:
var scene: PackedScene = load("res://buildings/Building.tscn")
for definition in BUILDING_DEFINITIONS.all():
if definition.placement_mode != "space":
continue
var building: Node2D = scene.instantiate()
building.definition_id = definition.definition_id
building._ready()
if building.definition == null \
or building.definition.definition_id != definition.definition_id \
or building.visual == null:
_fail("%s did not compose its definition and visual (resolved=%s visual=%s)" % [
definition.definition_id,
"null" if building.definition == null else building.definition.definition_id,
building.visual,
])
return
var provider: Node = building.visual.get_node_or_null("ActionProvider")
if "transport_hub" in definition.capabilities:
# #216: a hub has exactly one thing to press - how many
# transporters to keep here. Its routes remain automatic, so a
# manual transfer would still be wrong.
if provider == null:
_fail("transport hub has no way to set its crew")
elif building.available_actions() != PackedStringArray(["staff"]):
_fail("transport hub composed %s, expected only the crew menu" \
% [building.available_actions()])
return
elif "planet_scanner" in definition.capabilities:
if provider == null or not provider.actions.has("scanner") \
or provider.actions.has("transfer"):
_fail("%s did not compose its scanner-only action" \
% definition.definition_id)
return
elif provider == null or not provider.actions.has("transfer"):
_fail("%s has no composed transfer action" % definition.definition_id)
return
building.free()
print("TEST_BUILDING_COMPOSITION: PASS")
quit(0)
func _fail(message: String) -> void:
print("TEST_BUILDING_COMPOSITION: FAIL (%s)" % message)
quit(1)