mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
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:
@@ -24,7 +24,7 @@ from game.radio.tacan import TacanChannel
|
||||
from game.server import EventStream
|
||||
from game.sim.gameupdateevents import GameUpdateEvents
|
||||
from game.squadrons.squadron import Pilot, Squadron
|
||||
from game.theater import NavalControlPoint
|
||||
from game.theater import NavalControlPoint, Player
|
||||
from game.theater.missiontarget import MissionTarget
|
||||
from game.transfers import PendingTransfers, TransferOrder
|
||||
from qt_ui.simcontroller import SimController
|
||||
@@ -564,8 +564,8 @@ class GameModel:
|
||||
self.allocated_icls: list[int] = list()
|
||||
self.init_comms_registry()
|
||||
|
||||
def ato_model_for(self, player: bool) -> AtoModel:
|
||||
if player:
|
||||
def ato_model_for(self, player: Player) -> AtoModel:
|
||||
if player.is_blue:
|
||||
return self.ato_model
|
||||
return self.red_ato_model
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ from PySide6.QtWidgets import (
|
||||
|
||||
from game import Game
|
||||
from game.income import Income
|
||||
from game.theater import Player
|
||||
from qt_ui.windows.intel import IntelWindow
|
||||
|
||||
|
||||
@@ -76,8 +77,8 @@ class QIntelBox(QGroupBox):
|
||||
|
||||
def economic_strength_text(self) -> str:
|
||||
assert self.game is not None
|
||||
own = Income(self.game, player=True).total
|
||||
enemy = Income(self.game, player=False).total
|
||||
own = Income(self.game, player=Player.BLUE).total
|
||||
enemy = Income(self.game, player=Player.RED).total
|
||||
|
||||
if not enemy:
|
||||
return "enemy economy ruined"
|
||||
|
||||
@@ -6,6 +6,7 @@ from game.ato.flightwaypointtype import FlightWaypointType
|
||||
from game.missiongenerator.frontlineconflictdescription import (
|
||||
FrontLineConflictDescription,
|
||||
)
|
||||
from game.theater.player import Player
|
||||
from game.theater.controlpoint import ControlPointType
|
||||
from game.utils import Distance
|
||||
from qt_ui.widgets.combos.QFilteredComboBox import QFilteredComboBox
|
||||
@@ -93,7 +94,7 @@ class QPredefinedWaypointSelectionComboBox(QFilteredComboBox):
|
||||
wpt.targets.append(target)
|
||||
wpt.obj_name = tgo.obj_name
|
||||
wpt.waypoint_type = FlightWaypointType.CUSTOM
|
||||
if tgo.is_friendly(to_player=True):
|
||||
if tgo.is_friendly(to_player=Player.BLUE):
|
||||
wpt.description = f"Friendly unit: {target.name}"
|
||||
else:
|
||||
wpt.description = f"Enemy unit: {target.name}"
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user