Raffson 2ec187bc9c
Fixing OCA-bug against FOBs
OCA Aircraft should be properly allowed against FOBs given Ghosti's roadbases
2023-07-05 23:29:48 +02:00

37 lines
1.1 KiB
Python

from __future__ import annotations
import logging
from typing import Type
from game.theater import Airfield, Fob
from .formationattack import (
FormationAttackBuilder,
FormationAttackFlightPlan,
FormationAttackLayout,
)
from .invalidobjectivelocation import InvalidObjectiveLocation
from ..flightwaypointtype import FlightWaypointType
class OcaAircraftFlightPlan(FormationAttackFlightPlan):
@staticmethod
def builder_type() -> Type[Builder]:
return Builder
class Builder(FormationAttackBuilder[OcaAircraftFlightPlan, FormationAttackLayout]):
def layout(self) -> FormationAttackLayout:
location = self.package.target
if not isinstance(location, Airfield) and not isinstance(location, Fob):
logging.exception(
f"Invalid Objective Location for OCA/Aircraft flight "
f"{self.flight=} at {location=}."
)
raise InvalidObjectiveLocation(self.flight.flight_type, location)
return self._build(FlightWaypointType.INGRESS_OCA_AIRCRAFT)
def build(self) -> OcaAircraftFlightPlan:
return OcaAircraftFlightPlan(self.flight, self.layout())