From 58589b8dc18d75414511fc66aea64ce26c10619d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20R=C3=A9aux?= Date: Thu, 26 Feb 2026 10:36:13 +0100 Subject: [PATCH] fix tie-break & draw icons in war & campaign ranking --- .../controller/campaign_controller.py | 26 ++++++++++--------- src/warchron/controller/war_controller.py | 25 ++++++++++-------- src/warchron/model/tie_manager.py | 3 +++ 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/src/warchron/controller/campaign_controller.py b/src/warchron/controller/campaign_controller.py index 125d59b..cc62e0c 100644 --- a/src/warchron/controller/campaign_controller.py +++ b/src/warchron/controller/campaign_controller.py @@ -54,21 +54,24 @@ class CampaignController: icon_map = {} for rank, group, token_map in ranking: base_icon = RANK_TO_ICON.get(rank, IconName.VPNTH) - tie_resolved = TieResolver.is_tie_resolved( - war, ContextType.CAMPAIGN, campaign.id, scores[group[0]].victory_points + vp = scores[group[0]].victory_points + original_group_size = sum( + 1 for s in scores.values() if s.victory_points == vp ) for pid in group: spent = token_map.get(pid, 0) - if not tie_resolved and spent == 0: - icon_name = getattr(IconName, f"{base_icon.name}DRAW") - elif tie_resolved and spent == 0 and len(group) > 1: - icon_name = getattr(IconName, f"{base_icon.name}DRAW") - elif tie_resolved and spent > 0 and len(group) == 1: - icon_name = getattr(IconName, f"{base_icon.name}BREAK") - elif tie_resolved and spent > 0 and len(group) > 1: - icon_name = getattr(IconName, f"{base_icon.name}TIEDRAW") - else: + if original_group_size == 1: icon_name = base_icon + elif len(group) == 1: + if spent > 0: + icon_name = getattr(IconName, f"{base_icon.name}BREAK") + else: + icon_name = base_icon + else: + if spent > 0: + icon_name = getattr(IconName, f"{base_icon.name}TIEDRAW") + else: + icon_name = getattr(IconName, f"{base_icon.name}DRAW") icon_map[pid] = QIcon(Icons.get_pixmap(icon_name)) return icon_map @@ -276,7 +279,6 @@ class CampaignController: self.app.view, "Invalid name", "Sector name cannot be empty." ) return False - # TODO allow same objectives in different fields? return True def create_sector(self) -> Sector | None: diff --git a/src/warchron/controller/war_controller.py b/src/warchron/controller/war_controller.py index c950363..5cd0de0 100644 --- a/src/warchron/controller/war_controller.py +++ b/src/warchron/controller/war_controller.py @@ -53,21 +53,24 @@ class WarController: icon_map = {} for rank, group, token_map in ranking: base_icon = RANK_TO_ICON.get(rank, IconName.VPNTH) - tie_resolved = TieResolver.is_tie_resolved( - war, ContextType.WAR, war.id, scores[group[0]].victory_points + vp = scores[group[0]].victory_points + original_group_size = sum( + 1 for s in scores.values() if s.victory_points == vp ) for pid in group: spent = token_map.get(pid, 0) - if not tie_resolved and spent == 0: - icon_name = getattr(IconName, f"{base_icon.name}DRAW") - elif tie_resolved and spent == 0 and len(group) > 1: - icon_name = getattr(IconName, f"{base_icon.name}DRAW") - elif tie_resolved and spent > 0 and len(group) == 1: - icon_name = getattr(IconName, f"{base_icon.name}BREAK") - elif tie_resolved and spent > 0 and len(group) > 1: - icon_name = getattr(IconName, f"{base_icon.name}TIEDRAW") - else: + if original_group_size == 1: icon_name = base_icon + elif len(group) == 1: + if spent > 0: + icon_name = getattr(IconName, f"{base_icon.name}BREAK") + else: + icon_name = base_icon + else: + if spent > 0: + icon_name = getattr(IconName, f"{base_icon.name}TIEDRAW") + else: + icon_name = getattr(IconName, f"{base_icon.name}DRAW") icon_map[pid] = QIcon(Icons.get_pixmap(icon_name)) return icon_map diff --git a/src/warchron/model/tie_manager.py b/src/warchron/model/tie_manager.py index 4275ae2..65eea80 100644 --- a/src/warchron/model/tie_manager.py +++ b/src/warchron/model/tie_manager.py @@ -27,6 +27,7 @@ class TieResolver: for battle in round.battles.values(): if not battle.is_draw(): continue + # TODO remove test without score if TieResolver.is_tie_resolved(war, ContextType.BATTLE, battle.sector_id): continue @@ -55,6 +56,7 @@ class TieResolver: @staticmethod def find_campaign_ties(war: War, campaign_id: str) -> List[TieContext]: + # TODO remove test without score if TieResolver.is_tie_resolved(war, ContextType.CAMPAIGN, campaign_id): return [] scores = ScoreService.compute_scores(war, ContextType.CAMPAIGN, campaign_id) @@ -88,6 +90,7 @@ class TieResolver: @staticmethod def find_war_ties(war: War) -> List[TieContext]: + # TODO remove test without score if TieResolver.is_tie_resolved(war, ContextType.WAR, war.id): return [] scores = ScoreService.compute_scores(war, ContextType.WAR, war.id)