fix war tie campaign sorted unwanted participant

This commit is contained in:
Maxime Réaux 2026-02-26 15:14:44 +01:00
parent e7d3b962ca
commit e64d9ff43b
2 changed files with 10 additions and 10 deletions

View file

@ -149,7 +149,6 @@ class WarController:
for pid in active
]
counters = [war.get_influence_tokens(pid) for pid in active]
# TODO fix sorted participants included in tie-break after campaign ranking
dialog = TieDialog(
parent=self.app.view,
players=players,

View file

@ -87,19 +87,20 @@ class TieResolver:
@staticmethod
def find_war_ties(war: War) -> List[TieContext]:
from warchron.model.result_checker import ResultChecker
scores = ScoreService.compute_scores(war, ContextType.WAR, war.id)
buckets: DefaultDict[int, List[str]] = defaultdict(list)
for pid, score in scores.items():
buckets[score.victory_points].append(pid)
ranking = ResultChecker.get_effective_ranking(
war, ContextType.WAR, war.id, scores
)
ties: List[TieContext] = []
for score_value, participants in buckets.items():
if len(participants) <= 1:
for _, group, _ in ranking:
if len(group) <= 1:
continue
score_value = scores[group[0]].victory_points
if TieResolver.is_tie_resolved(war, ContextType.WAR, war.id, score_value):
continue
if not TieResolver.can_tie_be_resolved(
war, ContextType.WAR, war.id, participants
):
if not TieResolver.can_tie_be_resolved(war, ContextType.WAR, war.id, group):
war.events.append(
TieResolved(None, ContextType.WAR, war.id, score_value)
)
@ -108,7 +109,7 @@ class TieResolver:
TieContext(
context_type=ContextType.WAR,
context_id=war.id,
participants=participants,
participants=group,
score_value=score_value,
)
)