Plan every craftable vessel, and stop restating the point cost

#221: the planning centre listed only fleet-eligible hulls, so the two
vessels that most need replacing were the two it could not plan - #216 made
transporters and repair drones wear out, which is what a standing order is
for. It offers everything a crafter can build now.

That needed the census to see them: it counted the fleet, the hangar,
garrisons and transit, but not vessels standing at a hub or a workshop. An
order for a transporter would never have seen the ones already built, and
the crafters would have gone on making more forever.

#222: the ship lab's detail block restated the selected upgrade's research
point cost, which its own card shows a few pixels higher. Removed, with the
parameter and the call-site lookup that fed it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019AJMdB7iuHuLFZM1aBu3GD
This commit is contained in:
Loïc Wisniewski 2026-09-05 23:13:23 +02:00
commit f77596395b
4 changed files with 45 additions and 8 deletions

View file

@ -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))

View file

@ -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.

View file

@ -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)

View file

@ -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: