mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Propagate changes from Liberation
This commit is contained in:
parent
711d102425
commit
5e2625ad21
@ -114,7 +114,7 @@ class DefaultSquadronAssigner:
|
|||||||
) -> bool:
|
) -> bool:
|
||||||
if ignore_base_preference:
|
if ignore_base_preference:
|
||||||
return control_point.can_operate(squadron.aircraft)
|
return control_point.can_operate(squadron.aircraft)
|
||||||
return squadron.operates_from(control_point) and task in squadron.mission_types
|
return squadron.operates_from(control_point) and squadron.capable_of(task)
|
||||||
|
|
||||||
def find_squadron_for_airframe(
|
def find_squadron_for_airframe(
|
||||||
self, aircraft: AircraftType, task: FlightType, control_point: ControlPoint
|
self, aircraft: AircraftType, task: FlightType, control_point: ControlPoint
|
||||||
|
|||||||
@ -81,7 +81,7 @@ class AirWing:
|
|||||||
best_aircraft_for_task = AircraftType.priority_list_for_task(task)
|
best_aircraft_for_task = AircraftType.priority_list_for_task(task)
|
||||||
for aircraft, squadrons in self.squadrons.items():
|
for aircraft, squadrons in self.squadrons.items():
|
||||||
for squadron in squadrons:
|
for squadron in squadrons:
|
||||||
if squadron.untasked_aircraft and task in squadron.mission_types:
|
if squadron.untasked_aircraft and squadron.capable_of(task):
|
||||||
aircrafts.append(aircraft)
|
aircrafts.append(aircraft)
|
||||||
if aircraft not in best_aircraft_for_task:
|
if aircraft not in best_aircraft_for_task:
|
||||||
best_aircraft_for_task.append(aircraft)
|
best_aircraft_for_task.append(aircraft)
|
||||||
|
|||||||
@ -31,7 +31,7 @@ class Squadron:
|
|||||||
role: str
|
role: str
|
||||||
aircraft: AircraftType
|
aircraft: AircraftType
|
||||||
livery: Optional[str]
|
livery: Optional[str]
|
||||||
mission_types: tuple[FlightType, ...]
|
auto_assignable_mission_types: set[FlightType]
|
||||||
operating_bases: OperatingBases
|
operating_bases: OperatingBases
|
||||||
female_pilot_percentage: int
|
female_pilot_percentage: int
|
||||||
|
|
||||||
@ -45,10 +45,6 @@ class Squadron:
|
|||||||
default_factory=list, init=False, hash=False, compare=False
|
default_factory=list, init=False, hash=False, compare=False
|
||||||
)
|
)
|
||||||
|
|
||||||
auto_assignable_mission_types: set[FlightType] = field(
|
|
||||||
init=False, hash=False, compare=False
|
|
||||||
)
|
|
||||||
|
|
||||||
coalition: Coalition = field(hash=False, compare=False)
|
coalition: Coalition = field(hash=False, compare=False)
|
||||||
flight_db: Database[Flight] = field(hash=False, compare=False)
|
flight_db: Database[Flight] = field(hash=False, compare=False)
|
||||||
settings: Settings = field(hash=False, compare=False)
|
settings: Settings = field(hash=False, compare=False)
|
||||||
@ -62,9 +58,6 @@ class Squadron:
|
|||||||
untasked_aircraft: int = field(init=False, hash=False, compare=False, default=0)
|
untasked_aircraft: int = field(init=False, hash=False, compare=False, default=0)
|
||||||
pending_deliveries: int = field(init=False, hash=False, compare=False, default=0)
|
pending_deliveries: int = field(init=False, hash=False, compare=False, default=0)
|
||||||
|
|
||||||
def __post_init__(self) -> None:
|
|
||||||
self.auto_assignable_mission_types = set(self.mission_types)
|
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
if self.nickname is None:
|
if self.nickname is None:
|
||||||
return self.name
|
return self.name
|
||||||
@ -93,16 +86,12 @@ class Squadron:
|
|||||||
def pilot_limits_enabled(self) -> bool:
|
def pilot_limits_enabled(self) -> bool:
|
||||||
return self.settings.enable_squadron_pilot_limits
|
return self.settings.enable_squadron_pilot_limits
|
||||||
|
|
||||||
def set_allowed_mission_types(self, mission_types: Iterable[FlightType]) -> None:
|
|
||||||
self.mission_types = tuple(mission_types)
|
|
||||||
self.auto_assignable_mission_types.intersection_update(self.mission_types)
|
|
||||||
|
|
||||||
def set_auto_assignable_mission_types(
|
def set_auto_assignable_mission_types(
|
||||||
self, mission_types: Iterable[FlightType]
|
self, mission_types: Iterable[FlightType]
|
||||||
) -> None:
|
) -> None:
|
||||||
self.auto_assignable_mission_types = set(self.mission_types).intersection(
|
self.auto_assignable_mission_types = {
|
||||||
mission_types
|
t for t in mission_types if self.capable_of(t)
|
||||||
)
|
}
|
||||||
|
|
||||||
def claim_new_pilot_if_allowed(self) -> Optional[Pilot]:
|
def claim_new_pilot_if_allowed(self) -> Optional[Pilot]:
|
||||||
if self.pilot_limits_enabled:
|
if self.pilot_limits_enabled:
|
||||||
@ -439,7 +428,7 @@ class Squadron:
|
|||||||
squadron_def.role,
|
squadron_def.role,
|
||||||
squadron_def.aircraft,
|
squadron_def.aircraft,
|
||||||
squadron_def.livery,
|
squadron_def.livery,
|
||||||
squadron_def.mission_types,
|
squadron_def.auto_assignable_mission_types,
|
||||||
squadron_def.operating_bases,
|
squadron_def.operating_bases,
|
||||||
squadron_def.female_pilot_percentage,
|
squadron_def.female_pilot_percentage,
|
||||||
squadron_def.pilot_pool,
|
squadron_def.pilot_pool,
|
||||||
|
|||||||
@ -31,17 +31,18 @@ class SquadronDef:
|
|||||||
pilot_pool: list[Pilot]
|
pilot_pool: list[Pilot]
|
||||||
claimed: bool = False
|
claimed: bool = False
|
||||||
|
|
||||||
def __post_init__(self) -> None:
|
|
||||||
self.auto_assignable_mission_types = set(self.mission_types)
|
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
if self.nickname is None:
|
if self.nickname is None:
|
||||||
return self.name
|
return self.name
|
||||||
return f'{self.name} "{self.nickname}"'
|
return f'{self.name} "{self.nickname}"'
|
||||||
|
|
||||||
def set_allowed_mission_types(self, mission_types: Iterable[FlightType]) -> None:
|
def capable_of(self, task: FlightType) -> bool:
|
||||||
self.mission_types = tuple(mission_types)
|
"""Returns True if the squadron is capable of performing the given task.
|
||||||
self.auto_assignable_mission_types.intersection_update(self.mission_types)
|
|
||||||
|
A squadron may be capable of performing a task even if it will not be
|
||||||
|
automatically assigned to it.
|
||||||
|
"""
|
||||||
|
return self.aircraft.capable_of(task)
|
||||||
|
|
||||||
def can_auto_assign(self, task: FlightType) -> bool:
|
def can_auto_assign(self, task: FlightType) -> bool:
|
||||||
"""
|
"""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user