From ec6b543990d5580b0d343502c81c6eec231649e9 Mon Sep 17 00:00:00 2001 From: zhexu14 <64713351+zhexu14@users.noreply.github.com> Date: Wed, 6 Nov 2024 22:03:28 +1100 Subject: [PATCH] Stub new parameters in doctrines. These new parameters are not used at the moment but are intended for a future point release --- game/data/doctrine.py | 30 ++++++++++++++++++++++++++++-- resources/doctrines/coldwar.yaml | 5 ++++- resources/doctrines/modern.yaml | 4 ++++ resources/doctrines/ww2.yaml | 4 ++++ 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/game/data/doctrine.py b/game/data/doctrine.py index 91f5b81ad..ba063d12f 100644 --- a/game/data/doctrine.py +++ b/game/data/doctrine.py @@ -2,11 +2,11 @@ from pathlib import Path import yaml -from typing import Any, ClassVar +from typing import Any, ClassVar, Optional from dataclasses import dataclass from datetime import timedelta - +from dcs.task import OptAAMissileAttackRange from game.data.units import UnitClass from game.utils import Distance, feet, nautical_miles @@ -115,6 +115,28 @@ def from_dict(data: dict[str, Any]) -> Cap: ) +@dataclass(frozen=True) +class Tactics: + #: Aircraft use countermeasures (chaff, flares) + use_countermeasures: bool + + #: Air-to-air missile attack range options + air_to_air_missile_attack_range: Optional[OptAAMissileAttackRange.Values] + + #: Air defence units evade ARMs + air_defence_evades_anti_radiation_missiles: bool + + @staticmethod + def from_dict(data: dict[str, Any]) -> Tactics: + return Tactics( + use_countermeasures=data.get("use_countermeasures", True), + air_to_air_missile_attack_range=None, + air_defence_evades_anti_radiation_missiles=data.get( + "air_defence_evades_anti_radiation_missiles", False + ), + ) + + @dataclass(frozen=True) class Doctrine: #: Name of the doctrine, used to assign a doctrine in a faction. @@ -159,6 +181,9 @@ class Doctrine: #: Doctrine for Fighter Sweep missions. sweep: Sweep + #: Tactics options + tactics: Tactics + _by_name: ClassVar[dict[str, Doctrine]] = {} _loaded: ClassVar[bool] = False @@ -219,6 +244,7 @@ def load_all(cls) -> None: cas=Cas.from_dict(data["cas"]), cap=Cap.from_dict(data["cap"]), sweep=Sweep.from_dict(data["sweep"]), + tactics=Tactics.from_dict(data.get("tactics", {})), ) ) cls._loaded = True diff --git a/resources/doctrines/coldwar.yaml b/resources/doctrines/coldwar.yaml index 192d38fef..4f072a9e5 100644 --- a/resources/doctrines/coldwar.yaml +++ b/resources/doctrines/coldwar.yaml @@ -31,4 +31,7 @@ helicopter: combat_altitude_ft_agl: 200 rendezvous_altitude_ft_agl: 1500 air_assault_nav_altitude_ft_agl: 1500 - +tactics: + use_countermeasures: true + air_defence_evades_anti_radiation_missiles: false + air_to_air_missile_attack_range: ~ diff --git a/resources/doctrines/modern.yaml b/resources/doctrines/modern.yaml index 2e9137429..aca5233c0 100644 --- a/resources/doctrines/modern.yaml +++ b/resources/doctrines/modern.yaml @@ -31,3 +31,7 @@ helicopter: combat_altitude_ft_agl: 200 rendezvous_altitude_ft_agl: 1500 air_assault_nav_altitude_ft_agl: 1500 +tactics: + use_countermeasures: true + air_defence_evades_anti_radiation_missiles: false + air_to_air_missile_attack_range: ~ \ No newline at end of file diff --git a/resources/doctrines/ww2.yaml b/resources/doctrines/ww2.yaml index da0415919..de1450643 100644 --- a/resources/doctrines/ww2.yaml +++ b/resources/doctrines/ww2.yaml @@ -30,3 +30,7 @@ helicopter: combat_altitude_ft_agl: 200 rendezvous_altitude_ft_agl: 1500 air_assault_nav_altitude_ft_agl: 1500 +tactics: + use_countermeasures: true + air_defence_evades_anti_radiation_missiles: false + air_to_air_missile_attack_range: ~ \ No newline at end of file