diff --git a/game/commander/missionproposals.py b/game/commander/missionproposals.py index 7f712422..628bc50c 100644 --- a/game/commander/missionproposals.py +++ b/game/commander/missionproposals.py @@ -9,6 +9,7 @@ from game.theater import MissionTarget class EscortType(Enum): AirToAir = auto() Sead = auto() + Refuel = auto() @dataclass(frozen=True) diff --git a/game/commander/packagefulfiller.py b/game/commander/packagefulfiller.py index c4dcd6d2..d3b5a9e2 100644 --- a/game/commander/packagefulfiller.py +++ b/game/commander/packagefulfiller.py @@ -154,17 +154,17 @@ class PackageFulfiller: missing_types: Set[FlightType] = set() escorts = [] for proposed_flight in mission.flights: + if proposed_flight.escort_type is not None: + # Escorts are planned after the primary elements of the package. + # If the package does not need escorts they may be pruned. + escorts.append(proposed_flight) + continue if not self.air_wing_can_plan(proposed_flight.task): # This air wing can never plan this mission type because they do not # have compatible aircraft or squadrons. Skip fulfillment so that we # don't place the purchase request. missing_types.add(proposed_flight.task) break - if proposed_flight.escort_type is not None: - # Escorts are planned after the primary elements of the package. - # If the package does not need escorts they may be pruned. - escorts.append(proposed_flight) - continue with tracer.trace("Flight planning"): self.plan_flight( mission, diff --git a/game/commander/tasks/primitive/antishipping.py b/game/commander/tasks/primitive/antishipping.py index 8a65a7c8..2843c24f 100644 --- a/game/commander/tasks/primitive/antishipping.py +++ b/game/commander/tasks/primitive/antishipping.py @@ -1,9 +1,9 @@ from __future__ import annotations from dataclasses import dataclass -from random import randint from game.ato.flighttype import FlightType +from game.commander.missionproposals import EscortType from game.commander.tasks.packageplanningtask import PackagePlanningTask from game.commander.theaterstate import TheaterState from game.transfers import CargoShip @@ -24,4 +24,4 @@ class PlanAntiShipping(PackagePlanningTask[CargoShip]): def propose_flights(self) -> None: size = self.get_flight_size() self.propose_flight(FlightType.ANTISHIP, size) - self.propose_common_escorts() + self.propose_flight(FlightType.ESCORT, 2, EscortType.AirToAir) diff --git a/game/commander/tasks/primitive/cas.py b/game/commander/tasks/primitive/cas.py index 372016c3..6a43b2df 100644 --- a/game/commander/tasks/primitive/cas.py +++ b/game/commander/tasks/primitive/cas.py @@ -3,6 +3,7 @@ from __future__ import annotations from dataclasses import dataclass from game.ato.flighttype import FlightType +from game.commander.missionproposals import EscortType from game.commander.tasks.packageplanningtask import PackagePlanningTask from game.commander.theaterstate import TheaterState from game.theater import FrontLine @@ -31,5 +32,5 @@ class PlanCas(PackagePlanningTask[FrontLine]): def propose_flights(self) -> None: size = self.get_flight_size() self.propose_flight(FlightType.CAS, size) - self.propose_flight(FlightType.TARCAP, 2) - self.propose_flight(FlightType.SEAD_SWEEP, 2) + self.propose_flight(FlightType.TARCAP, 2, EscortType.AirToAir) + self.propose_flight(FlightType.SEAD_SWEEP, 2, EscortType.Sead) diff --git a/game/commander/tasks/primitive/dead.py b/game/commander/tasks/primitive/dead.py index c1a29ea6..ad7d26bb 100644 --- a/game/commander/tasks/primitive/dead.py +++ b/game/commander/tasks/primitive/dead.py @@ -3,6 +3,7 @@ from __future__ import annotations from dataclasses import dataclass from game.ato.flighttype import FlightType +from game.commander.missionproposals import EscortType from game.commander.tasks.packageplanningtask import PackagePlanningTask from game.commander.theaterstate import TheaterState from game.theater.theatergroundobject import IadsGroundObject @@ -39,8 +40,8 @@ class PlanDead(PackagePlanningTask[IadsGroundObject]): # also threatened by SAMs. We don't want to include a SEAD escort if the # package is *only* threatened by the target though. Could be improved, but # needs a decent refactor to the escort planning to do so. - if self.target.has_live_radar_sam: - self.propose_flight(FlightType.SEAD, 2) self.propose_common_escorts() + if self.target.has_live_radar_sam: + self.propose_flight(FlightType.SEAD, 2, EscortType.Sead) if self.target.control_point.coalition.game.settings.autoplan_tankers_for_dead: - self.propose_flight(FlightType.REFUELING, 1) + self.propose_flight(FlightType.REFUELING, 1, EscortType.Refuel) diff --git a/game/commander/tasks/primitive/oca.py b/game/commander/tasks/primitive/oca.py index 6877150d..dd57c806 100644 --- a/game/commander/tasks/primitive/oca.py +++ b/game/commander/tasks/primitive/oca.py @@ -3,6 +3,7 @@ from __future__ import annotations from dataclasses import dataclass from game.ato.flighttype import FlightType +from game.commander.missionproposals import EscortType from game.commander.tasks.packageplanningtask import PackagePlanningTask from game.commander.theaterstate import TheaterState from game.theater import ControlPoint @@ -30,4 +31,4 @@ class PlanOcaStrike(PackagePlanningTask[ControlPoint]): self.propose_flight(FlightType.OCA_AIRCRAFT, 2) self.propose_common_escorts() if self.target.coalition.game.settings.autoplan_tankers_for_oca: - self.propose_flight(FlightType.REFUELING, 1) + self.propose_flight(FlightType.REFUELING, 1, EscortType.Refuel) diff --git a/game/commander/tasks/primitive/strike.py b/game/commander/tasks/primitive/strike.py index d38260d5..a900810e 100644 --- a/game/commander/tasks/primitive/strike.py +++ b/game/commander/tasks/primitive/strike.py @@ -3,6 +3,7 @@ from __future__ import annotations from dataclasses import dataclass from game.ato.flighttype import FlightType +from game.commander.missionproposals import EscortType from game.commander.tasks.packageplanningtask import PackagePlanningTask from game.commander.theaterstate import TheaterState from game.theater.theatergroundobject import TheaterGroundObject @@ -25,4 +26,4 @@ class PlanStrike(PackagePlanningTask[TheaterGroundObject]): self.propose_flight(FlightType.STRIKE, min(4, (tgt_count // 2) + tgt_count % 2)) self.propose_common_escorts() if self.target.coalition.game.settings.autoplan_tankers_for_strike: - self.propose_flight(FlightType.REFUELING, 1) + self.propose_flight(FlightType.REFUELING, 1, EscortType.Refuel)