Skip to content

Commit

Permalink
Remove code for old squadron rules.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanAlbert committed Oct 1, 2023
1 parent 6358432 commit 69ec9ad
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 82 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions game/coalition.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,12 @@ def end_turn(self) -> None:
# 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.
Expand All @@ -189,7 +189,7 @@ def initialize_turn(self, is_turn_0: bool) -> None:
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()

Expand Down
6 changes: 3 additions & 3 deletions game/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def finish_turn(self, events: GameUpdateEvents, skipped: bool = False) -> None:
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

Expand All @@ -317,8 +317,8 @@ def begin_turn_0(self, squadrons_start_full: bool) -> None:
# 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.
Expand Down
9 changes: 0 additions & 9 deletions game/settings/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions game/squadrons/airwing.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ def iter_squadrons(self) -> Iterator[Squadron]:
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():
Expand Down
7 changes: 2 additions & 5 deletions game/squadrons/squadron.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,11 @@ def _recruit_pilots(self, count: int) -> None:
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:
Expand Down Expand Up @@ -338,8 +337,6 @@ def expected_size_next_turn(self) -> int:
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

Expand Down
10 changes: 2 additions & 8 deletions qt_ui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,7 @@ def path_arg(arg: str) -> Path:
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(
Expand Down Expand Up @@ -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
Expand All @@ -303,7 +299,6 @@ def from_args(args: argparse.Namespace) -> CreateGameParams | None:
args.date,
args.restrict_weapons_by_date,
args.advanced_iads,
args.use_new_squadron_rules,
args.show_air_wing_config,
)

Expand All @@ -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,
Expand Down Expand Up @@ -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


Expand Down
3 changes: 0 additions & 3 deletions qt_ui/windows/AirWingConfigurationDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,9 +839,6 @@ def revert(self) -> None:
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
Expand Down
50 changes: 1 addition & 49 deletions qt_ui/windows/newgame/QNewGameWizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ def accept(self):

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,
Expand All @@ -177,7 +176,6 @@ def accept(self):
),
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(
Expand Down Expand Up @@ -235,7 +233,7 @@ def accept(self):
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()
Expand Down Expand Up @@ -587,35 +585,6 @@ def __init__(self, label: str, value: int) -> None:
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
Expand Down Expand Up @@ -656,22 +625,6 @@ def __init__(
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()
Expand Down Expand Up @@ -706,7 +659,6 @@ def set_campaign_values(self, campaign: Campaign) -> None:
self.enemy_income.spinner.setValue(
int(campaign.recommended_enemy_income_multiplier * 10)
)
self.new_squadron_rules_warning.set_campaign(campaign)


class PluginOptionCheckbox(QCheckBox):
Expand Down

0 comments on commit 69ec9ad

Please sign in to comment.