Merge faction sams and shorads into air_defenses.

Fixes https://github.com/Khopa/dcs_liberation/issues/473. Air defenses
for bases, strike locations, and fixed IADS will now all downgrade to
lower tier systems as needed. Strike locations will still be spawned as
an equally weighted random generator from either the medium or long
range groups, but will use a short range system if none are available to
the faction.

I've made the change in a way that leaves factions compatible, but will
follow up to clean up our built-in factions.
This commit is contained in:
Dan Albert
2020-11-27 17:42:59 -08:00
parent e8aa9839b0
commit bd60760f9d
4 changed files with 13 additions and 22 deletions

View File

@@ -156,7 +156,7 @@ def get_faction_possible_sams_generator(
Return the list of possible SAM generator for the given faction
:param faction: Faction name to search units for
"""
return [SAM_MAP[s] for s in faction.sams]
return [SAM_MAP[s] for s in faction.air_defenses]
def get_faction_possible_ewrs_generator(faction: Faction) -> List[Type[GroupGenerator]]:
@@ -233,14 +233,3 @@ def generate_ewr_group(game: Game, ground_object: TheaterGroundObject,
generator.generate()
return generator.get_generated_group()
return None
def generate_shorad_group(game: Game, ground_object: SamGroundObject,
faction: Faction) -> Optional[VehicleGroup]:
if len(faction.shorads) > 0:
sam = random.choice(faction.shorads)
generator = SAM_MAP[sam](game, ground_object)
generator.generate()
return generator.get_generated_group()
else:
return generate_anti_air_group(game, ground_object, faction)