Allow custom mission types

Instead of giving an error when a mission type which was added to the squadron is not defined in the Ai autoplanner db for the aircraft the user should be able to task the aircraft accordingly.
This commit is contained in:
RndName
2022-04-21 19:38:42 +02:00
parent 5be92cd75e
commit f04030858b
4 changed files with 16 additions and 19 deletions

View File

@@ -57,6 +57,9 @@ class AirWing:
for squadron in control_point.squadrons:
if squadron.can_auto_assign_mission(location, task, size, this_turn):
capable_at_base.append(squadron)
if squadron.aircraft not in best_aircraft:
# If it is not already in the list it should be the last one
best_aircraft.append(squadron.aircraft)
ordered.extend(
sorted(
@@ -73,11 +76,10 @@ class AirWing:
return squadron
return None
@property
def available_aircraft_types(self) -> Iterator[AircraftType]:
def available_aircraft_for_task(self, task: FlightType) -> Iterator[AircraftType]:
for aircraft, squadrons in self.squadrons.items():
for squadron in squadrons:
if squadron.untasked_aircraft:
if squadron.untasked_aircraft and task in squadron.mission_types:
yield aircraft
break