Account for planned missions for breakthrough.

Consider BAI missions planned this turn when determining if a control
point is still garrisioned for preventing breakthrough.

This isn't very accurate yet since the HTN isn't checking for aircraft
fulfillment yet, so it might *plan* a mission to kill the garrison, but
there's no way to know if it will be fulfilled.
This commit is contained in:
Dan Albert
2021-07-13 13:50:50 -07:00
parent c180eb466d
commit 4534758c21
7 changed files with 59 additions and 59 deletions

View File

@@ -2,9 +2,6 @@ from __future__ import annotations
from game.commander.tasks.frontlinestancetask import FrontLineStanceTask
from game.commander.theaterstate import TheaterState
from game.theater import ControlPoint
from game.theater.theatergroundobject import VehicleGroupGroundObject
from game.utils import meters
from gen.ground_forces.combat_stance import CombatStance
@@ -17,20 +14,14 @@ class BreakthroughAttack(FrontLineStanceTask):
def have_sufficient_front_line_advantage(self) -> bool:
return self.ground_force_balance >= 2.0
@property
def opposing_garrisons_eliminated(self) -> bool:
# TODO: Should operate on TheaterState to account for BAIs planned this turn.
for tgo in self.enemy_cp.ground_objects:
if not isinstance(tgo, VehicleGroupGroundObject):
continue
if meters(tgo.distance_to(self.enemy_cp)) < ControlPoint.CAPTURE_DISTANCE:
return False
return True
def opposing_garrisons_eliminated(self, state: TheaterState) -> bool:
garrisons = state.enemy_garrisons[self.enemy_cp]
return not bool(garrisons.blocking_capture)
def preconditions_met(self, state: TheaterState) -> bool:
if not super().preconditions_met(state):
return False
return self.opposing_garrisons_eliminated
return self.opposing_garrisons_eliminated(state)
def apply_effects(self, state: TheaterState) -> None:
super().apply_effects(state)