Revert "Remove front line minimum distance."

This reverts commit dbe9691d
This commit is contained in:
RndName
2022-01-07 09:59:14 +01:00
parent 8aca036bf0
commit 7bb41d07b3
2 changed files with 21 additions and 4 deletions

View File

@@ -14,6 +14,9 @@ from .controlpoint import (
from ..utils import Heading, pairwise
FRONTLINE_MIN_CP_DISTANCE = 5000
@dataclass
class FrontLineSegment:
"""
@@ -169,8 +172,23 @@ class FrontLine(MissionTarget):
"""
total_strength = self.blue_cp.base.strength + self.red_cp.base.strength
if self.blue_cp.base.strength == 0:
return 0
return self._adjust_for_min_dist(0)
if self.red_cp.base.strength == 0:
return self.attack_distance
return self._adjust_for_min_dist(self.attack_distance)
strength_pct = self.blue_cp.base.strength / total_strength
return strength_pct * self.attack_distance
return self._adjust_for_min_dist(strength_pct * self.attack_distance)
def _adjust_for_min_dist(self, distance: float) -> float:
"""
Ensures the frontline conflict is never located within the minimum distance
constant of either end control point.
"""
if (distance > self.attack_distance / 2) and (
distance + FRONTLINE_MIN_CP_DISTANCE > self.attack_distance
):
distance = self.attack_distance - FRONTLINE_MIN_CP_DISTANCE
elif (distance < self.attack_distance / 2) and (
distance < FRONTLINE_MIN_CP_DISTANCE
):
distance = FRONTLINE_MIN_CP_DISTANCE
return distance