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

9
game/dcs/countries.py Normal file
View File

@@ -0,0 +1,9 @@
from dcs.countries import country_dict
from dcs.country import Country
def country_with_name(name: str) -> Country:
for country in country_dict.values():
if country.name == name:
return country()
raise KeyError(f"No country found named {name}")