2026-08-11 19:43:55 +02:00
|
|
|
extends SceneTree
|
|
|
|
|
|
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
|
|
|
# A transport hub holds a crew of logistics vessels, and Freight Yards widens
|
|
|
|
|
# how many it can hold.
|
|
|
|
|
#
|
|
|
|
|
# Forgejo #216 changed what the doctrine buys. A hub used to PROVISION every
|
|
|
|
|
# researched slot the moment it was built, free and forever; the slots are
|
|
|
|
|
# empty now, and the player fills them with transporters they have built. So
|
|
|
|
|
# what is checked here is the ROOM, the clamp on it, and that a hub taken down
|
|
|
|
|
# takes its crew with it rather than orphaning them.
|
2026-08-11 19:43:55 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func _initialize() -> void:
|
2026-08-15 00:09:10 +02:00
|
|
|
var state: Node = root.get_node("GameState")
|
|
|
|
|
state.buildings.clear()
|
|
|
|
|
state.extractors.clear()
|
|
|
|
|
state.transporters.clear()
|
|
|
|
|
state.reset_progression()
|
|
|
|
|
state.rocks = 900
|
#138: structures and doctrines cost more than rocks, and more the deeper they are
Both halves of the ticket, in the shape vessels have used since gas bombers
and laser ships: a definition carries an ore figure and, when it wants more
than ore, a dictionary that IS the price. `building_costs()` and
`skill_costs()` answer it the way `product_costs()` already did, so there is
one question with one answer whatever is being bought, and every payment
path now goes through `spend_resources` rather than `spend`.
Seven of ten structures and thirteen of seventeen doctrines now want gas,
energy or dark matter alongside their rocks, and the totals climb with tree
depth - structures 16/31/58/62/96 by depth, doctrines 15/30/73/96/143/258/530.
The constraint that shaped the table is REACHABILITY, and it is the reason
some prices stayed ore-only. Energy exists only where a gas burner stands,
and a gas burner needs Power Systems - so nothing at or before that depth
may be priced in energy, or it is a wall with no way through. Dark matter is
rarer still and appears once, on the deepest node in the game. The extractor
stays rocks-only despite its depth allowing gas, because the quest chain
reaches it before it has sent the player for any.
test_progressive_costs checks those as properties rather than transcribing
the numbers, so rebalancing a price costs nothing while breaking the shape
fails: nothing unreachable at its own depth, prices rising with depth, the
ore field agreeing with the dictionary (repairs quote the field alone, since
a repair drone carries ore and nothing else), and the quest chain never
asking for a structure it has not funded.
Two things cleaned up on the way:
- The per-building cost constants in GameState are gone. Nothing but tests
used them, and they were a second copy of a number the definitions already
hold - exactly what would drift once a price gained a resource.
- research_for_building() returns a display NAME, and the id-keyed half of
the tree wants an id. That mix-up is silent - skill_depth() of a name finds
no node and answers 0, so a deep structure reads as an ungated one, which
is how the first draft of the test let an unreachable price through.
research_node_for_building() is the id, and the name is expressed from it.
PriceTag no longer rebuilds its labels when re-told the same price; it
refreshes the held figures instead. The craft menu re-states prices every
frame and the build menu now does too, so that was a dozen Labels being torn
down and rebuilt sixty times a second.
2026-08-28 15:30:30 +02:00
|
|
|
# #138: doctrines past the first tier want gas as well as rocks.
|
|
|
|
|
state.bank_inventory.set_amount(GameState.RESOURCE_GAS, 900)
|
2026-08-16 21:38:07 +02:00
|
|
|
state.research_points = state.skill_research_point_cost("freight_yards")
|
2026-08-15 00:09:10 +02:00
|
|
|
state.unlocked = ["shipyards", "logistics", "freight"]
|
|
|
|
|
|
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
|
|
|
var staff: Script = load("res://tests/_staff.gd")
|
2026-08-15 00:09:10 +02:00
|
|
|
var hub_a: int = state.add_building(state.BUILDING_TRANSPORT_HUB, Vector2(-500, 0))
|
|
|
|
|
var per_hub: int = state.hub_capacity()
|
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
|
|
|
if not state.transporters.is_empty():
|
|
|
|
|
return _fail("a new hub arrived with %d transporters of its own" % state.transporters.size())
|
|
|
|
|
if state.station_capacity(state.find_building(hub_a)) != per_hub:
|
|
|
|
|
return _fail("a new hub reports room for %d, expected %d" % [
|
|
|
|
|
state.station_capacity(state.find_building(hub_a)), per_hub])
|
|
|
|
|
print("a new hub: room for %d, and nobody in it" % per_hub)
|
|
|
|
|
|
|
|
|
|
# The order is clamped to the room, so a hub cannot be asked for a crew it
|
|
|
|
|
# has nowhere to put.
|
|
|
|
|
if state.set_station_desired(hub_a, per_hub + 3) != per_hub:
|
|
|
|
|
return _fail("a hub accepted an order past its own capacity")
|
|
|
|
|
staff.staff(state, hub_a, per_hub)
|
|
|
|
|
if _at_hub(state, hub_a) != per_hub:
|
|
|
|
|
return _fail("the hub holds %d of its %d" % [_at_hub(state, hub_a), per_hub])
|
2026-08-15 00:09:10 +02:00
|
|
|
|
|
|
|
|
var hub_b: int = state.add_building(state.BUILDING_TRANSPORT_HUB, Vector2(-500, 600))
|
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
|
|
|
if _at_hub(state, hub_b) != 0:
|
|
|
|
|
return _fail("a second hub brought its own transporters")
|
|
|
|
|
staff.staff(state, hub_b, per_hub)
|
|
|
|
|
if state.transporters.size() != per_hub * 2:
|
|
|
|
|
return _fail("two crewed hubs hold %d transporters, expected %d" % [
|
|
|
|
|
state.transporters.size(), per_hub * 2])
|
|
|
|
|
print("two hubs, each crewed to %d" % per_hub)
|
2026-08-15 00:09:10 +02:00
|
|
|
|
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
|
|
|
# --- the doctrine buys ROOM, not vessels ---------------------------
|
2026-08-15 00:09:10 +02:00
|
|
|
var before: int = state.transporters.size()
|
|
|
|
|
if not state.unlock("freight_yards"):
|
|
|
|
|
return _fail("could not research Freight Yards")
|
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
|
|
|
if state.hub_capacity() != per_hub + 1:
|
|
|
|
|
return _fail("Freight Yards moved capacity to %d, expected %d" % [
|
|
|
|
|
state.hub_capacity(), per_hub + 1])
|
|
|
|
|
if state.transporters.size() != before:
|
|
|
|
|
return _fail("Freight Yards conjured %d transporters" % (state.transporters.size() - before))
|
|
|
|
|
print("Freight Yards widened each hub to %d without crewing anything" % state.hub_capacity())
|
|
|
|
|
|
|
|
|
|
# And the new room is usable.
|
|
|
|
|
staff.staff(state, hub_a, state.hub_capacity())
|
|
|
|
|
if _at_hub(state, hub_a) != state.hub_capacity():
|
|
|
|
|
return _fail("the widened hub holds %d of its %d" % [
|
|
|
|
|
_at_hub(state, hub_a), state.hub_capacity()])
|
|
|
|
|
|
2026-08-15 00:09:10 +02:00
|
|
|
if state.remove_buildings_of_type(state.BUILDING_TRANSPORT_HUB) != 2 \
|
|
|
|
|
or not state.transporters.is_empty():
|
|
|
|
|
return _fail("removing hubs left orphaned logistics transporters")
|
|
|
|
|
print("TEST_HUB_CAPACITY: PASS")
|
|
|
|
|
quit(0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _at_hub(state: Node, hub_id: int) -> int:
|
|
|
|
|
var count: int = 0
|
|
|
|
|
for transporter in state.transporters:
|
|
|
|
|
if int(transporter.hub_id) == hub_id:
|
|
|
|
|
count += 1
|
|
|
|
|
return count
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _fail(message: String) -> void:
|
|
|
|
|
print("TEST_HUB_CAPACITY: FAIL (%s)" % message)
|
|
|
|
|
quit(1)
|