unifomise tiebreak icons + refacto presenter
This commit is contained in:
parent
0081e52e9a
commit
3d0d7874e3
10 changed files with 185 additions and 165 deletions
|
|
@ -18,7 +18,6 @@ from warchron.model.exception import (
|
|||
RequiresConfirmation,
|
||||
)
|
||||
from warchron.model.tie_manager import TieResolver, TieContext
|
||||
from warchron.model.result_checker import ResultChecker
|
||||
from warchron.model.pairing import Pairing
|
||||
from warchron.model.round import Round
|
||||
from warchron.model.war import War
|
||||
|
|
@ -36,7 +35,7 @@ from warchron.controller.closure_workflow import (
|
|||
RoundClosureWorkflow,
|
||||
RoundPairingWorkflow,
|
||||
)
|
||||
from warchron.controller.presenter import TiePresenter
|
||||
from warchron.controller.presenter import Presenter
|
||||
from warchron.view.choice_dialog import ChoiceDialog
|
||||
from warchron.view.battle_dialog import BattleDialog
|
||||
from warchron.view.tie_dialog import TieDialog
|
||||
|
|
@ -47,7 +46,6 @@ class RoundController:
|
|||
self.app = app
|
||||
|
||||
def _fill_round_details(self, round_id: str) -> None:
|
||||
# self.app.view.clear_round_page()
|
||||
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)
|
||||
|
|
@ -135,7 +133,6 @@ 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:
|
||||
|
|
@ -143,7 +140,6 @@ 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:
|
||||
|
|
@ -153,34 +149,9 @@ class RoundController:
|
|||
)
|
||||
else:
|
||||
winner_name = ""
|
||||
p1_icon = None
|
||||
p2_icon = None
|
||||
# TODO use uniform draw/tie icon logic with choice, war, campaign...
|
||||
if battle.is_draw():
|
||||
p1_icon = Icons.get(IconName.DRAW)
|
||||
p2_icon = Icons.get(IconName.DRAW)
|
||||
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
|
||||
)
|
||||
p1_war = None
|
||||
if battle.player_1_id is not None:
|
||||
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)
|
||||
else:
|
||||
p2_icon = QIcon(pixmap)
|
||||
elif battle.winner_id:
|
||||
if battle.winner_id == battle.player_1_id:
|
||||
p1_icon = Icons.get(IconName.WIN)
|
||||
elif battle.winner_id == battle.player_2_id:
|
||||
p2_icon = Icons.get(IconName.WIN)
|
||||
p1_icon, p2_icon = Presenter.compute_battle_icons(
|
||||
war, round_id, battle.sector_id
|
||||
)
|
||||
battles_for_display.append(
|
||||
BattleDTO(
|
||||
id=battle.sector_id,
|
||||
|
|
@ -293,9 +264,7 @@ class RoundController:
|
|||
campaign = war.get_campaign_by_round(ctx.context_id)
|
||||
if campaign:
|
||||
round = war.get_round(ctx.context_id)
|
||||
data = TiePresenter.build_dialog_data(
|
||||
war, ctx, round=round, campaign=campaign
|
||||
)
|
||||
data = Presenter.build_dialog_data(war, ctx, round=round, campaign=campaign)
|
||||
dialog = TieDialog(
|
||||
parent=self.app.view,
|
||||
players=players,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue