From bc1e793ce6ff1ecea176478b3127003d95d36fdc Mon Sep 17 00:00:00 2001 From: Khopa Date: Thu, 22 Oct 2020 13:55:37 +0200 Subject: [PATCH] Fixed faction loader so it works with known modded units --- game/factions/faction.py | 4 ++ resources/factions/russia_2020.json | 78 +++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 resources/factions/russia_2020.json diff --git a/game/factions/faction.py b/game/factions/faction.py index 9f242bb8..6c894398 100644 --- a/game/factions/faction.py +++ b/game/factions/faction.py @@ -193,6 +193,10 @@ def unit_loader(unit: str, class_repository:[]) -> Optional[PlaneType]: for mother_class in class_repository: if getattr(mother_class, unit, None) is not None: return getattr(mother_class, unit) + if type(mother_class) is list: + for m in mother_class: + if m.__name__ == unit: + return m logging.info("FACTION ERROR : Unable to find " + unit + " in pydcs") print("FACTION ERROR : Unable to find " + unit + " in pydcs") return None diff --git a/resources/factions/russia_2020.json b/resources/factions/russia_2020.json new file mode 100644 index 00000000..b12bf7d1 --- /dev/null +++ b/resources/factions/russia_2020.json @@ -0,0 +1,78 @@ +{ + "country": "Russia", + "name": "Russia 2020 (Modded)", + "aircrafts": [ + "MiG_29S", + "MiG_31", + "Su_24M", + "Su_25", + "Su_25T", + "Su_27", + "Su_30", + "Su_33", + "Su_34", + "Su_57", + "L_39ZA", + "Mi_8MT", + "Mi_24V", + "Mi_28N", + "Ka_50" + ], + "awacs": [ + "A_50" + ], + "tankers": [ + "IL_78M" + ], + "frontline_units": [ + "IFV_BMP_2", + "IFV_BMP_3", + "MBT_T_90", + "MBT_T_80U", + "MBT_T_72B" + ], + "artillery_units": [ + "MLRS_9K57_Uragan_BM_27", + "SPH_2S19_Msta" + ], + "logistics_units": [ + "Transport_Ural_375", + "Transport_UAZ_469" + ], + "infantry_units": [ + "Paratrooper_AKS", + "Infantry_Soldier_Rus", + "Paratrooper_RPG_16" + ], + "shorads": [ + "SA19Generator" + ], + "sams": [ + "SA11Generator", + "SA10Generator", + "SA19Generator" + ], + "aircraft_carrier": [ + "CV_1143_5_Admiral_Kuznetsov" + ], + "helicopter_carrier": [ + ], + "lhanames": [ + ], + "destroyers": [ + "FF_1135M_Rezky" + ], + "cruisers": [ + "FSG_1241_1MP_Molniya" + ], + "requirements": {}, + "carrier_names": [ + "Admiral Kuznetov" + ], + "navy_generators": [ + "RussianNavyGroupGenerator", + "KiloSubGroupGenerator" + ], + "has_jtac": true, + "jtac_unit": "MQ_9_Reaper" +}