spaceship/tests/test_logistics_travel_speed.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

50 lines
2.2 KiB
GDScript

extends SceneTree
# Logistics travels at a readable pace rather than teleporting: the ceiling
# below is the rule, and each leg has to actually advance at the speed its own
# stat claims.
#
# The expected progress is DERIVED from that stat rather than written out,
# because the numbers are tuned: #217 slowed transporters from 150 to 120 and
# a hardcoded window failed for a change it was not about. What must not drift
# is the ceiling, and the agreement between the stat and the movement.
func _initialize() -> void:
var state: Node = root.get_node("GameState")
state.vessel_deliveries.clear()
state.transporters.clear()
state.buildings.clear()
state.reset_progression()
var delivery_speed: float = state.vessel_stat("interceptor", "delivery_speed")
var transport_speed: float = state.transporter_speed()
if delivery_speed >= 300.0 or transport_speed >= 300.0:
return _fail("logistics still rushes at delivery %.0f / transport %.0f" % [delivery_speed, transport_speed])
state.vessel_deliveries.append({"type": "interceptor", "from": Vector2.ZERO,
"to": Vector2(900, 0), "progress": 0.0})
state._advance_vessel_deliveries(1.0)
var delivery_progress: float = state.vessel_deliveries[0].progress
var delivery_expected: float = delivery_speed / 900.0
if absf(delivery_progress - delivery_expected) > 0.01:
return _fail("900-unit delivery advanced %.3f in one second at %.0f u/s, expected %.3f" \
% [delivery_progress, delivery_speed, delivery_expected])
state.transporters.append({"hub_id": 0, "state": state.TRANSPORTER_RETURNING,
"target_id": 0, "carrying": 0, "progress": 0.0,
"from": Vector2.ZERO, "to": Vector2(600, 0)})
state._advance_transporters(1.0)
var transport_progress: float = state.transporters[0].progress
var transport_expected: float = transport_speed / 600.0
if absf(transport_progress - transport_expected) > 0.01:
return _fail("600-unit transport leg advanced %.3f in one second at %.0f u/s, expected %.3f" \
% [transport_progress, transport_speed, transport_expected])
print("delivery %.0f u/s, transporter %.0f u/s" % [delivery_speed, transport_speed])
print("TEST_LOGISTICS_TRAVEL_SPEED: PASS")
quit(0)
func _fail(message: String) -> void:
print("TEST_LOGISTICS_TRAVEL_SPEED: FAIL (%s)" % message)
quit(1)