close war and manage tie

This commit is contained in:
Maxime Réaux 2026-02-23 21:18:27 +01:00
parent d766befd31
commit 71e987304b
7 changed files with 185 additions and 55 deletions

View file

@ -82,7 +82,32 @@ class TieResolver:
@staticmethod
def find_war_ties(war: War) -> List[TieContext]:
return [] # TODO
if TieResolver.is_tie_resolved(war, ContextType.WAR, war.id):
return []
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)
ties: List[TieContext] = []
for score_value, participants in buckets.items():
if len(participants) <= 1:
continue
tie_id = f"{war.id}:score:{score_value}"
if TieResolver.is_tie_resolved(war, ContextType.WAR, tie_id):
continue
if not TieResolver.can_tie_be_resolved(
war, ContextType.WAR, tie_id, participants
):
war.events.append(TieResolved(None, ContextType.WAR, tie_id))
continue
ties.append(
TieContext(
context_type=ContextType.WAR,
context_id=tie_id,
participants=participants,
)
)
return ties
@staticmethod
def apply_bids(