Ignore range when manually using auto-create

This commit is contained in:
Raffson
2024-03-09 19:01:38 +01:00
parent 15218d0241
commit eb6afbdf02
5 changed files with 15 additions and 5 deletions

View File

@@ -52,6 +52,7 @@ class AirWing:
heli: bool,
this_turn: bool,
preferred_type: Optional[AircraftType] = None,
ignore_range: bool = False,
) -> list[Squadron]:
airfield_cache = ObjectiveDistanceCache.get_closest_airfields(location)
best_aircraft = AircraftType.priority_list_for_task(task)
@@ -68,7 +69,7 @@ class AirWing:
]
for squadron in squadrons:
if squadron.can_auto_assign_mission(
location, task, size, heli, this_turn
location, task, size, heli, this_turn, ignore_range
):
capable_at_base.append(squadron)
if squadron.aircraft not in best_aircraft:
@@ -100,9 +101,10 @@ class AirWing:
heli: bool,
this_turn: bool,
preferred_type: Optional[AircraftType] = None,
ignore_range: bool = False,
) -> Optional[Squadron]:
for squadron in self.best_squadrons_for(
location, task, size, heli, this_turn, preferred_type
location, task, size, heli, this_turn, preferred_type, ignore_range
):
return squadron
return None

View File

@@ -281,6 +281,7 @@ class Squadron:
size: int,
heli: bool,
this_turn: bool,
ignore_range: bool = False,
) -> bool:
if (
self.location.cptype.name in ["FOB", "FARP"]
@@ -304,6 +305,9 @@ class Squadron:
if heli and task == FlightType.REFUELING:
return False
if ignore_range:
return True
distance_to_target = meters(location.distance_to(self.location))
return distance_to_target <= self.aircraft.max_mission_range