detect and resolve battle tie with influence_token
This commit is contained in:
parent
115ddf8d50
commit
818d2886f4
23 changed files with 808 additions and 172 deletions
40
src/warchron/view/tie_dialog.py
Normal file
40
src/warchron/view/tie_dialog.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
from typing import List, Dict
|
||||
|
||||
from PyQt6.QtWidgets import QWidget, QDialog
|
||||
|
||||
from warchron.constants import Icons, IconName
|
||||
from warchron.controller.dtos import ParticipantOption
|
||||
from warchron.view.ui.ui_tie_dialog import Ui_tieDialog
|
||||
|
||||
|
||||
class TieDialog(QDialog):
|
||||
def __init__(
|
||||
self,
|
||||
parent: QWidget | None = None,
|
||||
*,
|
||||
players: List[ParticipantOption],
|
||||
counters: List[int],
|
||||
context_id: str,
|
||||
) -> None:
|
||||
super().__init__(parent)
|
||||
self._context_id = context_id
|
||||
self._p1_id = players[0].id
|
||||
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.groupBox_1.setTitle(players[0].name)
|
||||
self.ui.groupBox_2.setTitle(players[1].name)
|
||||
self.ui.tokenCount_1.setText(str(counters[0]))
|
||||
self.ui.tokenCount_2.setText(str(counters[1]))
|
||||
if counters[0] < 1:
|
||||
self.ui.tokenSpend_1.setDisabled(True)
|
||||
if counters[1] < 1:
|
||||
self.ui.tokenSpend_2.setDisabled(True)
|
||||
self.setWindowIcon(Icons.get(IconName.WARCHRON))
|
||||
|
||||
def get_bids(self) -> Dict[str, bool]:
|
||||
return {
|
||||
self._p1_id: self.ui.tokenSpend_1.isChecked(),
|
||||
self._p2_id: self.ui.tokenSpend_2.isChecked(),
|
||||
}
|
||||
|
|
@ -117,7 +117,7 @@ class Ui_battleDialog(object):
|
|||
|
||||
def retranslateUi(self, battleDialog):
|
||||
_translate = QtCore.QCoreApplication.translate
|
||||
battleDialog.setWindowTitle(_translate("battleDialog", "Battle result"))
|
||||
battleDialog.setWindowTitle(_translate("battleDialog", "Battle"))
|
||||
self.label_7.setText(_translate("battleDialog", "Sector"))
|
||||
self.label_5.setText(_translate("battleDialog", "Player 1"))
|
||||
self.label_6.setText(_translate("battleDialog", "Player 2"))
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Battle result</string>
|
||||
<string>Battle</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset>
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ class Ui_choiceDialog(object):
|
|||
|
||||
def retranslateUi(self, choiceDialog):
|
||||
_translate = QtCore.QCoreApplication.translate
|
||||
choiceDialog.setWindowTitle(_translate("choiceDialog", "Choices"))
|
||||
choiceDialog.setWindowTitle(_translate("choiceDialog", "Choice"))
|
||||
self.label.setText(_translate("choiceDialog", "Player"))
|
||||
self.label_2.setText(_translate("choiceDialog", "Priority"))
|
||||
self.label_3.setText(_translate("choiceDialog", "Secondary"))
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Choices</string>
|
||||
<string>Choice</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset>
|
||||
|
|
|
|||
118
src/warchron/view/ui/ui_tie_dialog.py
Normal file
118
src/warchron/view/ui/ui_tie_dialog.py
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
# Form implementation generated from reading ui file '.\src\warchron\view\ui\ui_tie_dialog.ui'
|
||||
#
|
||||
# Created by: PyQt6 UI code generator 6.7.1
|
||||
#
|
||||
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
|
||||
# run again. Do not edit this file unless you know what you are doing.
|
||||
|
||||
|
||||
from PyQt6 import QtCore, QtGui, QtWidgets
|
||||
|
||||
|
||||
class Ui_tieDialog(object):
|
||||
def setupUi(self, tieDialog):
|
||||
tieDialog.setObjectName("tieDialog")
|
||||
tieDialog.setWindowModality(QtCore.Qt.WindowModality.ApplicationModal)
|
||||
tieDialog.resize(477, 174)
|
||||
icon = QtGui.QIcon()
|
||||
icon.addPixmap(QtGui.QPixmap(".\\src\\warchron\\view\\ui\\../resources/warchron_logo.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
|
||||
tieDialog.setWindowIcon(icon)
|
||||
self.verticalLayout_5 = QtWidgets.QVBoxLayout(tieDialog)
|
||||
self.verticalLayout_5.setObjectName("verticalLayout_5")
|
||||
self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
|
||||
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
|
||||
self.tieContext = QtWidgets.QLabel(parent=tieDialog)
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(10)
|
||||
font.setBold(True)
|
||||
font.setWeight(75)
|
||||
self.tieContext.setFont(font)
|
||||
self.tieContext.setObjectName("tieContext")
|
||||
self.horizontalLayout_3.addWidget(self.tieContext)
|
||||
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
self.horizontalLayout_3.addItem(spacerItem)
|
||||
self.verticalLayout_5.addLayout(self.horizontalLayout_3)
|
||||
self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
|
||||
self.horizontalLayout_4.setObjectName("horizontalLayout_4")
|
||||
self.groupBox_1 = QtWidgets.QGroupBox(parent=tieDialog)
|
||||
self.groupBox_1.setObjectName("groupBox_1")
|
||||
self.horizontalLayout = QtWidgets.QHBoxLayout(self.groupBox_1)
|
||||
self.horizontalLayout.setObjectName("horizontalLayout")
|
||||
self.verticalLayout = QtWidgets.QVBoxLayout()
|
||||
self.verticalLayout.setObjectName("verticalLayout")
|
||||
self.label_5 = QtWidgets.QLabel(parent=self.groupBox_1)
|
||||
self.label_5.setObjectName("label_5")
|
||||
self.verticalLayout.addWidget(self.label_5)
|
||||
self.label_2 = QtWidgets.QLabel(parent=self.groupBox_1)
|
||||
self.label_2.setObjectName("label_2")
|
||||
self.verticalLayout.addWidget(self.label_2)
|
||||
self.horizontalLayout.addLayout(self.verticalLayout)
|
||||
self.verticalLayout_2 = QtWidgets.QVBoxLayout()
|
||||
self.verticalLayout_2.setObjectName("verticalLayout_2")
|
||||
self.tokenSpend_1 = QtWidgets.QCheckBox(parent=self.groupBox_1)
|
||||
self.tokenSpend_1.setText("")
|
||||
self.tokenSpend_1.setObjectName("tokenSpend_1")
|
||||
self.verticalLayout_2.addWidget(self.tokenSpend_1)
|
||||
self.tokenCount_1 = QtWidgets.QLineEdit(parent=self.groupBox_1)
|
||||
self.tokenCount_1.setEnabled(False)
|
||||
self.tokenCount_1.setObjectName("tokenCount_1")
|
||||
self.verticalLayout_2.addWidget(self.tokenCount_1)
|
||||
self.horizontalLayout.addLayout(self.verticalLayout_2)
|
||||
self.horizontalLayout_4.addWidget(self.groupBox_1)
|
||||
self.groupBox_2 = QtWidgets.QGroupBox(parent=tieDialog)
|
||||
self.groupBox_2.setObjectName("groupBox_2")
|
||||
self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.groupBox_2)
|
||||
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
|
||||
self.verticalLayout_3 = QtWidgets.QVBoxLayout()
|
||||
self.verticalLayout_3.setObjectName("verticalLayout_3")
|
||||
self.label_6 = QtWidgets.QLabel(parent=self.groupBox_2)
|
||||
self.label_6.setObjectName("label_6")
|
||||
self.verticalLayout_3.addWidget(self.label_6)
|
||||
self.label_3 = QtWidgets.QLabel(parent=self.groupBox_2)
|
||||
self.label_3.setObjectName("label_3")
|
||||
self.verticalLayout_3.addWidget(self.label_3)
|
||||
self.horizontalLayout_2.addLayout(self.verticalLayout_3)
|
||||
self.verticalLayout_4 = QtWidgets.QVBoxLayout()
|
||||
self.verticalLayout_4.setObjectName("verticalLayout_4")
|
||||
self.tokenSpend_2 = QtWidgets.QCheckBox(parent=self.groupBox_2)
|
||||
self.tokenSpend_2.setText("")
|
||||
self.tokenSpend_2.setObjectName("tokenSpend_2")
|
||||
self.verticalLayout_4.addWidget(self.tokenSpend_2)
|
||||
self.tokenCount_2 = QtWidgets.QLineEdit(parent=self.groupBox_2)
|
||||
self.tokenCount_2.setEnabled(False)
|
||||
self.tokenCount_2.setObjectName("tokenCount_2")
|
||||
self.verticalLayout_4.addWidget(self.tokenCount_2)
|
||||
self.horizontalLayout_2.addLayout(self.verticalLayout_4)
|
||||
self.horizontalLayout_4.addWidget(self.groupBox_2)
|
||||
self.verticalLayout_5.addLayout(self.horizontalLayout_4)
|
||||
self.buttonBox = QtWidgets.QDialogButtonBox(parent=tieDialog)
|
||||
self.buttonBox.setOrientation(QtCore.Qt.Orientation.Horizontal)
|
||||
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Ok)
|
||||
self.buttonBox.setObjectName("buttonBox")
|
||||
self.verticalLayout_5.addWidget(self.buttonBox)
|
||||
|
||||
self.retranslateUi(tieDialog)
|
||||
self.buttonBox.accepted.connect(tieDialog.accept) # type: ignore
|
||||
self.buttonBox.rejected.connect(tieDialog.reject) # type: ignore
|
||||
QtCore.QMetaObject.connectSlotsByName(tieDialog)
|
||||
|
||||
def retranslateUi(self, tieDialog):
|
||||
_translate = QtCore.QCoreApplication.translate
|
||||
tieDialog.setWindowTitle(_translate("tieDialog", "Tie"))
|
||||
self.tieContext.setText(_translate("tieDialog", "Battle tie"))
|
||||
self.groupBox_1.setTitle(_translate("tieDialog", "Player 1"))
|
||||
self.label_5.setText(_translate("tieDialog", "Spend token"))
|
||||
self.label_2.setText(_translate("tieDialog", "Remaining token(s)"))
|
||||
self.groupBox_2.setTitle(_translate("tieDialog", "Player 2"))
|
||||
self.label_6.setText(_translate("tieDialog", "Spend token"))
|
||||
self.label_3.setText(_translate("tieDialog", "Remaining token(s)"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
tieDialog = QtWidgets.QDialog()
|
||||
ui = Ui_tieDialog()
|
||||
ui.setupUi(tieDialog)
|
||||
tieDialog.show()
|
||||
sys.exit(app.exec())
|
||||
196
src/warchron/view/ui/ui_tie_dialog.ui
Normal file
196
src/warchron/view/ui/ui_tie_dialog.ui
Normal file
|
|
@ -0,0 +1,196 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>tieDialog</class>
|
||||
<widget class="QDialog" name="tieDialog">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::ApplicationModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>477</width>
|
||||
<height>174</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Tie</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset>
|
||||
<normaloff>../resources/warchron_logo.png</normaloff>../resources/warchron_logo.png</iconset>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="tieContext">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Battle tie</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_1">
|
||||
<property name="title">
|
||||
<string>Player 1</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Spend token</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Remaining token(s)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="tokenSpend_1">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="tokenCount_1">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Player 2</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Spend token</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Remaining token(s)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="tokenSpend_2">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="tokenCount_2">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>tieDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>tieDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
from __future__ import annotations
|
||||
from typing import Callable, List
|
||||
from typing import Callable, List, Dict
|
||||
from pathlib import Path
|
||||
import calendar
|
||||
|
||||
|
|
@ -288,7 +288,7 @@ class View(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||
if item is not None and walk(item):
|
||||
return
|
||||
|
||||
def get_selected_tree_item(self) -> dict[str, str] | None:
|
||||
def get_selected_tree_item(self) -> Dict[str, str] | None:
|
||||
item = self.warsTree.currentItem()
|
||||
if not item:
|
||||
return None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue