tie-break for narrative points

This commit is contained in:
Maxime Réaux 2026-03-03 11:52:07 +01:00
parent d72c9902d4
commit 53b1fc916c
8 changed files with 194 additions and 17 deletions

View file

@ -171,7 +171,19 @@ class CampaignController:
counters=counters,
context_type=ContextType.CAMPAIGN,
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]
dialog = TieDialog(
parent=self.app.view,
players=players,
counters=counters,
context_type=ctx.context_type,
context_id=ctx.context_id,
context_name=objective.name,
)
if not dialog.exec():
TieResolver.cancel_tie_break(
war, ContextType.CAMPAIGN, ctx.context_id, ctx.score_value

View file

@ -2,7 +2,6 @@ from typing import TYPE_CHECKING
if TYPE_CHECKING:
from warchron.controller.app_controller import AppController
from warchron.model.war import War
from warchron.model.campaign import Campaign
from warchron.model.round import Round
@ -45,6 +44,23 @@ class CampaignClosureWorkflow(ClosureWorkflow):
TieResolver.apply_bids(war, tie.context_type, tie.context_id, bids)
TieResolver.resolve_tie_state(war, tie, bids)
ties = TieResolver.find_campaign_ties(war, campaign.id)
for objective_id in war.objectives:
ties = TieResolver.find_campaign_objective_ties(
war,
campaign.id,
objective_id,
)
while ties:
bids_map = self.app.campaigns.resolve_ties(war, ties)
for tie in ties:
bids = bids_map[(tie.context_type, tie.context_id, tie.score_value)]
TieResolver.apply_bids(war, tie.context_type, tie.context_id, bids)
TieResolver.resolve_tie_state(war, tie, bids)
ties = TieResolver.find_campaign_objective_ties(
war,
campaign.id,
objective_id,
)
ClosureService.finalize_campaign(campaign)
@ -60,4 +76,19 @@ class WarClosureWorkflow(ClosureWorkflow):
TieResolver.apply_bids(war, tie.context_type, tie.context_id, bids)
TieResolver.resolve_tie_state(war, tie, bids)
ties = TieResolver.find_war_ties(war)
for objective_id in war.objectives:
ties = TieResolver.find_war_objective_ties(
war,
objective_id,
)
while ties:
bids_map = self.app.wars.resolve_ties(war, ties)
for tie in ties:
bids = bids_map[(tie.context_type, tie.context_id, tie.score_value)]
TieResolver.apply_bids(war, tie.context_type, tie.context_id, bids)
TieResolver.resolve_tie_state(war, tie, bids)
ties = TieResolver.find_war_objective_ties(
war,
objective_id,
)
ClosureService.finalize_war(war)

View file

@ -107,14 +107,6 @@ class BattleDTO:
player2_tooltip: str | None = None
@dataclass(frozen=True, slots=True)
class ParticipantScoreDTO:
participant_id: str
player_name: str
victory_points: int
narrative_points: Dict[str, int]
@dataclass(frozen=True, slots=True)
class CampaignParticipantScoreDTO:
campaign_participant_id: str

View file

@ -21,11 +21,6 @@ class RankingIcon:
context_id: str,
scores: Dict[str, ParticipantScore],
) -> Dict[str, QIcon]:
# scores = ScoreService.compute_scores(
# war,
# context_type,
# context_id,
# )
ranking = ResultChecker.get_effective_ranking(
war, context_type, context_id, scores
)

View file

@ -155,7 +155,19 @@ class WarController:
counters=counters,
context_type=ContextType.WAR,
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]
dialog = TieDialog(
parent=self.app.view,
players=players,
counters=counters,
context_type=ctx.context_type,
context_id=ctx.context_id,
context_name=objective.name,
)
if not dialog.exec():
TieResolver.cancel_tie_break(
war, ContextType.WAR, ctx.context_id, ctx.score_value