mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Remove junk from FrontLineConflictDescription.
This commit is contained in:
parent
16fdb889a7
commit
9eb2b6e006
@ -206,10 +206,6 @@ class FlotGenerator:
|
|||||||
if not infantry_position:
|
if not infantry_position:
|
||||||
logging.warning("Could not find infantry position")
|
logging.warning("Could not find infantry position")
|
||||||
return
|
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)
|
faction = self.game.faction_for(is_player)
|
||||||
|
|
||||||
@ -739,6 +735,7 @@ class FlotGenerator:
|
|||||||
|
|
||||||
if final_position is not None:
|
if final_position is not None:
|
||||||
g = self._generate_group(
|
g = self._generate_group(
|
||||||
|
is_player,
|
||||||
self.mission.country(country),
|
self.mission.country(country),
|
||||||
group.unit_type,
|
group.unit_type,
|
||||||
group.size,
|
group.size,
|
||||||
@ -765,19 +762,14 @@ class FlotGenerator:
|
|||||||
|
|
||||||
def _generate_group(
|
def _generate_group(
|
||||||
self,
|
self,
|
||||||
|
player: bool,
|
||||||
side: Country,
|
side: Country,
|
||||||
unit_type: GroundUnitType,
|
unit_type: GroundUnitType,
|
||||||
count: int,
|
count: int,
|
||||||
at: Point,
|
at: Point,
|
||||||
move_formation: PointAction = PointAction.OffRoad,
|
heading: Heading,
|
||||||
heading: Heading = Heading.from_degrees(0),
|
|
||||||
) -> VehicleGroup:
|
) -> VehicleGroup:
|
||||||
|
cp = self.conflict.front_line.control_point_friendly_to(player)
|
||||||
if side == self.conflict.attackers_country:
|
|
||||||
cp = self.conflict.blue_cp
|
|
||||||
else:
|
|
||||||
cp = self.conflict.red_cp
|
|
||||||
|
|
||||||
group = self.mission.vehicle_group(
|
group = self.mission.vehicle_group(
|
||||||
side,
|
side,
|
||||||
namegen.next_unit_name(side, unit_type),
|
namegen.next_unit_name(side, unit_type),
|
||||||
@ -785,7 +777,6 @@ class FlotGenerator:
|
|||||||
position=at,
|
position=at,
|
||||||
group_size=count,
|
group_size=count,
|
||||||
heading=heading.degrees,
|
heading=heading.degrees,
|
||||||
move_formation=move_formation,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
self.unit_map.add_front_line_units(group, cp, unit_type)
|
self.unit_map.add_front_line_units(group, cp, unit_type)
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import logging
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Optional, Tuple
|
from typing import Optional, Tuple
|
||||||
|
|
||||||
from dcs.country import Country
|
|
||||||
from dcs.mapping import Point
|
from dcs.mapping import Point
|
||||||
from shapely.geometry import LineString, Point as ShapelyPoint
|
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.theater.controlpoint import ControlPoint
|
||||||
from game.utils import Heading
|
from game.utils import Heading
|
||||||
|
|
||||||
FRONTLINE_LENGTH = 80000
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class FrontLineBounds:
|
class FrontLineBounds:
|
||||||
@ -28,19 +25,10 @@ class FrontLineConflictDescription:
|
|||||||
self,
|
self,
|
||||||
theater: ConflictTheater,
|
theater: ConflictTheater,
|
||||||
front_line: FrontLine,
|
front_line: FrontLine,
|
||||||
attackers_side: str,
|
|
||||||
defenders_side: str,
|
|
||||||
attackers_country: Country,
|
|
||||||
defenders_country: Country,
|
|
||||||
position: Point,
|
position: Point,
|
||||||
heading: Optional[Heading] = None,
|
heading: Optional[Heading] = None,
|
||||||
size: Optional[int] = 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.front_line = front_line
|
||||||
self.theater = theater
|
self.theater = theater
|
||||||
self.position = position
|
self.position = position
|
||||||
@ -55,10 +43,6 @@ class FrontLineConflictDescription:
|
|||||||
def red_cp(self) -> ControlPoint:
|
def red_cp(self) -> ControlPoint:
|
||||||
return self.front_line.red_cp
|
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
|
@classmethod
|
||||||
def frontline_position(
|
def frontline_position(
|
||||||
cls, frontline: FrontLine, theater: ConflictTheater, settings: Settings
|
cls, frontline: FrontLine, theater: ConflictTheater, settings: Settings
|
||||||
@ -101,29 +85,17 @@ class FrontLineConflictDescription:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def frontline_cas_conflict(
|
def frontline_cas_conflict(
|
||||||
cls,
|
cls, front_line: FrontLine, theater: ConflictTheater, settings: Settings
|
||||||
attacker_name: str,
|
|
||||||
defender_name: str,
|
|
||||||
attacker: Country,
|
|
||||||
defender: Country,
|
|
||||||
front_line: FrontLine,
|
|
||||||
theater: ConflictTheater,
|
|
||||||
settings: Settings,
|
|
||||||
) -> FrontLineConflictDescription:
|
) -> FrontLineConflictDescription:
|
||||||
assert cls.has_frontline_between(front_line.blue_cp, front_line.red_cp)
|
|
||||||
# TODO: Break apart the front-line and air conflict descriptions.
|
# TODO: Break apart the front-line and air conflict descriptions.
|
||||||
# We're wastefully not caching the front-line bounds here because air conflicts
|
# We're wastefully not caching the front-line bounds here because air conflicts
|
||||||
# can't compute bounds, only a position.
|
# can't compute bounds, only a position.
|
||||||
bounds = cls.frontline_bounds(front_line, theater, settings)
|
bounds = cls.frontline_bounds(front_line, theater, settings)
|
||||||
conflict = cls(
|
conflict = cls(
|
||||||
position=bounds.left_position,
|
|
||||||
heading=bounds.heading_from_left_to_right,
|
|
||||||
theater=theater,
|
theater=theater,
|
||||||
front_line=front_line,
|
front_line=front_line,
|
||||||
attackers_side=attacker_name,
|
position=bounds.left_position,
|
||||||
defenders_side=defender_name,
|
heading=bounds.heading_from_left_to_right,
|
||||||
attackers_country=attacker,
|
|
||||||
defenders_country=defender,
|
|
||||||
size=bounds.length,
|
size=bounds.length,
|
||||||
)
|
)
|
||||||
return conflict
|
return conflict
|
||||||
|
|||||||
@ -196,13 +196,7 @@ class MissionGenerator:
|
|||||||
player_cp = front_line.blue_cp
|
player_cp = front_line.blue_cp
|
||||||
enemy_cp = front_line.red_cp
|
enemy_cp = front_line.red_cp
|
||||||
conflict = FrontLineConflictDescription.frontline_cas_conflict(
|
conflict = FrontLineConflictDescription.frontline_cas_conflict(
|
||||||
self.game.blue.faction.name,
|
front_line, self.game.theater, self.game.settings
|
||||||
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,
|
|
||||||
)
|
)
|
||||||
# Generate frontline ops
|
# Generate frontline ops
|
||||||
player_gp = self.game.ground_planners[player_cp.id].units_per_cp[
|
player_gp = self.game.ground_planners[player_cp.id].units_per_cp[
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user