From d2eb98bcc5b51a39d75f62436d8a6637050c47e5 Mon Sep 17 00:00:00 2001 From: MetalStormGhost Date: Wed, 24 Nov 2021 00:12:18 +0200 Subject: [PATCH] Added option for only night missions. - Moved the night mission setting back from the Mission restrictions section to the Mission difficulty section. - Changed the Night/day mission option into a dropdown menu. Resolves #1786 --- changelog.md | 1 + game/settings/settings.py | 17 ++++++++++++++--- game/weather.py | 19 +++++++++++++++---- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/changelog.md b/changelog.md index 4bdc94bb..f2e4807e 100644 --- a/changelog.md +++ b/changelog.md @@ -7,6 +7,7 @@ Saves from 5.0.0 are compatible with 5.1.0 * **[Engine]** Support for DCS 2.7.9.17830 and newer, including the HTS and ECM pod. * **[Campaign]** Add option to manually add and remove squadrons and different aircraft type in the new game wizard / air wing configuration dialog. * **[Mission Generation]** Add Option to enforce the Easy Communication setting for the mission +* **[Mission Generation]** Add Option to select between only night missions, day missions or any time (default). * **[Modding]** Add F-104 mod support ## Fixes diff --git a/game/settings/settings.py b/game/settings/settings.py index 1070fc06..44cb3ab8 100644 --- a/game/settings/settings.py +++ b/game/settings/settings.py @@ -23,6 +23,12 @@ class AutoAtoBehavior(Enum): Prefer = "Prefer player pilots" +class NightMissions(Enum): + DayAndNight = "nightmissions_nightandday" + OnlyDay = "nightmissions_onlyday" + OnlyNight = "nightmissions_onlynight" + + DIFFICULTY_PAGE = "Difficulty" AI_DIFFICULTY_SECTION = "AI Difficulty" @@ -104,11 +110,16 @@ class Settings: section=MISSION_DIFFICULTY_SECTION, default=True, ) - night_disabled: bool = boolean_option( - "No night missions", + night_day_missions: NightMissions = choices_option( + "Night/day mission options", page=DIFFICULTY_PAGE, section=MISSION_DIFFICULTY_SECTION, - default=False, + choices={ + "Generate night and day missions": NightMissions.DayAndNight, + "Only generate day missions": NightMissions.OnlyDay, + "Only generate night missions": NightMissions.OnlyNight, + }, + default=NightMissions.DayAndNight, ) # Mission Restrictions labels: str = choices_option( diff --git a/game/weather.py b/game/weather.py index 47287184..eb35e27e 100644 --- a/game/weather.py +++ b/game/weather.py @@ -10,7 +10,7 @@ from typing import Optional, TYPE_CHECKING, Any from dcs.cloud_presets import Clouds as PydcsClouds from dcs.weather import CloudPreset, Weather as PydcsWeather, Wind -from game.settings import Settings +from game.settings.settings import Settings, NightMissions from game.utils import Distance, Heading, meters, interpolate, Pressure, inches_hg from game.theater.seasonalconditions import determine_season @@ -301,7 +301,10 @@ class Conditions: settings: Settings, ) -> Conditions: _start_time = cls.generate_start_time( - theater, day, time_of_day, settings.night_disabled + theater, + day, + time_of_day, + settings.night_day_missions, ) return cls( time_of_day=time_of_day, @@ -315,9 +318,9 @@ class Conditions: theater: ConflictTheater, day: datetime.date, time_of_day: TimeOfDay, - night_disabled: bool, + night_day_missions: NightMissions, ) -> datetime.datetime: - if night_disabled: + if night_day_missions == NightMissions.OnlyDay: logging.info("Skip Night mission due to user settings") time_range = { TimeOfDay.Dawn: (8, 9), @@ -325,6 +328,14 @@ class Conditions: TimeOfDay.Dusk: (12, 14), TimeOfDay.Night: (14, 17), }[time_of_day] + elif night_day_missions == NightMissions.OnlyNight: + logging.info("Skip Day mission due to user settings") + time_range = { + TimeOfDay.Dawn: (0, 3), + TimeOfDay.Day: (3, 6), + TimeOfDay.Dusk: (21, 22), + TimeOfDay.Night: (22, 23), + }[time_of_day] else: time_range = theater.daytime_map[time_of_day.value]