mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Reuse Ghosti's NightMission conditions
This commit is contained in:
parent
e3fce5fddc
commit
71f6186a88
@ -14,7 +14,7 @@ from .minutesoption import minutes_option
|
|||||||
from .optiondescription import OptionDescription, SETTING_DESCRIPTION_KEY
|
from .optiondescription import OptionDescription, SETTING_DESCRIPTION_KEY
|
||||||
from .skilloption import skill_option
|
from .skilloption import skill_option
|
||||||
from ..ato.starttype import StartType
|
from ..ato.starttype import StartType
|
||||||
from ..weather import NightMissions
|
from ..weather.conditions import NightMissions
|
||||||
|
|
||||||
Views = ForcedOptions.Views
|
Views = ForcedOptions.Views
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import datetime
|
|||||||
import logging
|
import logging
|
||||||
import random
|
import random
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
from enum import Enum
|
||||||
|
|
||||||
from game.settings import Settings
|
from game.settings import Settings
|
||||||
from game.theater import ConflictTheater, DaytimeMap, SeasonalConditions
|
from game.theater import ConflictTheater, DaytimeMap, SeasonalConditions
|
||||||
@ -12,6 +13,12 @@ from game.timeofday import TimeOfDay
|
|||||||
from game.weather.weather import Weather, Thunderstorm, Raining, Cloudy, ClearSkies
|
from game.weather.weather import Weather, Thunderstorm, Raining, Cloudy, ClearSkies
|
||||||
|
|
||||||
|
|
||||||
|
class NightMissions(Enum):
|
||||||
|
DayAndNight = "nightmissions_nightandday"
|
||||||
|
OnlyDay = "nightmissions_onlyday"
|
||||||
|
OnlyNight = "nightmissions_onlynight"
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Conditions:
|
class Conditions:
|
||||||
time_of_day: TimeOfDay
|
time_of_day: TimeOfDay
|
||||||
@ -32,7 +39,7 @@ class Conditions:
|
|||||||
_start_time = datetime.datetime.combine(day, forced_time)
|
_start_time = datetime.datetime.combine(day, forced_time)
|
||||||
else:
|
else:
|
||||||
_start_time = cls.generate_start_time(
|
_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(
|
return cls(
|
||||||
@ -47,9 +54,11 @@ class Conditions:
|
|||||||
theater: ConflictTheater,
|
theater: ConflictTheater,
|
||||||
day: datetime.date,
|
day: datetime.date,
|
||||||
time_of_day: TimeOfDay,
|
time_of_day: TimeOfDay,
|
||||||
night_disabled: bool,
|
night_day_missions: NightMissions,
|
||||||
) -> datetime.datetime:
|
) -> datetime.datetime:
|
||||||
if night_disabled:
|
from game.theater import DaytimeMap
|
||||||
|
|
||||||
|
if night_day_missions == NightMissions.OnlyDay:
|
||||||
logging.info("Skip Night mission due to user settings")
|
logging.info("Skip Night mission due to user settings")
|
||||||
time_range = DaytimeMap(
|
time_range = DaytimeMap(
|
||||||
dawn=(datetime.time(hour=8), datetime.time(hour=9)),
|
dawn=(datetime.time(hour=8), datetime.time(hour=9)),
|
||||||
@ -57,6 +66,14 @@ class Conditions:
|
|||||||
dusk=(datetime.time(hour=12), datetime.time(hour=14)),
|
dusk=(datetime.time(hour=12), datetime.time(hour=14)),
|
||||||
night=(datetime.time(hour=14), datetime.time(hour=17)),
|
night=(datetime.time(hour=14), datetime.time(hour=17)),
|
||||||
).range_of(time_of_day)
|
).range_of(time_of_day)
|
||||||
|
elif night_day_missions == NightMissions.OnlyNight:
|
||||||
|
logging.info("Skip Day mission due to user settings")
|
||||||
|
time_range = DaytimeMap(
|
||||||
|
dawn=(datetime.time(hour=0), datetime.time(hour=3)),
|
||||||
|
day=(datetime.time(hour=3), datetime.time(hour=6)),
|
||||||
|
dusk=(datetime.time(hour=21), datetime.time(hour=22)),
|
||||||
|
night=(datetime.time(hour=22), datetime.time(hour=23)),
|
||||||
|
).range_of(time_of_day)
|
||||||
else:
|
else:
|
||||||
time_range = theater.daytime_map.range_of(time_of_day)
|
time_range = theater.daytime_map.range_of(time_of_day)
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import datetime
|
|||||||
import logging
|
import logging
|
||||||
import math
|
import math
|
||||||
import random
|
import random
|
||||||
from enum import Enum
|
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from typing import Optional, TYPE_CHECKING
|
from typing import Optional, TYPE_CHECKING
|
||||||
|
|
||||||
@ -27,12 +26,6 @@ if TYPE_CHECKING:
|
|||||||
from game.theater.seasonalconditions import SeasonalConditions
|
from game.theater.seasonalconditions import SeasonalConditions
|
||||||
|
|
||||||
|
|
||||||
class NightMissions(Enum):
|
|
||||||
DayAndNight = "nightmissions_nightandday"
|
|
||||||
OnlyDay = "nightmissions_onlyday"
|
|
||||||
OnlyNight = "nightmissions_onlynight"
|
|
||||||
|
|
||||||
|
|
||||||
class Weather(ABC):
|
class Weather(ABC):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user