extends SceneTree # 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. func _initialize() -> void: var state: Node = root.get_node("GameState") state.buildings.clear() state.extractors.clear() state.transporters.clear() state.reset_progression() state.rocks = 900 # #138: doctrines past the first tier want gas as well as rocks. state.bank_inventory.set_amount(GameState.RESOURCE_GAS, 900) state.research_points = state.skill_research_point_cost("freight_yards") state.unlocked = ["shipyards", "logistics", "freight"] var staff: Script = load("res://tests/_staff.gd") var hub_a: int = state.add_building(state.BUILDING_TRANSPORT_HUB, Vector2(-500, 0)) var per_hub: int = state.hub_capacity() 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]) var hub_b: int = state.add_building(state.BUILDING_TRANSPORT_HUB, Vector2(-500, 600)) 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) # --- the doctrine buys ROOM, not vessels --------------------------- var before: int = state.transporters.size() if not state.unlock("freight_yards"): return _fail("could not research Freight Yards") 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()]) 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)