mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
@@ -3,6 +3,7 @@ from enum import Enum, auto
|
||||
from typing import Optional
|
||||
|
||||
from game.ato.flighttype import FlightType
|
||||
from game.dcs.aircrafttype import AircraftType
|
||||
from game.theater import MissionTarget
|
||||
|
||||
|
||||
@@ -33,6 +34,8 @@ class ProposedFlight:
|
||||
#: field is None.
|
||||
escort_type: Optional[EscortType] = field(default=None)
|
||||
|
||||
preferred_type: Optional[AircraftType] = field(default=None)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"{self.task} {self.num_aircraft} ship"
|
||||
|
||||
|
||||
@@ -49,7 +49,12 @@ class PackageBuilder:
|
||||
pf = self.package.primary_flight
|
||||
heli = pf.is_helo if pf else False
|
||||
squadron = self.air_wing.best_squadron_for(
|
||||
self.package.target, plan.task, plan.num_aircraft, heli, this_turn=True
|
||||
self.package.target,
|
||||
plan.task,
|
||||
plan.num_aircraft,
|
||||
heli,
|
||||
this_turn=True,
|
||||
preferred_type=plan.preferred_type,
|
||||
)
|
||||
if squadron is None:
|
||||
return False
|
||||
|
||||
@@ -51,6 +51,7 @@ class AirWing:
|
||||
size: int,
|
||||
heli: bool,
|
||||
this_turn: bool,
|
||||
preferred_type: Optional[AircraftType] = None,
|
||||
) -> list[Squadron]:
|
||||
airfield_cache = ObjectiveDistanceCache.get_closest_airfields(location)
|
||||
best_aircraft = AircraftType.priority_list_for_task(task)
|
||||
@@ -59,7 +60,13 @@ class AirWing:
|
||||
if control_point.captured != self.player:
|
||||
continue
|
||||
capable_at_base = []
|
||||
for squadron in control_point.squadrons:
|
||||
squadrons = [
|
||||
s
|
||||
for s in control_point.squadrons
|
||||
if not preferred_type
|
||||
or s.aircraft.variant_id == preferred_type.variant_id
|
||||
]
|
||||
for squadron in squadrons:
|
||||
if squadron.can_auto_assign_mission(
|
||||
location, task, size, heli, this_turn
|
||||
):
|
||||
@@ -92,8 +99,11 @@ class AirWing:
|
||||
size: int,
|
||||
heli: bool,
|
||||
this_turn: bool,
|
||||
preferred_type: Optional[AircraftType] = None,
|
||||
) -> Optional[Squadron]:
|
||||
for squadron in self.best_squadrons_for(location, task, size, heli, this_turn):
|
||||
for squadron in self.best_squadrons_for(
|
||||
location, task, size, heli, this_turn, preferred_type
|
||||
):
|
||||
return squadron
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user