fix re-enable token on closed camapign + refacto war_event attributes
This commit is contained in:
parent
5c124f9229
commit
6efd22527a
8 changed files with 108 additions and 57 deletions
|
|
@ -1,4 +1,4 @@
|
|||
from typing import List, Dict, TYPE_CHECKING
|
||||
from typing import List, Dict, Tuple, TYPE_CHECKING
|
||||
|
||||
from PyQt6.QtWidgets import QMessageBox, QDialog
|
||||
from PyQt6.QtGui import QIcon
|
||||
|
|
@ -54,9 +54,8 @@ class CampaignController:
|
|||
icon_map = {}
|
||||
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
|
||||
war, ContextType.CAMPAIGN, campaign.id, scores[group[0]].victory_points
|
||||
)
|
||||
for pid in group:
|
||||
spent = token_map.get(pid, 0)
|
||||
|
|
@ -189,7 +188,7 @@ class CampaignController:
|
|||
|
||||
def resolve_ties(
|
||||
self, war: War, contexts: List[TieContext]
|
||||
) -> Dict[str, Dict[str, bool]]:
|
||||
) -> Dict[Tuple[ContextType, str, int | None], Dict[str, bool]]:
|
||||
bids_map = {}
|
||||
for ctx in contexts:
|
||||
active = TieResolver.get_active_participants(
|
||||
|
|
@ -208,11 +207,17 @@ class CampaignController:
|
|||
context_id=ctx.context_id,
|
||||
)
|
||||
if not dialog.exec():
|
||||
TieResolver.cancel_tie_break(war, ContextType.CAMPAIGN, ctx.context_id)
|
||||
TieResolver.cancel_tie_break(
|
||||
war, ContextType.CAMPAIGN, ctx.context_id, ctx.score_value
|
||||
)
|
||||
raise ForbiddenOperation("Tie resolution cancelled")
|
||||
bids_map[ctx.context_id] = dialog.get_bids()
|
||||
bids_map[(ctx.context_type, ctx.context_id, ctx.score_value)] = (
|
||||
dialog.get_bids()
|
||||
)
|
||||
return bids_map
|
||||
|
||||
# Campaign participant methods
|
||||
|
||||
def create_campaign_participant(self) -> CampaignParticipant | None:
|
||||
if not self.app.navigation.selected_campaign_id:
|
||||
return None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue