fix ignored campaign NP tie-break when closing war

This commit is contained in:
Maxime Réaux 2026-03-06 15:02:53 +01:00
parent b1bde76319
commit 72f80563f1
16 changed files with 314 additions and 219 deletions

View file

@ -1,4 +1,4 @@
from typing import List, Tuple, TYPE_CHECKING, Dict
from typing import List, TYPE_CHECKING, Dict
from PyQt6.QtWidgets import QMessageBox, QDialog
from PyQt6.QtGui import QIcon
@ -63,8 +63,8 @@ class WarController:
for obj in war.get_all_objectives():
objective_icon_maps[obj.id] = RankingIcon.compute_icons(
war,
ContextType.OBJECTIVE,
f"{war.id}:{obj.id}",
ContextType.WAR,
war.id,
scores,
objective_id=obj.id,
)
@ -151,16 +151,14 @@ class WarController:
RefreshScope.WARS_TREE, item_type=ItemType.WAR, item_id=war_id
)
# FIXME tie dialog with all participant even without tie
def resolve_ties(
self, war: War, contexts: List[TieContext]
) -> Dict[Tuple[ContextType, str, int | None], Dict[str, bool]]:
) -> Dict[tuple[str, 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,
ctx.participants,
)
players = [
@ -176,26 +174,21 @@ class WarController:
context_id=ctx.context_id,
context_name=None,
)
if ctx.context_type == ContextType.OBJECTIVE:
_, objective_id = ctx.context_id.split(":")
objective = war.objectives[objective_id]
if ctx.objective_id:
objective = war.objectives[ctx.objective_id]
dialog = TieDialog(
parent=self.app.view,
players=players,
counters=counters,
context_type=ctx.context_type,
context_id=ctx.context_id,
context_name=objective.name,
context_name=f"Objective tie: {objective.name}",
)
if not dialog.exec():
# FIXME lost tokens used for narrative tie-break (ContextType.OBJECTIVE)
TieResolver.cancel_tie_break(
war, ContextType.WAR, ctx.context_id, ctx.score_value
)
TieResolver.cancel_tie_break(war, ctx)
raise ForbiddenOperation("Tie resolution cancelled")
bids_map[(ctx.context_type, ctx.context_id, ctx.score_value)] = (
dialog.get_bids()
)
bids_map[ctx.key()] = dialog.get_bids()
return bids_map
def set_major_value(self, value: int) -> None: