diff --git a/game/migrator.py b/game/migrator.py index c96d62a1..9becbfab 100644 --- a/game/migrator.py +++ b/game/migrator.py @@ -164,6 +164,7 @@ class Migrator: try_set_attr(s, "max_size", 12) try_set_attr(s, "radio_presets", {}) try_set_attr(s, "livery_set", []) + try_set_attr(s, "_livery_pool", []) if isinstance(s.country, str): c = country_dict.get(s.country, s.country) s.country = countries_by_name[c]() diff --git a/game/missiongenerator/aircraft/aircraftpainter.py b/game/missiongenerator/aircraft/aircraftpainter.py index cc9cac49..411082a9 100644 --- a/game/missiongenerator/aircraft/aircraftpainter.py +++ b/game/missiongenerator/aircraft/aircraftpainter.py @@ -33,7 +33,7 @@ class AircraftPainter: and (self.flight.squadron.use_livery_set or member_uses_livery_set) ): return None - return random.choice(self.flight.squadron.livery_set) + return self.flight.squadron.random_round_robin_livery_from_set() def determine_livery(self, member_uses_livery_set: bool) -> Optional[str]: livery = self.livery_from_squadron_set(member_uses_livery_set) diff --git a/game/squadrons/squadron.py b/game/squadrons/squadron.py index ab109f6b..1bc349db 100644 --- a/game/squadrons/squadron.py +++ b/game/squadrons/squadron.py @@ -92,6 +92,9 @@ class Squadron: return False return self.id == other.id + def __post_init__(self) -> None: + self._livery_pool: list[str] = [] + @property def player(self) -> bool: return self.coalition.player @@ -104,6 +107,15 @@ class Squadron: def pilot_limits_enabled(self) -> bool: return self.settings.enable_squadron_pilot_limits + def random_round_robin_livery_from_set(self) -> str: + livery = random.choice(self.livery_set) + self._livery_pool.append(livery) + self.livery_set.remove(livery) + if not self.livery_set: + self.livery_set = self._livery_pool + self._livery_pool = [] + return livery + def set_auto_assignable_mission_types( self, mission_types: Iterable[FlightType] ) -> None: