diff --git a/game/campaignloader/campaign.py b/game/campaignloader/campaign.py index 6b2dc749..7f87bf1e 100644 --- a/game/campaignloader/campaign.py +++ b/game/campaignloader/campaign.py @@ -120,6 +120,8 @@ class Campaign: with logged_duration("Importing miz data"): MizCampaignLoader(self.path.parent / miz, t).populate_theater() + # TODO: Move into MizCampaignLoader so this doesn't have unknown initialization + # in ConflictTheater. # Load IADS Config from campaign yaml iads_data = self.data.get("iads_config", []) t.iads_network = IadsNetwork(advanced_iads, iads_data) diff --git a/game/theater/conflicttheater.py b/game/theater/conflicttheater.py index 4f929a2e..7575daed 100644 --- a/game/theater/conflicttheater.py +++ b/game/theater/conflicttheater.py @@ -1,7 +1,7 @@ from __future__ import annotations -import datetime import math +from datetime import timezone from typing import Iterator, List, Optional, TYPE_CHECKING, Tuple from uuid import UUID @@ -22,14 +22,22 @@ if TYPE_CHECKING: class ConflictTheater: - terrain: Terrain - - landmap: Optional[Landmap] - daytime_map: DaytimeMap iads_network: IadsNetwork - def __init__(self) -> None: - self.controlpoints: List[ControlPoint] = [] + def __init__( + self, + terrain: Terrain, + landmap: Landmap | None, + time_zone: timezone, + seasonal_conditions: SeasonalConditions, + daytime_map: DaytimeMap, + ) -> None: + self.terrain = terrain + self.landmap = landmap + self.timezone = time_zone + self.seasonal_conditions = seasonal_conditions + self.daytime_map = daytime_map + self.controlpoints: list[ControlPoint] = [] def add_controlpoint(self, point: ControlPoint) -> None: self.controlpoints.append(point) @@ -205,14 +213,6 @@ class ConflictTheater: return cp raise KeyError(f"Cannot find ControlPoint named {name}") - @property - def timezone(self) -> datetime.timezone: - raise NotImplementedError - - @property - def seasonal_conditions(self) -> SeasonalConditions: - raise NotImplementedError - def heading_to_conflict_from(self, position: Point) -> Optional[Heading]: # Heading for a Group to the enemy. # Should be the point between the nearest and the most distant conflict diff --git a/game/theater/theaterloader.py b/game/theater/theaterloader.py index 0df987d5..c86d48ec 100644 --- a/game/theater/theaterloader.py +++ b/game/theater/theaterloader.py @@ -21,7 +21,6 @@ from .conflicttheater import ConflictTheater from .daytimemap import DaytimeMap from .landmap import load_landmap from .seasonalconditions import Season, SeasonalConditions, WeatherTypeChances -from .yamltheater import YamlTheater ALL_TERRAINS = [ Caucasus(), @@ -65,7 +64,7 @@ class TheaterLoader: def load(self) -> ConflictTheater: with self.descriptor_path.open() as descriptor_file: data = yaml.safe_load(descriptor_file) - return YamlTheater( + return ConflictTheater( TERRAINS_BY_NAME[data.get("pydcs_name", data["name"])], load_landmap(self.descriptor_path.with_name("landmap.p")), datetime.timezone(datetime.timedelta(hours=data["timezone"])), diff --git a/game/theater/yamltheater.py b/game/theater/yamltheater.py deleted file mode 100644 index 9a9b7d53..00000000 --- a/game/theater/yamltheater.py +++ /dev/null @@ -1,35 +0,0 @@ -from __future__ import annotations - -from datetime import timezone - -from dcs.terrain import Terrain - -from .conflicttheater import ConflictTheater -from .daytimemap import DaytimeMap -from .landmap import Landmap -from .seasonalconditions import SeasonalConditions - - -class YamlTheater(ConflictTheater): - def __init__( - self, - terrain: Terrain, - landmap: Landmap | None, - time_zone: timezone, - seasonal_conditions: SeasonalConditions, - daytime_map: DaytimeMap, - ) -> None: - super().__init__() - self.terrain = terrain - self.landmap = landmap - self._timezone = time_zone - self._seasonal_conditions = seasonal_conditions - self.daytime_map = daytime_map - - @property - def timezone(self) -> timezone: - return self._timezone - - @property - def seasonal_conditions(self) -> SeasonalConditions: - return self._seasonal_conditions