mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Clean up silly some exception handling.
This commit is contained in:
parent
9cd511da3d
commit
3dd0e4a66f
@ -72,9 +72,9 @@ class FlightPlanBuilder:
|
|||||||
f"{flight.departure} to {flight.package.target}"
|
f"{flight.departure} to {flight.package.target}"
|
||||||
) from ex
|
) from ex
|
||||||
|
|
||||||
def plan_type(self, task: FlightType) -> Type[FlightPlan[Any]] | None:
|
def plan_type(self, flight: Flight) -> Type[FlightPlan[Any]]:
|
||||||
plan_type: Type[FlightPlan[Any]]
|
plan_type: Type[FlightPlan[Any]]
|
||||||
if task == FlightType.REFUELING:
|
if flight.flight_type is FlightType.REFUELING:
|
||||||
if self.package.target.is_friendly(self.is_player) or isinstance(
|
if self.package.target.is_friendly(self.is_player) or isinstance(
|
||||||
self.package.target, FrontLine
|
self.package.target, FrontLine
|
||||||
):
|
):
|
||||||
@ -100,13 +100,14 @@ class FlightPlanBuilder:
|
|||||||
FlightType.FERRY: FerryFlightPlan,
|
FlightType.FERRY: FerryFlightPlan,
|
||||||
FlightType.AIR_ASSAULT: AirAssaultFlightPlan,
|
FlightType.AIR_ASSAULT: AirAssaultFlightPlan,
|
||||||
}
|
}
|
||||||
return plan_dict.get(task)
|
try:
|
||||||
|
return plan_dict[flight.flight_type]
|
||||||
def generate_flight_plan(self, flight: Flight) -> FlightPlan[Any]:
|
except KeyError as ex:
|
||||||
plan_type = self.plan_type(flight.flight_type)
|
|
||||||
if plan_type is None:
|
|
||||||
raise PlanningError(
|
raise PlanningError(
|
||||||
f"{flight.flight_type} flight plan generation not implemented"
|
f"{flight.flight_type} flight plan generation not implemented"
|
||||||
)
|
) from ex
|
||||||
|
|
||||||
|
def generate_flight_plan(self, flight: Flight) -> FlightPlan[Any]:
|
||||||
|
plan_type = self.plan_type(flight)
|
||||||
layout = plan_type.builder_type()(flight, self.theater).build()
|
layout = plan_type.builder_type()(flight, self.theater).build()
|
||||||
return plan_type(flight, layout)
|
return plan_type(flight, layout)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user