mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Issue 3204 (#3458)
This issue addresses Issue #3204 by allowing factions to set a different weapon introduction date.
This commit is contained in:
@@ -14,6 +14,8 @@ from dcs.flyingunit import FlyingUnit
|
||||
from dcs.weapons_data import weapon_ids
|
||||
|
||||
from game.dcs.aircrafttype import AircraftType
|
||||
from game.factions.faction import Faction
|
||||
|
||||
|
||||
PydcsWeapon = Any
|
||||
PydcsWeaponAssignment = tuple[int, PydcsWeapon]
|
||||
@@ -77,8 +79,12 @@ class Weapon:
|
||||
WeaponGroup.load_all()
|
||||
cls._loaded = True
|
||||
|
||||
def available_on(self, date: datetime.date) -> bool:
|
||||
def available_on(self, date: datetime.date, faction: Faction) -> bool:
|
||||
introduction_year = self.weapon_group.introduction_year
|
||||
if self.weapon_group.name in faction.weapons_introduction_year_overrides:
|
||||
introduction_year = faction.weapons_introduction_year_overrides[
|
||||
self.weapon_group.name
|
||||
]
|
||||
if introduction_year is None:
|
||||
return True
|
||||
return date >= datetime.date(introduction_year, 1, 1)
|
||||
@@ -243,9 +249,9 @@ class Pylon:
|
||||
def make_pydcs_assignment(self, weapon: Weapon) -> PydcsWeaponAssignment:
|
||||
return self.number, weapon.pydcs_data
|
||||
|
||||
def available_on(self, date: datetime.date) -> Iterator[Weapon]:
|
||||
def available_on(self, date: datetime.date, faction: Faction) -> Iterator[Weapon]:
|
||||
for weapon in self.allowed:
|
||||
if weapon.available_on(date):
|
||||
if weapon.available_on(date, faction):
|
||||
yield weapon
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user