refactor of previous commits

refactor to enum

typing and many other fixes

fix tests

attempt to fix some typescript

more typescript fixes

more typescript test fixes

revert all API changes

update to pydcs

mypy fixes

Use properties to check if player is blue/red/neutral

update requirements.txt

black -_-

bump pydcs and fix mypy

add opponent property

bump pydcs
This commit is contained in:
Eclipse/Druss99
2025-01-17 17:02:07 -05:00
committed by Raffson
parent 362ce66f80
commit 31c80dfd02
78 changed files with 739 additions and 350 deletions

View File

@@ -790,7 +790,7 @@ class AirWingConfigurationDialog(QDialog):
self.tabs = []
for coalition in game.coalitions:
coalition_tab = AirWingConfigurationTab(coalition, game, aircraft_present)
name = "Blue" if coalition.player else "Red"
name = "Blue" if coalition.player.is_blue else "Red"
self.tab_widget.addTab(coalition_tab, name)
self.tabs.append(coalition_tab)

View File

@@ -14,13 +14,14 @@ from PySide6.QtWidgets import (
)
from game.debriefing import Debriefing
from game.theater import Player
from qt_ui.windows.GameUpdateSignal import GameUpdateSignal
T = TypeVar("T")
class LossGrid(QGridLayout):
def __init__(self, debriefing: Debriefing, player: bool) -> None:
def __init__(self, debriefing: Debriefing, player: Player) -> None:
super().__init__()
self.add_loss_rows(
@@ -57,8 +58,10 @@ class LossGrid(QGridLayout):
class ScrollingCasualtyReportContainer(QGroupBox):
def __init__(self, debriefing: Debriefing, player: bool) -> None:
country = debriefing.player_country if player else debriefing.enemy_country
def __init__(self, debriefing: Debriefing, player: Player) -> None:
country = (
debriefing.player_country if player.is_blue else debriefing.enemy_country
)
super().__init__(f"{country}'s lost units:")
scroll_content = QWidget()
scroll_content.setLayout(LossGrid(debriefing, player))
@@ -91,10 +94,14 @@ class QDebriefingWindow(QDialog):
title = QLabel("<b>Casualty report</b>")
layout.addWidget(title)
player_lost_units = ScrollingCasualtyReportContainer(debriefing, player=True)
player_lost_units = ScrollingCasualtyReportContainer(
debriefing, player=Player.BLUE
)
layout.addWidget(player_lost_units)
enemy_lost_units = ScrollingCasualtyReportContainer(debriefing, player=False)
enemy_lost_units = ScrollingCasualtyReportContainer(
debriefing, player=Player.RED
)
layout.addWidget(enemy_lost_units, 1)
okay = QPushButton("Okay")

View File

@@ -25,7 +25,7 @@ from dcs.unittype import UnitType
from game import Game
from game.dcs.groundunittype import GroundUnitType
from game.theater import ControlPoint
from game.theater import ControlPoint, Player
from game.transfers import TransferOrder
from qt_ui.models import GameModel
from qt_ui.widgets.QLabeledWidget import QLabeledWidget
@@ -40,7 +40,7 @@ class TransferDestinationComboBox(QComboBox):
for cp in self.game.theater.controlpoints:
if (
cp != self.origin
and cp.is_friendly(to_player=True)
and cp.is_friendly(to_player=Player.BLUE)
and cp.can_deploy_ground_units
):
self.addItem(cp.name, cp)

View File

@@ -27,6 +27,7 @@ from game.theater import (
FREE_FRONTLINE_UNIT_SUPPLY,
NavalControlPoint,
ParkingType,
Player,
)
from qt_ui.dialogs import Dialog
from qt_ui.models import GameModel
@@ -85,7 +86,7 @@ class QBaseMenu2(QDialog):
self.freq_widget = None
self.link4_widget = None
is_friendly = cp.is_friendly(True)
is_friendly = cp.is_friendly(Player.BLUE)
if is_friendly and isinstance(cp, RadioFrequencyContainer):
self.freq_widget = QFrequencyWidget(cp, self.game_model)
cp_settings.addWidget(self.freq_widget, counter // 2, counter % 2)

View File

@@ -19,7 +19,7 @@ from game.config import REWARDS
from game.data.building_data import FORTIFICATION_BUILDINGS
from game.server import EventStream
from game.sim.gameupdateevents import GameUpdateEvents
from game.theater import ControlPoint, TheaterGroundObject
from game.theater import ControlPoint, TheaterGroundObject, Player
from game.theater.theatergroundobject import (
BuildingGroundObject,
)
@@ -87,12 +87,12 @@ class QGroundObjectMenu(QDialog):
if isinstance(self.ground_object, BuildingGroundObject):
self.mainLayout.addWidget(self.buildingBox)
if self.cp.captured:
if self.cp.captured.is_blue:
self.mainLayout.addWidget(self.financesBox)
else:
self.mainLayout.addWidget(self.intelBox)
self.mainLayout.addWidget(self.orientationBox)
if self.ground_object.is_iads and self.cp.is_friendly(to_player=False):
if self.ground_object.is_iads and self.cp.is_friendly(to_player=Player.RED):
self.mainLayout.addWidget(self.hiddenBox)
self.actionLayout = QHBoxLayout()
@@ -118,8 +118,10 @@ class QGroundObjectMenu(QDialog):
@property
def show_buy_sell_actions(self) -> bool:
if self.cp.captured.is_neutral:
return False
buysell_allowed = self.game.settings.enable_enemy_buy_sell
buysell_allowed |= self.cp.captured
buysell_allowed |= self.cp.captured.is_blue
return buysell_allowed
def doLayout(self):
@@ -133,7 +135,7 @@ class QGroundObjectMenu(QDialog):
QLabel(f"<b>Unit {str(unit.display_name)}</b>"), i, 0
)
if not unit.alive and unit.repairable and self.cp.captured:
if not unit.alive and unit.repairable and self.cp.captured.is_blue:
price = unit.unit_type.price if unit.unit_type else 0
repair = QPushButton(f"Repair [{price}M]")
repair.setProperty("style", "btn-success")