Override squadron base preferences when named.

This allows campaign designers to forcibly place specific squadrons at
bases that they would not normally be assigned to, such as assigning
CV-only squadrons to the shore. The airframe itself must be compatible
with the location type, so A-10s still may not be assigned to carriers.

This change only applies to squadrons that are named explicitly. There's
no need for squadrons defined by type because a squadron will always be
generated to fit the need if no pre-defined squadron is found.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1621
This commit is contained in:
Dan Albert 2021-10-14 20:49:18 -07:00
parent 5e5f249bd2
commit 76b3ff5f6e

View File

@ -109,8 +109,13 @@ class DefaultSquadronAssigner:
@staticmethod
def squadron_compatible_with(
squadron: SquadronDef, task: FlightType, control_point: ControlPoint
squadron: SquadronDef,
task: FlightType,
control_point: ControlPoint,
ignore_base_preference: bool = False,
) -> bool:
if ignore_base_preference:
return control_point.can_operate(squadron.aircraft)
return squadron.operates_from(control_point) and task in squadron.mission_types
def find_squadron_for_airframe(
@ -127,7 +132,7 @@ class DefaultSquadronAssigner:
for squadrons in self.squadron_defs.values():
for squadron in squadrons:
if squadron.name == name and self.squadron_compatible_with(
squadron, task, control_point
squadron, task, control_point, ignore_base_preference=True
):
return squadron
return None