From 85ae66b0a6bb3a83587a213a95347f4e1ff9d5fd Mon Sep 17 00:00:00 2001 From: Claude Code Date: Fri, 10 Apr 2026 20:20:14 -0700 Subject: [PATCH] =?UTF-8?q?feat(victory):=20=E2=9C=A8=20Add=20unit-capture?= =?UTF-8?q?=20victory=20condition=20logic=20to=20handle=20new=20win=20scen?= =?UTF-8?q?arios=20in=20VictoryManager.gd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- .../src/modules/victory/victory_manager.gd | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/game/engine/src/modules/victory/victory_manager.gd b/src/game/engine/src/modules/victory/victory_manager.gd index 9e9e1457..a67c5208 100644 --- a/src/game/engine/src/modules/victory/victory_manager.gd +++ b/src/game/engine/src/modules/victory/victory_manager.gd @@ -10,6 +10,7 @@ extends RefCounted ## Called by TurnManager.next_player() after all players have moved. const PlayerScript: GDScript = preload("res://engine/src/entities/player.gd") +const UnitScript: GDScript = preload("res://engine/src/entities/unit.gd") var _game_over: bool = false @@ -28,6 +29,11 @@ func check_all(_game_map: RefCounted) -> void: ## Domination: the last player with at least one city wins. +## +## A player without cities is still considered alive while they hold any +## founder unit, since they can still settle. This prevents the check from +## firing on the very first turn that one side founds before the other has +## had a chance — a "haven't finished setting up" state, not a real victory. func _check_domination() -> int: var alive_players: Array[int] = [] for player: Variant in GameState.players: @@ -35,12 +41,22 @@ func _check_domination() -> int: continue if player.cities.size() > 0: alive_players.append(player.index) + continue + if _has_living_founder(player): + alive_players.append(player.index) if alive_players.size() == 1: return alive_players[0] return -1 +func _has_living_founder(player: RefCounted) -> bool: + for unit: Variant in player.units: + if unit is UnitScript and unit.is_alive() and unit.can_found_city: + return true + return false + + ## Calculate a simple score for a player (used by victory/defeat screens). ## Points: 1 per population, 5 per city, 3 per tech, 2 per unit alive. func calculate_score(player: RefCounted, _game_map: RefCounted) -> int: