display battle tie-break token

This commit is contained in:
Maxime Réaux 2026-02-18 11:15:53 +01:00
parent 818d2886f4
commit 23110383c2
9 changed files with 127 additions and 29 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 806 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 832 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 754 B

View file

@ -1,8 +1,9 @@
from typing import List, Dict
from PyQt6.QtWidgets import QWidget, QDialog
from PyQt6.QtCore import Qt
from warchron.constants import Icons, IconName
from warchron.constants import Icons, IconName, ContextType, RESOURCES_DIR
from warchron.controller.dtos import ParticipantOption
from warchron.view.ui.ui_tie_dialog import Ui_tieDialog
@ -14,6 +15,7 @@ class TieDialog(QDialog):
*,
players: List[ParticipantOption],
counters: List[int],
context_type: ContextType,
context_id: str,
) -> None:
super().__init__(parent)
@ -22,7 +24,13 @@ class TieDialog(QDialog):
self._p2_id = players[1].id
self.ui: Ui_tieDialog = Ui_tieDialog()
self.ui.setupUi(self) # type: ignore
self.ui.tieContext.setText("Battle tie") # Change with context
self.ui.tieContext.setText(self._get_context_title(context_type))
icon_path = (RESOURCES_DIR / Icons._paths[IconName.TOKENS]).as_posix()
html = f'<img src="{icon_path}" width="16" height="16"> Remaining token(s)'
self.ui.label_2.setText(html)
self.ui.label_2.setTextFormat(Qt.TextFormat.RichText)
self.ui.label_3.setText(html)
self.ui.label_3.setTextFormat(Qt.TextFormat.RichText)
self.ui.groupBox_1.setTitle(players[0].name)
self.ui.groupBox_2.setTitle(players[1].name)
self.ui.tokenCount_1.setText(str(counters[0]))
@ -38,3 +46,13 @@ class TieDialog(QDialog):
self._p1_id: self.ui.tokenSpend_1.isChecked(),
self._p2_id: self.ui.tokenSpend_2.isChecked(),
}
@staticmethod
def _get_context_title(context_type: ContextType) -> str:
titles = {
ContextType.BATTLE: "Battle tie",
ContextType.CAMPAIGN: "Campaign tie",
ContextType.WAR: "War tie",
ContextType.CHOICE: "Choice tie",
}
return titles.get(context_type, "Tie")

View file

@ -4,7 +4,7 @@ from pathlib import Path
import calendar
from PyQt6 import QtWidgets
from PyQt6.QtCore import Qt, QPoint
from PyQt6.QtCore import Qt, QPoint, QSize
from PyQt6.QtWidgets import QWidget, QFileDialog, QTreeWidgetItem, QMenu
from PyQt6.QtGui import QCloseEvent
@ -540,6 +540,7 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
table = self.battlesTable
table.clearContents()
table.setRowCount(len(sectors))
self.battlesTable.setIconSize(QSize(32, 16))
for row, battle in enumerate(sectors):
sector_item = QtWidgets.QTableWidgetItem(battle.sector_name)
if battle.state_icon: