Remove junk from FrontLineConflictDescription.

This commit is contained in:
Dan Albert 2022-09-11 14:39:10 -07:00 committed by Raffson
parent 16fdb889a7
commit 9eb2b6e006
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
3 changed files with 8 additions and 51 deletions

View File

@ -206,10 +206,6 @@ class FlotGenerator:
if not infantry_position:
logging.warning("Could not find infantry position")
return
if side == self.conflict.attackers_country:
cp = self.conflict.blue_cp
else:
cp = self.conflict.red_cp
faction = self.game.faction_for(is_player)
@ -739,6 +735,7 @@ class FlotGenerator:
if final_position is not None:
g = self._generate_group(
is_player,
self.mission.country(country),
group.unit_type,
group.size,
@ -765,19 +762,14 @@ class FlotGenerator:
def _generate_group(
self,
player: bool,
side: Country,
unit_type: GroundUnitType,
count: int,
at: Point,
move_formation: PointAction = PointAction.OffRoad,
heading: Heading = Heading.from_degrees(0),
heading: Heading,
) -> VehicleGroup:
if side == self.conflict.attackers_country:
cp = self.conflict.blue_cp
else:
cp = self.conflict.red_cp
cp = self.conflict.front_line.control_point_friendly_to(player)
group = self.mission.vehicle_group(
side,
namegen.next_unit_name(side, unit_type),
@ -785,7 +777,6 @@ class FlotGenerator:
position=at,
group_size=count,
heading=heading.degrees,
move_formation=move_formation,
)
self.unit_map.add_front_line_units(group, cp, unit_type)

View File

@ -4,7 +4,6 @@ import logging
from dataclasses import dataclass
from typing import Optional, Tuple
from dcs.country import Country
from dcs.mapping import Point
from shapely.geometry import LineString, Point as ShapelyPoint
@ -13,8 +12,6 @@ from game.theater.conflicttheater import ConflictTheater, FrontLine
from game.theater.controlpoint import ControlPoint
from game.utils import Heading
FRONTLINE_LENGTH = 80000
@dataclass(frozen=True)
class FrontLineBounds:
@ -28,19 +25,10 @@ class FrontLineConflictDescription:
self,
theater: ConflictTheater,
front_line: FrontLine,
attackers_side: str,
defenders_side: str,
attackers_country: Country,
defenders_country: Country,
position: Point,
heading: Optional[Heading] = None,
size: Optional[int] = None,
):
self.attackers_side = attackers_side
self.defenders_side = defenders_side
self.attackers_country = attackers_country
self.defenders_country = defenders_country
self.front_line = front_line
self.theater = theater
self.position = position
@ -55,10 +43,6 @@ class FrontLineConflictDescription:
def red_cp(self) -> ControlPoint:
return self.front_line.red_cp
@classmethod
def has_frontline_between(cls, from_cp: ControlPoint, to_cp: ControlPoint) -> bool:
return from_cp.has_frontline and to_cp.has_frontline
@classmethod
def frontline_position(
cls, frontline: FrontLine, theater: ConflictTheater, settings: Settings
@ -101,29 +85,17 @@ class FrontLineConflictDescription:
@classmethod
def frontline_cas_conflict(
cls,
attacker_name: str,
defender_name: str,
attacker: Country,
defender: Country,
front_line: FrontLine,
theater: ConflictTheater,
settings: Settings,
cls, front_line: FrontLine, theater: ConflictTheater, settings: Settings
) -> FrontLineConflictDescription:
assert cls.has_frontline_between(front_line.blue_cp, front_line.red_cp)
# TODO: Break apart the front-line and air conflict descriptions.
# We're wastefully not caching the front-line bounds here because air conflicts
# can't compute bounds, only a position.
bounds = cls.frontline_bounds(front_line, theater, settings)
conflict = cls(
position=bounds.left_position,
heading=bounds.heading_from_left_to_right,
theater=theater,
front_line=front_line,
attackers_side=attacker_name,
defenders_side=defender_name,
attackers_country=attacker,
defenders_country=defender,
position=bounds.left_position,
heading=bounds.heading_from_left_to_right,
size=bounds.length,
)
return conflict

View File

@ -196,13 +196,7 @@ class MissionGenerator:
player_cp = front_line.blue_cp
enemy_cp = front_line.red_cp
conflict = FrontLineConflictDescription.frontline_cas_conflict(
self.game.blue.faction.name,
self.game.red.faction.name,
self.mission.country(self.game.blue.country_name),
self.mission.country(self.game.red.country_name),
front_line,
self.game.theater,
self.game.settings,
front_line, self.game.theater, self.game.settings
)
# Generate frontline ops
player_gp = self.game.ground_planners[player_cp.id].units_per_cp[