From e64d9ff43b9670fbd8e7abd7b20c69e8d853d31a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20R=C3=A9aux?= Date: Thu, 26 Feb 2026 15:14:44 +0100 Subject: [PATCH] fix war tie campaign sorted unwanted participant --- src/warchron/controller/war_controller.py | 1 - src/warchron/model/tie_manager.py | 19 ++++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/warchron/controller/war_controller.py b/src/warchron/controller/war_controller.py index ac2f0b4..84977e9 100644 --- a/src/warchron/controller/war_controller.py +++ b/src/warchron/controller/war_controller.py @@ -149,7 +149,6 @@ class WarController: for pid in active ] counters = [war.get_influence_tokens(pid) for pid in active] - # TODO fix sorted participants included in tie-break after campaign ranking dialog = TieDialog( parent=self.app.view, players=players, diff --git a/src/warchron/model/tie_manager.py b/src/warchron/model/tie_manager.py index d714f4a..e174e8e 100644 --- a/src/warchron/model/tie_manager.py +++ b/src/warchron/model/tie_manager.py @@ -87,19 +87,20 @@ class TieResolver: @staticmethod def find_war_ties(war: War) -> List[TieContext]: + from warchron.model.result_checker import ResultChecker + scores = ScoreService.compute_scores(war, ContextType.WAR, war.id) - buckets: DefaultDict[int, List[str]] = defaultdict(list) - for pid, score in scores.items(): - buckets[score.victory_points].append(pid) + ranking = ResultChecker.get_effective_ranking( + war, ContextType.WAR, war.id, scores + ) ties: List[TieContext] = [] - for score_value, participants in buckets.items(): - if len(participants) <= 1: + for _, group, _ in ranking: + if len(group) <= 1: continue + score_value = scores[group[0]].victory_points if TieResolver.is_tie_resolved(war, ContextType.WAR, war.id, score_value): continue - if not TieResolver.can_tie_be_resolved( - war, ContextType.WAR, war.id, participants - ): + if not TieResolver.can_tie_be_resolved(war, ContextType.WAR, war.id, group): war.events.append( TieResolved(None, ContextType.WAR, war.id, score_value) ) @@ -108,7 +109,7 @@ class TieResolver: TieContext( context_type=ContextType.WAR, context_id=war.id, - participants=participants, + participants=group, score_value=score_value, ) )