MetalStormGhost 7a9a8e1b4b
Auto-ato AWACS & Tankers settings (#198)
* Auto-ato AWACS & Tankers settings

Split off the **Automatic AWACS package planning** and **Automatic Theater tanker package planning** settings from **Automatic package planning behavior** so players can choose to have AWACS and theater tankers auto-planned, while managing everything else themselves.

* Drop logic to child-classes

* Enable AWACS auto-planning by default

* Switch order of preconditions

---------

Co-authored-by: Raffson <Raffson@users.noreply.github.com>
2023-08-12 19:09:19 +00:00

28 lines
904 B
Python

from __future__ import annotations
from dataclasses import dataclass
from game.ato.flighttype import FlightType
from game.commander.tasks.packageplanningtask import PackagePlanningTask
from game.commander.theaterstate import TheaterState
from game.theater import MissionTarget
@dataclass
class PlanRefueling(PackagePlanningTask[MissionTarget]):
def preconditions_met(self, state: TheaterState) -> bool:
if (
state.context.coalition.player
and not state.context.settings.auto_ato_behavior_tankers
):
return False
if not super().preconditions_met(state):
return False
return self.target in state.refueling_targets
def apply_effects(self, state: TheaterState) -> None:
state.refueling_targets.remove(self.target)
def propose_flights(self) -> None:
self.propose_flight(FlightType.REFUELING, 1)