Raffson 1f4cca329e
Vary number of aircraft for main task
The following tasks plan according to the number of targets left:
- BAI
- ANTISHIP
- DEAD
- STRIKE

Other tasks use a random value between 2 and 4.
2022-08-15 01:20:14 +02:00

36 lines
1.4 KiB
Python

from __future__ import annotations
from dataclasses import dataclass
from random import randint
from game.commander.tasks.packageplanningtask import PackagePlanningTask
from game.commander.theaterstate import TheaterState
from game.theater import ControlPoint
from game.ato.flighttype import FlightType
@dataclass
class PlanAirAssault(PackagePlanningTask[ControlPoint]):
def preconditions_met(self, state: TheaterState) -> bool:
if self.target not in state.air_assault_targets:
return False
if self.capture_blocked(state):
# Do not task if there are enemy battle_positions blocking the capture
return False
if not self.target_area_preconditions_met(state):
# Do not task if air defense is present in the target area
return False
return super().preconditions_met(state)
def capture_blocked(self, state: TheaterState) -> bool:
battle_positions = state.enemy_battle_positions[self.target]
return len(battle_positions.blocking_capture) > 0
def apply_effects(self, state: TheaterState) -> None:
state.air_assault_targets.remove(self.target)
def propose_flights(self) -> None:
self.propose_flight(FlightType.AIR_ASSAULT, randint(2, 4))
# TODO Validate this.. / is Heli escort possible?
self.propose_flight(FlightType.TARCAP, 2)