Skip to content

Commit

Permalink
Refactor use_countermeasures to faction (#3459)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhexu14 authored Nov 11, 2024
1 parent fa41b00 commit e47e95f
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 deletions.
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: ~

0 comments on commit e47e95f

Please sign in to comment.