fix icon mapping in campaign ranking
This commit is contained in:
parent
0bfe27e0d3
commit
d766befd31
5 changed files with 113 additions and 58 deletions
|
|
@ -3,7 +3,14 @@ from typing import List, Dict, TYPE_CHECKING
|
|||
from PyQt6.QtWidgets import QMessageBox, QDialog
|
||||
from PyQt6.QtGui import QIcon
|
||||
|
||||
from warchron.constants import RefreshScope, ContextType, ItemType, Icons, IconName
|
||||
from warchron.constants import (
|
||||
RefreshScope,
|
||||
ContextType,
|
||||
ItemType,
|
||||
Icons,
|
||||
IconName,
|
||||
RANK_TO_ICON,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from warchron.controller.app_controller import AppController
|
||||
|
|
@ -45,40 +52,25 @@ class CampaignController:
|
|||
war, ContextType.CAMPAIGN, campaign.id, scores
|
||||
)
|
||||
icon_map = {}
|
||||
for rank, group in ranking:
|
||||
vp = scores[group[0]].victory_points
|
||||
tie_id = f"{campaign.id}:score:{vp}"
|
||||
is_tie = len(group) > 1
|
||||
broken = TieResolver.was_tie_broken_by_tokens(
|
||||
war,
|
||||
ContextType.CAMPAIGN,
|
||||
tie_id,
|
||||
for rank, group, token_map in ranking:
|
||||
base_icon = RANK_TO_ICON.get(rank, IconName.VPNTH)
|
||||
tie_id = f"{campaign.id}:score:{scores[group[0]].victory_points}"
|
||||
tie_resolved = TieResolver.is_tie_resolved(
|
||||
war, ContextType.CAMPAIGN, tie_id
|
||||
)
|
||||
# choose icon name
|
||||
if rank == 1:
|
||||
base = IconName.VP1ST
|
||||
draw = IconName.VP1STDRAW
|
||||
tb = IconName.VP1STTIEBREAK
|
||||
elif rank == 2:
|
||||
base = IconName.VP2ND
|
||||
draw = IconName.VP2NDDRAW
|
||||
tb = IconName.VP2NDTIEBREAK
|
||||
elif rank == 3:
|
||||
base = IconName.VP3RD
|
||||
draw = IconName.VP3RDDRAW
|
||||
tb = IconName.VP3RDTIEBREAK
|
||||
else:
|
||||
base = IconName.VPNTH
|
||||
draw = IconName.VPNTHDRAW
|
||||
tb = IconName.VPNTHTIEBREAK
|
||||
if not is_tie:
|
||||
icon = Icons.get(base)
|
||||
elif not broken:
|
||||
icon = QIcon(Icons.get_pixmap(draw))
|
||||
else:
|
||||
icon = QIcon(Icons.get_pixmap(tb))
|
||||
for pid in group:
|
||||
icon_map[pid] = icon
|
||||
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:
|
||||
icon_name = base_icon
|
||||
icon_map[pid] = QIcon(Icons.get_pixmap(icon_name))
|
||||
return icon_map
|
||||
|
||||
def _fill_campaign_details(self, campaign_id: str) -> None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue