fix tie-break & draw icons in war & campaign ranking
This commit is contained in:
parent
747f5dec65
commit
58589b8dc1
3 changed files with 31 additions and 23 deletions
|
|
@ -54,21 +54,24 @@ class CampaignController:
|
||||||
icon_map = {}
|
icon_map = {}
|
||||||
for rank, group, token_map in ranking:
|
for rank, group, token_map in ranking:
|
||||||
base_icon = RANK_TO_ICON.get(rank, IconName.VPNTH)
|
base_icon = RANK_TO_ICON.get(rank, IconName.VPNTH)
|
||||||
tie_resolved = TieResolver.is_tie_resolved(
|
vp = scores[group[0]].victory_points
|
||||||
war, ContextType.CAMPAIGN, campaign.id, scores[group[0]].victory_points
|
original_group_size = sum(
|
||||||
|
1 for s in scores.values() if s.victory_points == vp
|
||||||
)
|
)
|
||||||
for pid in group:
|
for pid in group:
|
||||||
spent = token_map.get(pid, 0)
|
spent = token_map.get(pid, 0)
|
||||||
if not tie_resolved and spent == 0:
|
if original_group_size == 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}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:
|
|
||||||
icon_name = base_icon
|
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))
|
icon_map[pid] = QIcon(Icons.get_pixmap(icon_name))
|
||||||
return icon_map
|
return icon_map
|
||||||
|
|
||||||
|
|
@ -276,7 +279,6 @@ class CampaignController:
|
||||||
self.app.view, "Invalid name", "Sector name cannot be empty."
|
self.app.view, "Invalid name", "Sector name cannot be empty."
|
||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
# TODO allow same objectives in different fields?
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def create_sector(self) -> Sector | None:
|
def create_sector(self) -> Sector | None:
|
||||||
|
|
|
||||||
|
|
@ -53,21 +53,24 @@ class WarController:
|
||||||
icon_map = {}
|
icon_map = {}
|
||||||
for rank, group, token_map in ranking:
|
for rank, group, token_map in ranking:
|
||||||
base_icon = RANK_TO_ICON.get(rank, IconName.VPNTH)
|
base_icon = RANK_TO_ICON.get(rank, IconName.VPNTH)
|
||||||
tie_resolved = TieResolver.is_tie_resolved(
|
vp = scores[group[0]].victory_points
|
||||||
war, ContextType.WAR, war.id, scores[group[0]].victory_points
|
original_group_size = sum(
|
||||||
|
1 for s in scores.values() if s.victory_points == vp
|
||||||
)
|
)
|
||||||
for pid in group:
|
for pid in group:
|
||||||
spent = token_map.get(pid, 0)
|
spent = token_map.get(pid, 0)
|
||||||
if not tie_resolved and spent == 0:
|
if original_group_size == 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}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:
|
|
||||||
icon_name = base_icon
|
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))
|
icon_map[pid] = QIcon(Icons.get_pixmap(icon_name))
|
||||||
return icon_map
|
return icon_map
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ class TieResolver:
|
||||||
for battle in round.battles.values():
|
for battle in round.battles.values():
|
||||||
if not battle.is_draw():
|
if not battle.is_draw():
|
||||||
continue
|
continue
|
||||||
|
# TODO remove test without score
|
||||||
if TieResolver.is_tie_resolved(war, ContextType.BATTLE, battle.sector_id):
|
if TieResolver.is_tie_resolved(war, ContextType.BATTLE, battle.sector_id):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
@ -55,6 +56,7 @@ class TieResolver:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def find_campaign_ties(war: War, campaign_id: str) -> List[TieContext]:
|
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):
|
if TieResolver.is_tie_resolved(war, ContextType.CAMPAIGN, campaign_id):
|
||||||
return []
|
return []
|
||||||
scores = ScoreService.compute_scores(war, ContextType.CAMPAIGN, campaign_id)
|
scores = ScoreService.compute_scores(war, ContextType.CAMPAIGN, campaign_id)
|
||||||
|
|
@ -88,6 +90,7 @@ class TieResolver:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def find_war_ties(war: War) -> List[TieContext]:
|
def find_war_ties(war: War) -> List[TieContext]:
|
||||||
|
# TODO remove test without score
|
||||||
if TieResolver.is_tie_resolved(war, ContextType.WAR, war.id):
|
if TieResolver.is_tie_resolved(war, ContextType.WAR, war.id):
|
||||||
return []
|
return []
|
||||||
scores = ScoreService.compute_scores(war, ContextType.WAR, war.id)
|
scores = ScoreService.compute_scores(war, ContextType.WAR, war.id)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue