display battle tie-break token
This commit is contained in:
parent
818d2886f4
commit
23110383c2
9 changed files with 127 additions and 29 deletions
|
|
@ -105,6 +105,8 @@ class BattleDTO:
|
|||
state_icon: QIcon | None
|
||||
player1_icon: QIcon | None
|
||||
player2_icon: QIcon | None
|
||||
player1_tooltip: str | None = None
|
||||
player2_tooltip: str | None = None
|
||||
|
||||
|
||||
@dataclass
|
||||
|
|
|
|||
|
|
@ -2,9 +2,11 @@ from typing import List, Dict, TYPE_CHECKING
|
|||
|
||||
from PyQt6.QtWidgets import QDialog
|
||||
from PyQt6.QtWidgets import QMessageBox
|
||||
from PyQt6.QtGui import QIcon
|
||||
|
||||
from warchron.constants import ItemType, RefreshScope, Icons, IconName
|
||||
from warchron.constants import ItemType, RefreshScope, Icons, IconName, ContextType
|
||||
from warchron.model.exception import ForbiddenOperation, DomainError
|
||||
from warchron.model.tie_manager import TieResolver
|
||||
from warchron.model.round import Round
|
||||
from warchron.model.war import War
|
||||
|
||||
|
|
@ -31,6 +33,7 @@ class RoundController:
|
|||
def _fill_round_details(self, round_id: str) -> None:
|
||||
rnd = self.app.model.get_round(round_id)
|
||||
camp = self.app.model.get_campaign_by_round(round_id)
|
||||
war = self.app.model.get_war_by_round(round_id)
|
||||
self.app.view.show_round_details(index=camp.get_round_index(round_id))
|
||||
participants = self.app.model.get_round_participants(round_id)
|
||||
sectors = camp.get_sectors_in_round(round_id)
|
||||
|
|
@ -97,9 +100,29 @@ class RoundController:
|
|||
winner_name = ""
|
||||
p1_icon = None
|
||||
p2_icon = None
|
||||
p1_tooltip = None
|
||||
p2_tooltip = None
|
||||
if battle.is_draw():
|
||||
p1_icon = Icons.get(IconName.DRAW)
|
||||
p2_icon = Icons.get(IconName.DRAW)
|
||||
if TieResolver.was_tie_broken_by_tokens(
|
||||
war, ContextType.BATTLE, battle.sector_id
|
||||
):
|
||||
effective_winner = TieResolver.get_effective_winner_id(
|
||||
war, ContextType.BATTLE, battle.sector_id, None
|
||||
)
|
||||
p1_war = None
|
||||
if battle.player_1_id is not None:
|
||||
p1_war = camp.participants[
|
||||
battle.player_1_id
|
||||
].war_participant_id
|
||||
pixmap = Icons.get_pixmap(IconName.TIEBREAK_TOKEN)
|
||||
if effective_winner == p1_war:
|
||||
p1_icon = QIcon(pixmap)
|
||||
p1_tooltip = "Won by tie-break"
|
||||
else:
|
||||
p2_icon = QIcon(pixmap)
|
||||
p2_tooltip = "Won by tie-break"
|
||||
elif battle.winner_id:
|
||||
if battle.winner_id == battle.player_1_id:
|
||||
p1_icon = Icons.get(IconName.WIN)
|
||||
|
|
@ -118,6 +141,8 @@ class RoundController:
|
|||
state_icon=state_icon,
|
||||
player1_icon=p1_icon,
|
||||
player2_icon=p2_icon,
|
||||
player1_tooltip=p1_tooltip,
|
||||
player2_tooltip=p2_tooltip,
|
||||
)
|
||||
)
|
||||
self.app.view.display_round_battles(battles_for_display)
|
||||
|
|
@ -168,6 +193,7 @@ class RoundController:
|
|||
parent=self.app.view,
|
||||
players=players,
|
||||
counters=counters,
|
||||
context_type=ContextType.BATTLE,
|
||||
context_id=ctx.context_id,
|
||||
)
|
||||
if not dialog.exec():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue