Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor use_countermeasures to faction #3459

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions game/data/doctrine.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ 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]
Expand All @@ -129,7 +127,6 @@ class Tactics:
@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
Expand Down
5 changes: 5 additions & 0 deletions game/factions/faction.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ class Faction:
#: weapons groups to their introduction years.
weapons_introduction_year_overrides: Dict[str, int] = field(default_factory=dict)

#: Set to True if the faction has access to countermeasures (chaff and flares).
countermeasures_available: bool = True

def has_access_to_dcs_type(self, unit_type: Type[DcsUnitType]) -> bool:
# Vehicle and Ship Units
if any(unit_type == u.dcs_unit_type for u in self.accessible_units):
Expand Down Expand Up @@ -271,6 +274,8 @@ def from_dict(cls: Type[Faction], json: Dict[str, Any]) -> Faction:
"weapons_introduction_year_overrides", {}
)

faction.countermeasures_available = json.get("countermeasures_available", True)

return faction

@property
Expand Down
1 change: 0 additions & 1 deletion resources/doctrines/coldwar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,5 @@ helicopter:
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: ~
1 change: 0 additions & 1 deletion resources/doctrines/modern.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,5 @@ helicopter:
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: ~
1 change: 0 additions & 1 deletion resources/doctrines/ww2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@ helicopter:
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: ~
Loading