fix icon mapping in campaign ranking

This commit is contained in:
Maxime Réaux 2026-02-23 19:28:13 +01:00
parent 0bfe27e0d3
commit d766befd31
5 changed files with 113 additions and 58 deletions

View file

@ -37,24 +37,23 @@ class ResultChecker:
context_type: ContextType,
context_id: str,
scores: Dict[str, ParticipantScore],
) -> List[Tuple[int, List[str]]]:
) -> List[Tuple[int, List[str], Dict[str, int]]]:
vp_buckets: Dict[int, List[str]] = defaultdict(list)
for pid, score in scores.items():
vp_buckets[score.victory_points].append(pid)
sorted_vps = sorted(vp_buckets.keys(), reverse=True)
ranking: List[Tuple[int, List[str]]] = []
ranking: List[Tuple[int, List[str], Dict[str, int]]] = []
current_rank = 1
for vp in sorted_vps:
participants = vp_buckets[vp]
# no tie
if len(participants) == 1:
ranking.append((current_rank, participants))
current_rank += 1
continue
tie_id = f"{context_id}:score:{vp}"
# tie unresolved → shared rank (theoretically impossible)
if not TieResolver.is_tie_resolved(war, context_type, tie_id):
ranking.append((current_rank, participants))
# no tie
if len(participants) == 1 or not TieResolver.is_tie_resolved(
war, context_type, tie_id
):
ranking.append(
(current_rank, participants, {pid: 0 for pid in participants})
)
current_rank += 1
continue
# apply token ranking
@ -64,7 +63,11 @@ class ResultChecker:
tie_id,
participants,
)
tokens_spent = TieResolver.tokens_spent_map(
war, context_type, tie_id, participants
)
for group in groups:
ranking.append((current_rank, group))
group_tokens = {pid: tokens_spent[pid] for pid in group}
ranking.append((current_rank, group, group_tokens))
current_rank += 1
return ranking