From 5fb6a53cbdcc675feeb2a2c7b1e4f755f2ac2fd0 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Thu, 19 Nov 2020 21:28:57 -0800 Subject: [PATCH] Add preset configuration for offshore types. --- game/theater/conflicttheater.py | 29 ++++++++++++++++++++++++++++- game/theater/controlpoint.py | 7 ++++--- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/game/theater/conflicttheater.py b/game/theater/conflicttheater.py index b0f2c1fb..8ad73838 100644 --- a/game/theater/conflicttheater.py +++ b/game/theater/conflicttheater.py @@ -16,7 +16,11 @@ from dcs.countries import ( ) from dcs.country import Country from dcs.mapping import Point -from dcs.ships import CVN_74_John_C__Stennis, LHA_1_Tarawa +from dcs.ships import ( + CVN_74_John_C__Stennis, + LHA_1_Tarawa, + USS_Arleigh_Burke_IIa, +) from dcs.statics import Fortification from dcs.terrain import ( caucasus, @@ -98,6 +102,8 @@ class MizCampaignLoader: SAM_UNIT_TYPE = AirDefence.SAM_SA_10_S_300PS_SR_64H6E.id GARRISON_UNIT_TYPE = AirDefence.SAM_SA_19_Tunguska_2S6.id STRIKE_TARGET_UNIT_TYPE = Fortification.Workshop_A.id + OFFSHORE_STRIKE_TARGET_UNIT_TYPE = Fortification.Oil_platform.id + SHIP_UNIT_TYPE = USS_Arleigh_Burke_IIa.id BASE_DEFENSE_RADIUS = nm_to_meter(2) @@ -165,6 +171,12 @@ class MizCampaignLoader: if group.units[0].type == self.LHA_UNIT_TYPE: yield group + @property + def ships(self) -> Iterator[ShipGroup]: + for group in self.blue.ship_group: + if group.units[0].type == self.SHIP_UNIT_TYPE: + yield group + @property def ewrs(self) -> Iterator[VehicleGroup]: for group in self.blue.vehicle_group: @@ -189,6 +201,12 @@ class MizCampaignLoader: if group.units[0].type == self.STRIKE_TARGET_UNIT_TYPE: yield group + @property + def offshore_strike_targets(self) -> Iterator[StaticGroup]: + for group in self.blue.static_group: + if group.units[0].type == self.OFFSHORE_STRIKE_TARGET_UNIT_TYPE: + yield group + @cached_property def control_points(self) -> Dict[int, ControlPoint]: control_points = {} @@ -279,6 +297,15 @@ class MizCampaignLoader: closest, distance = self.objective_info(group) closest.preset_locations.strike_locations.append(group.position) + for group in self.offshore_strike_targets: + closest, distance = self.objective_info(group) + closest.preset_locations.offshore_strike_locations.append( + group.position) + + for group in self.ships: + closest, distance = self.objective_info(group) + closest.preset_locations.ships.append(group.position) + def populate_theater(self) -> None: for control_point in self.control_points.values(): self.theater.add_controlpoint(control_point) diff --git a/game/theater/controlpoint.py b/game/theater/controlpoint.py index f9ff79d8..b32ff97f 100644 --- a/game/theater/controlpoint.py +++ b/game/theater/controlpoint.py @@ -59,9 +59,10 @@ class PresetLocations: ewrs: List[Point] = field(default_factory=list) sams: List[Point] = field(default_factory=list) - offshore: List[Point] = field(default_factory=list) + ships: List[Point] = field(default_factory=list) coastal_defenses: List[Point] = field(default_factory=list) strike_locations: List[Point] = field(default_factory=list) + offshore_strike_locations: List[Point] = field(default_factory=list) fixed_sams: List[Point] = field(default_factory=list) @@ -85,9 +86,9 @@ class PresetLocations: if location_type == LocationType.Shorad: return self._random_from(self.base_garrisons) if location_type == LocationType.OffshoreStrikeTarget: - return self._random_from(self.offshore) + return self._random_from(self.offshore_strike_locations) if location_type == LocationType.Ship: - return self._random_from(self.offshore) + return self._random_from(self.ships) if location_type == LocationType.StrikeTarget: return self._random_from(self.strike_locations) logging.error(f"Unknown location type: {location_type}")