From 49001bb558288c7908ac692a411b3f316b86dbbd Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Wed, 7 Sep 2022 16:39:47 -0700 Subject: [PATCH] Migrate Falklands to YAML. All theaters are now moddable. --- game/campaignloader/campaign.py | 12 +----- game/theater/conflicttheater.py | 30 ------------- .../seasonalconditions.py | 0 game/theater/seasonalconditions/__init__.py | 1 - game/theater/seasonalconditions/caucasus.py | 36 ---------------- resources/theaters/falklands/info.yaml | 42 +++++++++++++++++++ 6 files changed, 44 insertions(+), 77 deletions(-) rename game/theater/{seasonalconditions => }/seasonalconditions.py (100%) delete mode 100644 game/theater/seasonalconditions/__init__.py delete mode 100644 game/theater/seasonalconditions/caucasus.py create mode 100644 resources/theaters/falklands/info.yaml diff --git a/game/campaignloader/campaign.py b/game/campaignloader/campaign.py index e11b819a..6b2dc749 100644 --- a/game/campaignloader/campaign.py +++ b/game/campaignloader/campaign.py @@ -5,7 +5,7 @@ import logging from collections.abc import Iterator from dataclasses import dataclass from pathlib import Path -from typing import Any, Dict, Tuple, Type +from typing import Any, Dict, Tuple import yaml from packaging.version import Version @@ -14,7 +14,6 @@ from game import persistency from game.profiling import logged_duration from game.theater import ( ConflictTheater, - FalklandsTheater, ) from game.theater.iadsnetwork.iadsnetwork import IadsNetwork from game.theater.theaterloader import TheaterLoader @@ -109,14 +108,7 @@ class Campaign: ) def load_theater(self, advanced_iads: bool) -> ConflictTheater: - theaters: dict[str, Type[ConflictTheater]] = { - "Falklands": FalklandsTheater, - } - try: - theater = theaters[self.data["theater"]] - t = theater() - except KeyError: - t = TheaterLoader(self.data["theater"].lower()).load() + t = TheaterLoader(self.data["theater"].lower()).load() try: miz = self.data["miz"] diff --git a/game/theater/conflicttheater.py b/game/theater/conflicttheater.py index 63a1e9a2..4f929a2e 100644 --- a/game/theater/conflicttheater.py +++ b/game/theater/conflicttheater.py @@ -6,9 +6,6 @@ from typing import Iterator, List, Optional, TYPE_CHECKING, Tuple from uuid import UUID from dcs.mapping import Point -from dcs.terrain import ( - falklands, -) from dcs.terrain.terrain import Terrain from shapely import geometry, ops @@ -237,30 +234,3 @@ class ConflictTheater: ) return Heading.from_degrees(position.heading_between_point(conflict_center)) - - -class FalklandsTheater(ConflictTheater): - terrain = falklands.Falklands() - - # TODO: https://github.com/dcs-liberation/dcs_liberation/issues/2242 - landmap = None - - # TODO: https://github.com/dcs-liberation/dcs_liberation/issues/2242 - daytime_map = DaytimeMap( - dawn=(datetime.time(hour=6), datetime.time(hour=9)), - day=(datetime.time(hour=9), datetime.time(hour=18)), - dusk=(datetime.time(hour=18), datetime.time(hour=20)), - night=(datetime.time(hour=0), datetime.time(hour=5)), - ) - - # TODO: https://github.com/dcs-liberation/dcs_liberation/issues/2242 - @property - def timezone(self) -> datetime.timezone: - return datetime.timezone(datetime.timedelta(hours=4)) - - # TODO: https://github.com/dcs-liberation/dcs_liberation/issues/2242 - @property - def seasonal_conditions(self) -> SeasonalConditions: - from .seasonalconditions.caucasus import CONDITIONS - - return CONDITIONS diff --git a/game/theater/seasonalconditions/seasonalconditions.py b/game/theater/seasonalconditions.py similarity index 100% rename from game/theater/seasonalconditions/seasonalconditions.py rename to game/theater/seasonalconditions.py diff --git a/game/theater/seasonalconditions/__init__.py b/game/theater/seasonalconditions/__init__.py deleted file mode 100644 index 713a85f5..00000000 --- a/game/theater/seasonalconditions/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .seasonalconditions import * diff --git a/game/theater/seasonalconditions/caucasus.py b/game/theater/seasonalconditions/caucasus.py deleted file mode 100644 index 2fe87861..00000000 --- a/game/theater/seasonalconditions/caucasus.py +++ /dev/null @@ -1,36 +0,0 @@ -from .seasonalconditions import SeasonalConditions, Season, WeatherTypeChances - -CONDITIONS = SeasonalConditions( - summer_avg_pressure=30.02, # TODO: Find real-world data - winter_avg_pressure=29.72, # TODO: Find real-world data - summer_avg_temperature=22.5, - winter_avg_temperature=3.0, - temperature_day_night_difference=6.0, - weather_type_chances={ - # TODO: Find real-world data for all these values - Season.Winter: WeatherTypeChances( - thunderstorm=1, - raining=20, - cloudy=60, - clear_skies=20, - ), - Season.Spring: WeatherTypeChances( - thunderstorm=1, - raining=20, - cloudy=40, - clear_skies=40, - ), - Season.Summer: WeatherTypeChances( - thunderstorm=1, - raining=10, - cloudy=35, - clear_skies=55, - ), - Season.Fall: WeatherTypeChances( - thunderstorm=1, - raining=30, - cloudy=50, - clear_skies=20, - ), - }, -) diff --git a/resources/theaters/falklands/info.yaml b/resources/theaters/falklands/info.yaml new file mode 100644 index 00000000..393140ad --- /dev/null +++ b/resources/theaters/falklands/info.yaml @@ -0,0 +1,42 @@ +--- +name: Falklands +# TODO: https://github.com/dcs-liberation/dcs_liberation/issues/2242 +timezone: +4 +# TODO: https://github.com/dcs-liberation/dcs_liberation/issues/2242 +daytime: + dawn: [6, 9] + day: [9, 18] + dusk: [18, 20] + night: [0, 5] +# TODO: https://github.com/dcs-liberation/dcs_liberation/issues/2242 +climate: + day_night_temperature_difference: 6.0 + seasons: + winter: + average_pressure: 29.72 # TODO: Find real-world data + average_temperature: 3.0 + weather: + thunderstorm: 1 + raining: 20 + cloudy: 60 + clear: 20 + spring: + weather: + thunderstorm: 1 + raining: 20 + cloudy: 40 + clear: 40 + summer: + average_pressure: 30.02 # TODO: Find real-world data + average_temperature: 22.5 + weather: + thunderstorm: 1 + raining: 10 + cloudy: 35 + clear: 55 + fall: + weather: + thunderstorm: 1 + raining: 30 + cloudy: 50 + clear: 20