choice tie-break and random fallback + exception cleanup + war<->camp pid

This commit is contained in:
Maxime Réaux 2026-03-12 16:28:20 +01:00
parent 241d7f10f5
commit 241e76c937
15 changed files with 241 additions and 157 deletions

View file

@ -6,7 +6,7 @@ from PyQt6.QtGui import QIcon
from warchron.constants import ItemType, RefreshScope, Icons, IconName, ContextType
from warchron.model.exception import (
ForbiddenOperation,
AbortedOperation,
DomainError,
RequiresConfirmation,
)
@ -119,9 +119,7 @@ class RoundController:
)
p1_war = None
if battle.player_1_id is not None:
p1_war = camp.participants[
battle.player_1_id
].war_participant_id
p1_war = camp.campaign_to_war_part_id(battle.player_1_id)
pixmap = Icons.get_pixmap(IconName.TIEBREAK_TOKEN)
if effective_winner == p1_war:
p1_icon = QIcon(pixmap)
@ -192,10 +190,19 @@ class RoundController:
workflow = RoundPairingWorkflow(self.app)
try:
workflow.start(war, rnd)
except AbortedOperation as e:
QMessageBox.warning(
self.app.view,
"Canceled pairing",
str(e),
)
for bat in rnd.battles.values():
bat.cleanup_battle_players()
return
except DomainError as e:
QMessageBox.warning(
self.app.view,
"Closure forbidden",
"Pairing impossible",
str(e),
)
return
@ -238,7 +245,7 @@ class RoundController:
)
if not dialog.exec():
TieResolver.cancel_tie_break(war, ctx)
raise ForbiddenOperation("Tie resolution cancelled")
raise AbortedOperation("Tie resolution cancelled")
bids_map[ctx.key()] = dialog.get_bids()
return bids_map