mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
RoundRobinize random livery selection from livery_set
This commit is contained in:
parent
8796d629e8
commit
9dd25e933e
@ -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]()
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user