mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Limit squadron tasks to those of the aircraft.
https://github.com/dcs-liberation/dcs_liberation/issues/276
This commit is contained in:
parent
e8edb31be3
commit
1795ed7617
@ -177,6 +177,7 @@ class Squadron:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_yaml(cls, path: Path, game: Game, player: bool) -> Squadron:
|
def from_yaml(cls, path: Path, game: Game, player: bool) -> Squadron:
|
||||||
|
from gen.flights.ai_flight_planner_db import tasks_for_aircraft
|
||||||
from gen.flights.flight import FlightType
|
from gen.flights.flight import FlightType
|
||||||
|
|
||||||
with path.open() as squadron_file:
|
with path.open() as squadron_file:
|
||||||
@ -189,6 +190,16 @@ class Squadron:
|
|||||||
pilots = [Pilot(n, player=False) for n in data.get("pilots", [])]
|
pilots = [Pilot(n, player=False) for n in data.get("pilots", [])]
|
||||||
pilots.extend([Pilot(n, player=True) for n in data.get("players", [])])
|
pilots.extend([Pilot(n, player=True) for n in data.get("players", [])])
|
||||||
|
|
||||||
|
mission_types = [FlightType.from_name(n) for n in data["mission_types"]]
|
||||||
|
tasks = tasks_for_aircraft(unit_type)
|
||||||
|
for mission_type in list(mission_types):
|
||||||
|
if mission_type not in tasks:
|
||||||
|
logging.error(
|
||||||
|
f"Squadron has mission type {mission_type} but {unit_type} is not "
|
||||||
|
f"capable of that task: {path}"
|
||||||
|
)
|
||||||
|
mission_types.remove(mission_type)
|
||||||
|
|
||||||
return Squadron(
|
return Squadron(
|
||||||
name=data["name"],
|
name=data["name"],
|
||||||
nickname=data["nickname"],
|
nickname=data["nickname"],
|
||||||
@ -196,7 +207,7 @@ class Squadron:
|
|||||||
role=data["role"],
|
role=data["role"],
|
||||||
aircraft=unit_type,
|
aircraft=unit_type,
|
||||||
livery=data.get("livery"),
|
livery=data.get("livery"),
|
||||||
mission_types=tuple(FlightType.from_name(n) for n in data["mission_types"]),
|
mission_types=tuple(mission_types),
|
||||||
pilots=pilots,
|
pilots=pilots,
|
||||||
game=game,
|
game=game,
|
||||||
player=player,
|
player=player,
|
||||||
@ -262,7 +273,7 @@ class SquadronLoader:
|
|||||||
|
|
||||||
class AirWing:
|
class AirWing:
|
||||||
def __init__(self, game: Game, player: bool) -> None:
|
def __init__(self, game: Game, player: bool) -> None:
|
||||||
from gen.flights.flight import FlightType
|
from gen.flights.ai_flight_planner_db import tasks_for_aircraft
|
||||||
|
|
||||||
self.game = game
|
self.game = game
|
||||||
self.player = player
|
self.player = player
|
||||||
@ -280,7 +291,7 @@ class AirWing:
|
|||||||
role="Flying Squadron",
|
role="Flying Squadron",
|
||||||
aircraft=aircraft,
|
aircraft=aircraft,
|
||||||
livery=None,
|
livery=None,
|
||||||
mission_types=tuple(FlightType),
|
mission_types=tuple(tasks_for_aircraft(aircraft)),
|
||||||
pilots=[],
|
pilots=[],
|
||||||
game=game,
|
game=game,
|
||||||
player=player,
|
player=player,
|
||||||
|
|||||||
@ -426,3 +426,11 @@ def aircraft_for_task(task: FlightType) -> List[Type[FlyingType]]:
|
|||||||
else:
|
else:
|
||||||
logging.error(f"Unplannable flight type: {task}")
|
logging.error(f"Unplannable flight type: {task}")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
def tasks_for_aircraft(aircraft: Type[FlyingType]) -> list[FlightType]:
|
||||||
|
tasks = []
|
||||||
|
for task in FlightType:
|
||||||
|
if aircraft in aircraft_for_task(task):
|
||||||
|
tasks.append(task)
|
||||||
|
return tasks
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user