mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Clean up ConflictTheater constructor.
Now that all theaters are defined in YAML, we can lose some of the mess in this class.
This commit is contained in:
parent
d060f39e2f
commit
87375eb4b1
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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"])),
|
||||
|
||||
@ -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
|
||||
Loading…
x
Reference in New Issue
Block a user