Use the actual Country type instead of the name.

We want other pieces of country information (in particular the short
names). This cleans up a lot of code anyway.

As an added bonus, this now catches squadrons that used invalid names
which would previously be passed through to pydcs and... then I don't
know what would happen.
This commit is contained in:
Dan Albert
2023-05-12 17:59:51 -07:00
parent 752a90cddb
commit bd2ec12e0f
23 changed files with 63 additions and 78 deletions

View File

@@ -29,13 +29,13 @@ class SquadronDefLoader:
squadrons: dict[AircraftType, list[SquadronDef]] = defaultdict(list)
country = self.faction.country
faction = self.faction
any_country = country.startswith("Combined Joint Task Forces ")
any_country = country.name.startswith("Combined Joint Task Forces ")
for directory in self.squadron_directories():
for path, squadron_def in self.load_squadrons_from(directory):
if not any_country and squadron_def.country != country:
logging.debug(
"Not using squadron for non-matching country (is "
f"{squadron_def.country}, need {country}: {path}"
f"{squadron_def.country.name}, need {country.name}: {path}"
)
continue
if squadron_def.aircraft not in faction.aircrafts: