Add planet conquest state and gate extractor placement (#41)

Planets now need every capture point held before an extractor can go
up there: GameState tracks per-planet capture progress keyed by the
same stable planet_id as extractors, and BuildController's four
extractor placement checks (menu enable, status text, info popup,
confirm) all re-check conquest, not just proximity/duplication.

Part of the #40 conquest-mechanic breakdown.
This commit is contained in:
Loïc Wisniewski 2026-08-15 14:41:19 +02:00
commit a1ad6cc844
5 changed files with 238 additions and 4 deletions

View file

@ -543,10 +543,13 @@ func _refresh_build_status() -> void:
# Prices are shown under each option now, so this only needs to say
# whether the fleet is somewhere an extractor could go.
if _planet_under_fleet() != null:
build_status.text = "Over %s - an extractor can be built here" % _planet_under_fleet().planet_name
else:
var planet: Node2D = _planet_under_fleet()
if planet == null:
build_status.text = ""
elif not GameState.is_planet_conquered(planet.planet_id):
build_status.text = "Over %s - capture it before building an extractor" % planet.planet_name
else:
build_status.text = "Over %s - an extractor can be built here" % planet.planet_name
func _refresh_build_option_states() -> void:
@ -554,7 +557,8 @@ func _refresh_build_option_states() -> void:
var definition: Resource = entry[4]
var enabled: bool = GameState.is_building_unlocked(definition.definition_id)
if definition.placement_mode == "planet":
enabled = enabled and _planet_under_fleet() != null
var planet: Node2D = _planet_under_fleet()
enabled = enabled and planet != null and GameState.is_planet_conquered(planet.planet_id)
entry[1].enabled = enabled
entry[1].queue_redraw()
@ -593,6 +597,9 @@ func _show_building_info(type: String) -> void:
if planet == null:
lines.append("No planet in reach - fly over one.")
can_build = false
elif not GameState.is_planet_conquered(planet.planet_id):
lines.append("%s is not captured yet - take all its capture points." % planet.planet_name)
can_build = false
elif GameState.has_extractor_at(planet.planet_id):
lines.append("%s already has an extractor." % planet.planet_name)
can_build = false
@ -639,6 +646,9 @@ func _confirm_build() -> void:
if planet == null or GameState.has_extractor_at(planet.planet_id):
build_status.text = "No planet in reach any more"
return
if not GameState.is_planet_conquered(planet.planet_id):
build_status.text = "%s is not captured yet" % planet.planet_name
return
if not GameState.spend(definition.cost):
build_status.text = "Not enough rocks (need %d, have %d)" % [definition.cost, GameState.rocks]
return