mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
34 lines
971 B
Python
34 lines
971 B
Python
from __future__ import annotations
|
|
|
|
import random
|
|
from dataclasses import dataclass, field
|
|
from typing import Optional
|
|
|
|
from dcs.cloud_presets import Clouds as PydcsClouds
|
|
from dcs.weather import Weather as PydcsWeather, CloudPreset
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class Clouds:
|
|
base: int
|
|
density: int
|
|
thickness: int
|
|
precipitation: PydcsWeather.Preceptions
|
|
preset: Optional[CloudPreset] = field(default=None)
|
|
|
|
@classmethod
|
|
def random_preset(cls, rain: bool) -> Clouds:
|
|
clouds = (p.value for p in PydcsClouds)
|
|
if rain:
|
|
presets = [p for p in clouds if "Rain" in p.name]
|
|
else:
|
|
presets = [p for p in clouds if "Rain" not in p.name]
|
|
preset = random.choice(presets)
|
|
return Clouds(
|
|
base=random.randint(preset.min_base, preset.max_base),
|
|
density=0,
|
|
thickness=0,
|
|
precipitation=PydcsWeather.Preceptions.None_,
|
|
preset=preset,
|
|
)
|