fix ignored campaign NP tie-break when closing war
This commit is contained in:
parent
b1bde76319
commit
72f80563f1
16 changed files with 314 additions and 219 deletions
|
|
@ -1,13 +1,9 @@
|
|||
from typing import List, Dict, Tuple, TYPE_CHECKING
|
||||
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,
|
||||
)
|
||||
from warchron.constants import RefreshScope, ContextType, ItemType
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from warchron.controller.app_controller import AppController
|
||||
|
|
@ -67,8 +63,8 @@ class CampaignController:
|
|||
for obj in war.get_all_objectives():
|
||||
objective_icon_maps[obj.id] = RankingIcon.compute_icons(
|
||||
war,
|
||||
ContextType.OBJECTIVE,
|
||||
f"{camp.id}:{obj.id}",
|
||||
ContextType.CAMPAIGN,
|
||||
camp.id,
|
||||
scores,
|
||||
objective_id=obj.id,
|
||||
)
|
||||
|
|
@ -170,12 +166,10 @@ class CampaignController:
|
|||
|
||||
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.participants
|
||||
)
|
||||
active = TieResolver.get_active_participants(war, ctx, ctx.participants)
|
||||
players = [
|
||||
ParticipantOption(id=pid, name=self.app.model.get_participant_name(pid))
|
||||
for pid in active
|
||||
|
|
@ -189,9 +183,8 @@ class CampaignController:
|
|||
context_id=ctx.context_id,
|
||||
context_name=None,
|
||||
)
|
||||
if ctx.context_type == ContextType.OBJECTIVE:
|
||||
campaign_id, 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,
|
||||
|
|
@ -202,13 +195,9 @@ class CampaignController:
|
|||
)
|
||||
if not dialog.exec():
|
||||
# FIXME lost tokens used for narrative tie-break (ContextType.OBJECTIVE)
|
||||
TieResolver.cancel_tie_break(
|
||||
war, ContextType.CAMPAIGN, 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
|
||||
|
||||
# Campaign participant methods
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue