fix choice tiebreak loop and cancel tiebreak lost tokens

This commit is contained in:
Maxime Réaux 2026-03-17 11:16:47 +01:00
parent a3b9f5a943
commit 42ad708e77
13 changed files with 333 additions and 129 deletions

View file

@ -72,6 +72,7 @@ class RoundController:
comment=choice.comment,
)
)
# TODO display allocated sectors and used token
self.app.view.display_round_choices(choices_for_display)
battles_for_display: List[BattleDTO] = []
for sect in sectors:
@ -89,6 +90,7 @@ class RoundController:
player_1_name = self.app.model.get_participant_name(
camp_part.war_participant_id
)
p1_id = battle.player_1_id
else:
player_1_name = ""
if battle.player_2_id:
@ -96,6 +98,7 @@ class RoundController:
player_2_name = self.app.model.get_participant_name(
camp_part.war_participant_id
)
p2_id = battle.player_2_id
else:
player_2_name = ""
if battle.winner_id:
@ -112,7 +115,11 @@ class RoundController:
if battle.is_draw():
p1_icon = Icons.get(IconName.DRAW)
p2_icon = Icons.get(IconName.DRAW)
context = TieContext(ContextType.BATTLE, battle.sector_id)
context = TieContext(
ContextType.BATTLE,
battle.sector_id,
[p1_id, p2_id],
)
if TieResolver.was_tie_broken_by_tokens(war, context):
effective_winner = ResultChecker.get_effective_winner_id(
war, ContextType.BATTLE, battle.sector_id, None
@ -197,7 +204,7 @@ class RoundController:
str(e),
)
for bat in rnd.battles.values():
bat.cleanup_battle_players()
bat.clear_battle_players()
return
except DomainError as e:
QMessageBox.warning(
@ -225,7 +232,7 @@ class RoundController:
def resolve_ties(
self, war: War, contexts: List[TieContext]
) -> Dict[tuple[str, str, int | None], Dict[str, bool]]:
) -> Dict[tuple[str, str, int | None, str | None, str | None], Dict[str, bool]]:
bids_map = {}
for ctx in contexts:
players = [
@ -236,11 +243,12 @@ class RoundController:
for pid in ctx.participants
]
counters = [war.get_influence_tokens(pid) for pid in ctx.participants]
# TODO display sector name for BATTLE or CHOICE
dialog = TieDialog(
parent=self.app.view,
players=players,
counters=counters,
context_type=ContextType.BATTLE,
context_type=ctx.context_type,
context_id=ctx.context_id,
)
if not dialog.exec():