mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
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:
@@ -7,6 +7,7 @@ from dataclasses import dataclass, field
|
||||
from datetime import datetime
|
||||
from typing import Optional, Sequence, TYPE_CHECKING
|
||||
|
||||
from dcs.country import Country
|
||||
from faker import Faker
|
||||
|
||||
from game.ato import Flight, FlightType, Package
|
||||
@@ -28,7 +29,7 @@ if TYPE_CHECKING:
|
||||
class Squadron:
|
||||
name: str
|
||||
nickname: Optional[str]
|
||||
country: str
|
||||
country: Country
|
||||
role: str
|
||||
aircraft: AircraftType
|
||||
max_size: int
|
||||
@@ -71,7 +72,7 @@ class Squadron:
|
||||
(
|
||||
self.name,
|
||||
self.nickname,
|
||||
self.country,
|
||||
self.country.id,
|
||||
self.role,
|
||||
self.aircraft,
|
||||
)
|
||||
@@ -418,7 +419,6 @@ class Squadron:
|
||||
|
||||
flight = Flight(
|
||||
package,
|
||||
self.coalition.country_name,
|
||||
self,
|
||||
size,
|
||||
FlightType.FERRY,
|
||||
|
||||
@@ -5,8 +5,10 @@ from pathlib import Path
|
||||
from typing import Optional, TYPE_CHECKING
|
||||
|
||||
import yaml
|
||||
from dcs.country import Country
|
||||
|
||||
from game.dcs.aircrafttype import AircraftType
|
||||
from game.dcs.countries import country_with_name
|
||||
from game.squadrons.operatingbases import OperatingBases
|
||||
from game.squadrons.pilot import Pilot
|
||||
|
||||
@@ -19,7 +21,7 @@ if TYPE_CHECKING:
|
||||
class SquadronDef:
|
||||
name: str
|
||||
nickname: Optional[str]
|
||||
country: str
|
||||
country: Country
|
||||
role: str
|
||||
aircraft: AircraftType
|
||||
livery: Optional[str]
|
||||
@@ -71,7 +73,7 @@ class SquadronDef:
|
||||
return SquadronDef(
|
||||
name=data["name"],
|
||||
nickname=data.get("nickname"),
|
||||
country=data["country"],
|
||||
country=country_with_name(data["country"]),
|
||||
role=data["role"],
|
||||
aircraft=unit_type,
|
||||
livery=data.get("livery"),
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user