diff --git a/controllers/BuildController.gd b/controllers/BuildController.gd index 308e93f..f2b0dea 100644 --- a/controllers/BuildController.gd +++ b/controllers/BuildController.gd @@ -650,8 +650,7 @@ func _refresh_lab() -> void: lab_can_buy = false return var selected: Dictionary = options[lab_choice] - var points: int = GameState.research_point_cost(String(selected.id)) - lab_menu.show_detail(String(selected.name), String(selected.desc), points) + lab_menu.show_detail(String(selected.name), String(selected.desc)) var queued: Dictionary = GameState.lab_research_order(lab_building_id) lab_can_buy = queued.is_empty() and (selected.unlock \ or not GameState.upgrade_maxed(selected.id)) diff --git a/core/GameState.gd b/core/GameState.gd index 92f69a4..5d86356 100644 --- a/core/GameState.gd +++ b/core/GameState.gd @@ -2186,11 +2186,14 @@ func adjust_vessel_target(vessel_type: String, delta: int) -> int: return set_vessel_target(vessel_type, vessel_target(vessel_type) + delta) +# #221: everything a crafter can be asked for, not just the fleet hulls. +# #216 made transporters and repair drones ordinary craft that wear out and +# have to be replaced, which is precisely the kind of vessel a standing order +# is for - they were the one thing the planning centre could not plan. func planned_vessel_types() -> PackedStringArray: var out: PackedStringArray = PackedStringArray() - for definition in VESSEL_DEFINITIONS.all(): - if bool(definition.fleet_eligible): - out.append(String(definition.definition_id)) + for definition in VESSEL_DEFINITIONS.craftable(): + out.append(String(definition.definition_id)) return out @@ -2201,6 +2204,7 @@ func vessel_census(vessel_type: String) -> int: return vessel_count_in_fleet(vessel_type) \ + vessel_count_in_hangar(vessel_type) \ + vessel_count_in_garrisons(vessel_type) \ + + vessel_count_at_stations(vessel_type) \ + vessel_count_in_transit(vessel_type) @@ -2227,6 +2231,19 @@ func vessel_count_in_garrisons(vessel_type: String) -> int: return n +# #221: transporters standing at hubs and drones at workshops. Without these +# a standing order for one could never be satisfied - the census would never +# see the vessels it had already built, and the crafters would keep making +# more forever. +func vessel_count_at_stations(vessel_type: String) -> int: + var n: int = 0 + if vessel_type == VESSEL_TRANSPORTER: + n += transporters.size() + elif vessel_type == REPAIR_DRONE: + n += repair_drones.size() + return n + + # Both directions of flight: a finished hull on its way to the mothership, # and a vessel being moved to or from an outpost. All of them are vessels # that exist and will land somewhere. diff --git a/tests/test_planning_center.gd b/tests/test_planning_center.gd index 36e81bf..7dd2b99 100644 --- a/tests/test_planning_center.gd +++ b/tests/test_planning_center.gd @@ -69,6 +69,25 @@ func _state_cases() -> bool: # --- A. one vessel, one count, wherever it is ------------------------ if game_state.vessel_census(interceptor) != 0: return _fail("an empty game counts %d vessels" % game_state.vessel_census(interceptor)) + + # --- #221: support craft are plannable too -------------------------- + # #216 made transporters and repair drones ordinary craft that wear out + # and need replacing, which is exactly what a standing order is for - + # and they were the one thing the planning centre could not plan. + var plannable: PackedStringArray = game_state.planned_vessel_types() + for support in [GameState.VESSEL_TRANSPORTER, GameState.REPAIR_DRONE]: + if not plannable.has(support): + return _fail("'%s' cannot be planned, so a standing order cannot replace one" % support) + # And the census has to SEE them where they live, or an order for one + # could never be satisfied and the crafters would build forever. + var hub_id: int = game_state.add_building(GameState.BUILDING_TRANSPORT_HUB, + Vector2(1200.0, 0.0)) + load("res://tests/_staff.gd").staff(game_state, hub_id, 1) + if game_state.vessel_census(GameState.VESSEL_TRANSPORTER) != 1: + return _fail("a transporter standing at a hub is counted %d times, expected once" \ + % game_state.vessel_census(GameState.VESSEL_TRANSPORTER)) + game_state.remove_buildings_of_type(GameState.BUILDING_TRANSPORT_HUB) + print("support craft are plannable, and counted where they stand") game_state.fleet_vessel_types = PackedStringArray([interceptor, interceptor]) game_state.stored_vessels.append(interceptor) game_state.set_garrison_desired(outpost_id, interceptor, 1) diff --git a/ui/menus/LabMenu.gd b/ui/menus/LabMenu.gd index e6834d1..231c1b4 100644 --- a/ui/menus/LabMenu.gd +++ b/ui/menus/LabMenu.gd @@ -83,10 +83,12 @@ func render_options(options: Array, selected: int, vessel_colour: Color) -> void _resize_price_tags() -func show_detail(heading: String, description: String, points: int) -> void: +# #222: the research-point line that used to sit under the description is +# gone. Every upgrade card above already carries its own "RP have/need", so +# the detail was restating for the selected card what the selected card was +# showing a few pixels higher. +func show_detail(heading: String, description: String) -> void: detail.text = "%s\n%s" % [heading, description] - if points > 0: - detail.text += "\nResearch points: %d/%d" % [GameState.research_points, points] func clear_detail() -> void: