From 69ec9adec763bf734623fbd733bec2fa2e065dc3 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Sun, 1 Oct 2023 11:58:20 -0700 Subject: [PATCH] Remove code for old squadron rules. --- changelog.md | 1 + game/coalition.py | 6 +-- game/game.py | 6 +-- game/settings/settings.py | 9 ---- game/squadrons/airwing.py | 4 +- game/squadrons/squadron.py | 7 +-- qt_ui/main.py | 10 +---- qt_ui/windows/AirWingConfigurationDialog.py | 3 -- qt_ui/windows/newgame/QNewGameWizard.py | 50 +-------------------- 9 files changed, 14 insertions(+), 82 deletions(-) diff --git a/changelog.md b/changelog.md index 4c6faca7..605b555d 100644 --- a/changelog.md +++ b/changelog.md @@ -6,6 +6,7 @@ Saves from 8.x are not compatible with 9.0.0. * **[Engine]** Support for DCS Open Beta 2.8.8.43489. * **[Campaign]** Added ferry only control points, which offer campaign designers a way to add squadrons that can be brought in after additional airfields are captured. +* **[Campaign]** The new squadron rules (size limits, beginning the campaign at full strength) are now the default and required. The old style of unlimited squadron sizes and starting with zero aircraft has been removed. * **[Data]** Added support for the ARA Veinticinco de Mayo. * **[Data]** Changed display name of the AI-only F-15E Strike Eagle for clarity. * **[Flight Planning]** Improved IP selection for targets that are near the center of a threat zone. diff --git a/game/coalition.py b/game/coalition.py index 156f4ff9..f8abad92 100644 --- a/game/coalition.py +++ b/game/coalition.py @@ -163,12 +163,12 @@ class Coalition: # is handled correctly. self.transfers.perform_transfers() - def preinit_turn_0(self, squadrons_start_full: bool) -> None: + def preinit_turn_0(self) -> None: """Runs final Coalition initialization. Final initialization occurs before Game.initialize_turn runs for turn 0. """ - self.air_wing.populate_for_turn_0(squadrons_start_full) + self.air_wing.populate_for_turn_0() def initialize_turn(self, is_turn_0: bool) -> None: """Processes coalition-specific turn initialization. @@ -189,7 +189,7 @@ class Coalition: with logged_duration("Transport planning"): self.transfers.plan_transports(self.game.conditions.start_time) - if not is_turn_0 or not self.game.settings.enable_squadron_aircraft_limits: + if not is_turn_0: self.plan_missions(self.game.conditions.start_time) self.plan_procurement() diff --git a/game/game.py b/game/game.py index 96de7ac8..f7716e21 100644 --- a/game/game.py +++ b/game/game.py @@ -292,7 +292,7 @@ class Game: if self.turn > 1: self.conditions = self.generate_conditions() - def begin_turn_0(self, squadrons_start_full: bool) -> None: + def begin_turn_0(self) -> None: """Initialization for the first turn of the game.""" from .sim import GameUpdateEvents @@ -317,8 +317,8 @@ class Game: # Rotate the whole TGO with the new heading tgo.rotate(heading or tgo.heading) - self.blue.preinit_turn_0(squadrons_start_full) - self.red.preinit_turn_0(squadrons_start_full) + self.blue.preinit_turn_0() + self.red.preinit_turn_0() # TODO: Check for overfull bases. # We don't need to actually stream events for turn zero because we haven't given # *any* state to the UI yet, so it will need to do a full draw once we do. diff --git a/game/settings/settings.py b/game/settings/settings.py index 369ab10e..93a2a11e 100644 --- a/game/settings/settings.py +++ b/game/settings/settings.py @@ -254,15 +254,6 @@ class Settings: "this many pilots each turn up to the limit." ), ) - # Feature flag for squadron limits. - enable_squadron_aircraft_limits: bool = boolean_option( - "Enable per-squadron aircraft limits", - CAMPAIGN_MANAGEMENT_PAGE, - PILOTS_AND_SQUADRONS_SECTION, - default=False, - remember_player_choice=True, - detail="If set, squadrons will be limited to a maximum number of aircraft.", - ) # HQ Automation automate_runway_repair: bool = boolean_option( diff --git a/game/squadrons/airwing.py b/game/squadrons/airwing.py index ab03c192..70b0c7c4 100644 --- a/game/squadrons/airwing.py +++ b/game/squadrons/airwing.py @@ -127,9 +127,9 @@ class AirWing: def squadron_at_index(self, index: int) -> Squadron: return list(self.iter_squadrons())[index] - def populate_for_turn_0(self, squadrons_start_full: bool) -> None: + def populate_for_turn_0(self) -> None: for squadron in self.iter_squadrons(): - squadron.populate_for_turn_0(squadrons_start_full) + squadron.populate_for_turn_0() def end_turn(self) -> None: for squadron in self.iter_squadrons(): diff --git a/game/squadrons/squadron.py b/game/squadrons/squadron.py index 3a168196..1506617a 100644 --- a/game/squadrons/squadron.py +++ b/game/squadrons/squadron.py @@ -162,12 +162,11 @@ class Squadron: self.current_roster.extend(new_pilots) self.available_pilots.extend(new_pilots) - def populate_for_turn_0(self, squadrons_start_full: bool) -> None: + def populate_for_turn_0(self) -> None: if any(p.status is not PilotStatus.Active for p in self.pilot_pool): raise ValueError("Squadrons can only be created with active pilots.") self._recruit_pilots(self.settings.squadron_pilot_limit) - if squadrons_start_full: - self.owned_aircraft = self.max_size + self.owned_aircraft = self.max_size def end_turn(self) -> None: if self.destination is not None: @@ -338,8 +337,6 @@ class Squadron: return self.owned_aircraft + self.pending_deliveries def has_aircraft_capacity_for(self, n: int) -> bool: - if not self.settings.enable_squadron_aircraft_limits: - return True remaining = self.max_size - self.owned_aircraft - self.pending_deliveries return remaining >= n diff --git a/qt_ui/main.py b/qt_ui/main.py index 06e271f1..5e2d0626 100644 --- a/qt_ui/main.py +++ b/qt_ui/main.py @@ -230,10 +230,7 @@ def parse_args() -> argparse.Namespace: new_game.add_argument( "--use-new-squadron-rules", action="store_true", - help=( - "Limit the number of aircraft per squadron and begin the campaign with " - "them at full strength." - ), + help="Deprecated. Does nothing.", ) new_game.add_argument( @@ -285,7 +282,6 @@ class CreateGameParams: start_date: datetime restrict_weapons_by_date: bool advanced_iads: bool - use_new_squadron_rules: bool show_air_wing_config: bool @staticmethod @@ -303,7 +299,6 @@ class CreateGameParams: args.date, args.restrict_weapons_by_date, args.advanced_iads, - args.use_new_squadron_rules, args.show_air_wing_config, ) @@ -327,7 +322,6 @@ def create_game(params: CreateGameParams) -> Game: enable_frontline_cheats=params.cheats, enable_base_capture_cheat=params.cheats, restrict_weapons_by_date=params.restrict_weapons_by_date, - enable_squadron_aircraft_limits=params.use_new_squadron_rules, ), GeneratorSettings( start_date=params.start_date, @@ -357,7 +351,7 @@ def create_game(params: CreateGameParams) -> Game: if params.show_air_wing_config: if AirWingConfigurationDialog(game, None).exec() == QDialog.DialogCode.Rejected: sys.exit("Aborted air wing configuration") - game.begin_turn_0(squadrons_start_full=params.use_new_squadron_rules) + game.begin_turn_0() return game diff --git a/qt_ui/windows/AirWingConfigurationDialog.py b/qt_ui/windows/AirWingConfigurationDialog.py index c1e464e6..89bafac0 100644 --- a/qt_ui/windows/AirWingConfigurationDialog.py +++ b/qt_ui/windows/AirWingConfigurationDialog.py @@ -839,9 +839,6 @@ class AirWingConfigurationDialog(QDialog): tab.revert() def can_continue(self) -> bool: - if not self.game.settings.enable_squadron_aircraft_limits: - return True - overfull = list(self.parking_tracker.iter_overfull()) if not overfull: return True diff --git a/qt_ui/windows/newgame/QNewGameWizard.py b/qt_ui/windows/newgame/QNewGameWizard.py index 3ce63bab..3769fcb9 100644 --- a/qt_ui/windows/newgame/QNewGameWizard.py +++ b/qt_ui/windows/newgame/QNewGameWizard.py @@ -163,7 +163,6 @@ class NewGameWizard(QtWidgets.QWizard): self.lua_plugin_manager.save_player_settings() - use_new_squadron_rules = self.field("use_new_squadron_rules") logging.info("New campaign start date: %s", start_date.strftime("%m/%d/%Y")) settings = Settings( player_income_multiplier=self.field("player_income_multiplier") / 10, @@ -177,7 +176,6 @@ class NewGameWizard(QtWidgets.QWizard): ), automate_aircraft_reinforcements=self.field("automate_aircraft_purchases"), supercarrier=self.field("supercarrier"), - enable_squadron_aircraft_limits=use_new_squadron_rules, ) settings.save_player_settings() generator_settings = GeneratorSettings( @@ -235,7 +233,7 @@ class NewGameWizard(QtWidgets.QWizard): logging.info("Aborted air wing configuration") return - game.begin_turn_0(squadrons_start_full=use_new_squadron_rules) + game.begin_turn_0() GameUpdateSignal.get_instance().game_generated.emit(game) super(NewGameWizard, self).accept() @@ -587,35 +585,6 @@ class BudgetInputs(QtWidgets.QGridLayout): self.addWidget(self.starting_money, 1, 1) -class NewSquadronRulesWarning(QLabel): - def __init__( - self, campaign: Campaign | None, parent: QWidget | None = None - ) -> None: - super().__init__(parent) - self.set_campaign(campaign) - - def set_campaign(self, campaign: Campaign | None) -> None: - if campaign is None: - self.setText("No campaign selected") - return - if campaign.version >= (10, 9): - text = f"{campaign.name} is compatible with the new squadron rules." - elif campaign.version >= (10, 7): - text = ( - f"{campaign.name} has been updated since the new squadron rules were " - "introduced, but support for those rules was still optional. You may " - "need to remove, resize, or relocate squadrons before beginning the " - "game." - ) - else: - text = ( - f"{campaign.name} has not been updated since the new squadron rules. " - "Were introduced. You may need to remove, resize, or relocate " - "squadrons before beginning the game." - ) - self.setText(wrap_label_text(text)) - - class DifficultyAndAutomationOptions(QtWidgets.QWizardPage): def __init__( self, default_settings: Settings, current_campaign: Campaign | None, parent=None @@ -656,22 +625,6 @@ class DifficultyAndAutomationOptions(QtWidgets.QWizardPage): self.registerField("enemy_starting_money", self.enemy_budget.starting_money) economy_layout.addLayout(self.enemy_budget) - new_squadron_rules = QtWidgets.QCheckBox("Enable new squadron rules") - new_squadron_rules.setChecked(default_settings.enable_squadron_aircraft_limits) - self.registerField("use_new_squadron_rules", new_squadron_rules) - economy_layout.addWidget(new_squadron_rules) - self.new_squadron_rules_warning = NewSquadronRulesWarning(current_campaign) - economy_layout.addWidget(self.new_squadron_rules_warning) - economy_layout.addWidget( - QLabel( - wrap_label_text( - "With new squadron rules enabled, squadrons will not be able to " - "exceed a maximum number of aircraft (configurable), and the " - "campaign will begin with all squadrons at full strength." - ) - ) - ) - assist_group = QtWidgets.QGroupBox("Player assists") layout.addWidget(assist_group) assist_layout = QtWidgets.QGridLayout() @@ -706,7 +659,6 @@ class DifficultyAndAutomationOptions(QtWidgets.QWizardPage): self.enemy_income.spinner.setValue( int(campaign.recommended_enemy_income_multiplier * 10) ) - self.new_squadron_rules_warning.set_campaign(campaign) class PluginOptionCheckbox(QCheckBox):