dcs-retribution/game/settings/boundedfloatoption.py
Dan Albert 6dae5b98d5 Fix carrier option not taking effect this turn.
This really shouldn't need to happen but I don't feel like rewriting the
culling code right now. There's no reason for these to be persisted to
the Game at all, we should be generating these once they're needed.
2021-10-21 20:05:07 -07:00

43 lines
934 B
Python

from dataclasses import dataclass, field
from typing import Any, Optional
from .optiondescription import OptionDescription, SETTING_DESCRIPTION_KEY
@dataclass(frozen=True)
class BoundedFloatOption(OptionDescription):
min: float
max: float
divisor: int
def bounded_float_option(
text: str,
page: str,
section: str,
default: float,
min: float,
max: float,
divisor: int,
detail: Optional[str] = None,
tooltip: Optional[str] = None,
**kwargs: Any,
) -> float:
return field(
metadata={
SETTING_DESCRIPTION_KEY: BoundedFloatOption(
page,
section,
text,
detail,
tooltip,
causes_expensive_game_update=False,
min=min,
max=max,
divisor=divisor,
)
},
default=default,
**kwargs,
)