fix re-enable token on closed camapign + refacto war_event attributes

This commit is contained in:
Maxime Réaux 2026-02-25 16:54:21 +01:00
parent 5c124f9229
commit 6efd22527a
8 changed files with 108 additions and 57 deletions

View file

@ -1,4 +1,4 @@
from typing import List, TYPE_CHECKING, Dict
from typing import List, Tuple, TYPE_CHECKING, Dict
from PyQt6.QtWidgets import QMessageBox, QDialog
from PyQt6.QtGui import QIcon
@ -53,8 +53,9 @@ class WarController:
icon_map = {}
for rank, group, token_map in ranking:
base_icon = RANK_TO_ICON.get(rank, IconName.VPNTH)
tie_id = f"{war.id}:score:{scores[group[0]].victory_points}"
tie_resolved = TieResolver.is_tie_resolved(war, ContextType.WAR, tie_id)
tie_resolved = TieResolver.is_tie_resolved(
war, ContextType.WAR, war.id, scores[group[0]].victory_points
)
for pid in group:
spent = token_map.get(pid, 0)
if not tie_resolved and spent == 0:
@ -169,11 +170,14 @@ class WarController:
# TODO fix ignored campaign tie-breaks
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(
war, ctx.context_type, ctx.context_id, ctx.participants
war,
ctx.context_type,
ctx.context_id,
ctx.participants,
)
players = [
ParticipantOption(id=pid, name=self.app.model.get_participant_name(pid))
@ -188,9 +192,13 @@ class WarController:
context_id=ctx.context_id,
)
if not dialog.exec():
TieResolver.cancel_tie_break(war, ContextType.WAR, ctx.context_id)
TieResolver.cancel_tie_break(
war, ContextType.WAR, 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
def set_major_value(self, value: int) -> None: