Set the flight airfields based on the Squadron.

This commit is contained in:
Dan Albert 2021-08-31 22:11:59 -07:00
parent a404792bd2
commit f9f0b429b6
6 changed files with 13 additions and 22 deletions

View File

@ -54,8 +54,6 @@ class PackageBuilder:
plan.num_aircraft, plan.num_aircraft,
plan.task, plan.task,
start_type, start_type,
departure=airfield,
arrival=airfield,
divert=self.find_divert_field(squadron.aircraft, airfield), divert=self.find_divert_field(squadron.aircraft, airfield),
) )
self.package.add_flight(flight) self.package.add_flight(flight)

View File

@ -308,6 +308,10 @@ class Squadron:
def expected_size_next_turn(self) -> int: def expected_size_next_turn(self) -> int:
return self.owned_aircraft + self.pending_deliveries return self.owned_aircraft + self.pending_deliveries
@property
def arrival(self) -> ControlPoint:
return self.location if self.destination is None else self.destination
def plan_relocation(self, destination: ControlPoint) -> None: def plan_relocation(self, destination: ControlPoint) -> None:
if destination == self.location: if destination == self.location:
logging.warning( logging.warning(

View File

@ -360,8 +360,6 @@ class AirliftPlanner:
flight_size, flight_size,
FlightType.TRANSPORT, FlightType.TRANSPORT,
start_type, start_type,
departure=squadron.location,
arrival=squadron.location,
divert=None, divert=None,
cargo=transfer, cargo=transfer,
) )

View File

@ -606,41 +606,36 @@ class AircraftConflictGenerator:
for squadron in control_point.squadrons: for squadron in control_point.squadrons:
try: try:
self._spawn_unused_at(control_point, country, faction, squadron) self._spawn_unused_for(squadron, country, faction)
except NoParkingSlotError: except NoParkingSlotError:
# If we run out of parking, stop spawning aircraft. # If we run out of parking, stop spawning aircraft.
return return
def _spawn_unused_at( def _spawn_unused_for(
self, self, squadron: Squadron, country: Country, faction: Faction
control_point: Airfield,
country: Country,
faction: Faction,
squadron: Squadron,
) -> None: ) -> None:
assert isinstance(squadron.location, Airfield)
for _ in range(squadron.untasked_aircraft): for _ in range(squadron.untasked_aircraft):
# Creating a flight even those this isn't a fragged mission lets us # Creating a flight even those this isn't a fragged mission lets us
# reuse the existing debriefing code. # reuse the existing debriefing code.
# TODO: Special flight type? # TODO: Special flight type?
flight = Flight( flight = Flight(
Package(control_point), Package(squadron.location),
faction.country, faction.country,
squadron, squadron,
1, 1,
FlightType.BARCAP, FlightType.BARCAP,
"Cold", "Cold",
departure=control_point,
arrival=control_point,
divert=None, divert=None,
) )
group = self._generate_at_airport( group = self._generate_at_airport(
name=namegen.next_aircraft_name(country, control_point.id, flight), name=namegen.next_aircraft_name(country, flight.departure.id, flight),
side=country, side=country,
unit_type=squadron.aircraft.dcs_unit_type, unit_type=squadron.aircraft.dcs_unit_type,
count=1, count=1,
start_type="Cold", start_type="Cold",
airport=control_point.airport, airport=squadron.location.airport,
) )
self._setup_livery(flight, group) self._setup_livery(flight, group)

View File

@ -280,8 +280,6 @@ class Flight:
count: int, count: int,
flight_type: FlightType, flight_type: FlightType,
start_type: str, start_type: str,
departure: ControlPoint,
arrival: ControlPoint,
divert: Optional[ControlPoint], divert: Optional[ControlPoint],
custom_name: Optional[str] = None, custom_name: Optional[str] = None,
cargo: Optional[TransferOrder] = None, cargo: Optional[TransferOrder] = None,
@ -295,8 +293,8 @@ class Flight:
self.roster = FlightRoster(self.squadron, initial_size=count) self.roster = FlightRoster(self.squadron, initial_size=count)
else: else:
self.roster = roster self.roster = roster
self.departure = departure self.departure = self.squadron.location
self.arrival = arrival self.arrival = self.squadron.arrival
self.divert = divert self.divert = divert
self.flight_type = flight_type self.flight_type = flight_type
# TODO: Replace with FlightPlan. # TODO: Replace with FlightPlan.

View File

@ -182,8 +182,6 @@ class QFlightCreator(QDialog):
roster.max_size, roster.max_size,
task, task,
self.start_type.currentText(), self.start_type.currentText(),
squadron.location,
squadron.location,
divert, divert,
custom_name=self.custom_name_text, custom_name=self.custom_name_text,
roster=roster, roster=roster,