mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Change naming to static class
This ensures all generators are using the same ID set.
This commit is contained in:
parent
d7e48662e0
commit
09b7cb3d85
@ -13,11 +13,6 @@ ALPHA_MILITARY = ["Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot",
|
|||||||
"Tango", "Uniform", "Victor", "Whisky", "XRay", "Yankee",
|
"Tango", "Uniform", "Victor", "Whisky", "XRay", "Yankee",
|
||||||
"Zulu", "Zero"]
|
"Zulu", "Zero"]
|
||||||
|
|
||||||
|
|
||||||
class NameGenerator:
|
|
||||||
number = 0
|
|
||||||
infantry_number = 0
|
|
||||||
|
|
||||||
ANIMALS = [
|
ANIMALS = [
|
||||||
"SHARK", "TORTOISE", "BAT", "PANGOLIN", "AARDWOLF",
|
"SHARK", "TORTOISE", "BAT", "PANGOLIN", "AARDWOLF",
|
||||||
"MONKEY", "BUFFALO", "DOG", "BOBCAT", "LYNX", "PANTHER", "TIGER",
|
"MONKEY", "BUFFALO", "DOG", "BOBCAT", "LYNX", "PANTHER", "TIGER",
|
||||||
@ -46,20 +41,26 @@ class NameGenerator:
|
|||||||
"ANACONDA"
|
"ANACONDA"
|
||||||
]
|
]
|
||||||
|
|
||||||
def __init__(self):
|
class NameGenerator:
|
||||||
self.number = 0
|
number = 0
|
||||||
self.ANIMALS = NameGenerator.ANIMALS.copy()
|
infantry_number = 0
|
||||||
|
|
||||||
def reset(self):
|
ANIMALS = ANIMALS
|
||||||
self.number = 0
|
|
||||||
self.ANIMALS = NameGenerator.ANIMALS.copy()
|
|
||||||
|
|
||||||
def reset_numbers(self):
|
@classmethod
|
||||||
self.number = 0
|
def reset(cls):
|
||||||
self.infantry_number = 0
|
cls.number = 0
|
||||||
|
cls.infantry_number = 0
|
||||||
|
cls.ANIMALS = NameGenerator.ANIMALS.copy()
|
||||||
|
|
||||||
def next_aircraft_name(self, country: Country, parent_base_id: int, flight: Flight):
|
@classmethod
|
||||||
self.number += 1
|
def reset_numbers(cls):
|
||||||
|
cls.number = 0
|
||||||
|
cls.infantry_number = 0
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def next_aircraft_name(cls, country: Country, parent_base_id: int, flight: Flight):
|
||||||
|
cls.number += 1
|
||||||
try:
|
try:
|
||||||
if flight.custom_name:
|
if flight.custom_name:
|
||||||
name_str = flight.custom_name
|
name_str = flight.custom_name
|
||||||
@ -69,38 +70,45 @@ class NameGenerator:
|
|||||||
except AttributeError: # Here to maintain save compatibility with 2.3
|
except AttributeError: # Here to maintain save compatibility with 2.3
|
||||||
name_str = "{} {}".format(
|
name_str = "{} {}".format(
|
||||||
flight.package.target.name, flight.flight_type)
|
flight.package.target.name, flight.flight_type)
|
||||||
return "{}|{}|{}|{}|{}|".format(name_str, country.id, self.number, parent_base_id, db.unit_type_name(flight.unit_type))
|
return "{}|{}|{}|{}|{}|".format(name_str, country.id, cls.number, parent_base_id, db.unit_type_name(flight.unit_type))
|
||||||
|
|
||||||
def next_unit_name(self, country: Country, parent_base_id: int, unit_type: UnitType):
|
@classmethod
|
||||||
self.number += 1
|
def next_unit_name(cls, country: Country, parent_base_id: int, unit_type: UnitType):
|
||||||
return "unit|{}|{}|{}|{}|".format(country.id, self.number, parent_base_id, db.unit_type_name(unit_type))
|
cls.number += 1
|
||||||
|
return "unit|{}|{}|{}|{}|".format(country.id, cls.number, parent_base_id, db.unit_type_name(unit_type))
|
||||||
|
|
||||||
def next_infantry_name(self, country: Country, parent_base_id: int, unit_type: UnitType):
|
@classmethod
|
||||||
self.infantry_number += 1
|
def next_infantry_name(cls, country: Country, parent_base_id: int, unit_type: UnitType):
|
||||||
return "infantry|{}|{}|{}|{}|".format(country.id, self.infantry_number, parent_base_id, db.unit_type_name(unit_type))
|
cls.infantry_number += 1
|
||||||
|
return "infantry|{}|{}|{}|{}|".format(country.id, cls.infantry_number, parent_base_id, db.unit_type_name(unit_type))
|
||||||
|
|
||||||
def next_basedefense_name(self):
|
@staticmethod
|
||||||
|
def next_basedefense_name():
|
||||||
return "basedefense_aa|0|0|"
|
return "basedefense_aa|0|0|"
|
||||||
|
|
||||||
def next_awacs_name(self, country: Country):
|
@classmethod
|
||||||
self.number += 1
|
def next_awacs_name(cls, country: Country):
|
||||||
return "awacs|{}|{}|0|".format(country.id, self.number)
|
cls.number += 1
|
||||||
|
return "awacs|{}|{}|0|".format(country.id, cls.number)
|
||||||
|
|
||||||
def next_tanker_name(self, country: Country, unit_type: UnitType):
|
@classmethod
|
||||||
self.number += 1
|
def next_tanker_name(cls, country: Country, unit_type: UnitType):
|
||||||
return "tanker|{}|{}|0|{}".format(country.id, self.number, db.unit_type_name(unit_type))
|
cls.number += 1
|
||||||
|
return "tanker|{}|{}|0|{}".format(country.id, cls.number, db.unit_type_name(unit_type))
|
||||||
|
|
||||||
def next_carrier_name(self, country: Country):
|
@classmethod
|
||||||
self.number += 1
|
def next_carrier_name(cls, country: Country):
|
||||||
return "carrier|{}|{}|0|".format(country.id, self.number)
|
cls.number += 1
|
||||||
|
return "carrier|{}|{}|0|".format(country.id, cls.number)
|
||||||
|
|
||||||
def random_objective_name(self):
|
@classmethod
|
||||||
if len(self.ANIMALS) == 0:
|
def random_objective_name(cls):
|
||||||
|
if len(cls.ANIMALS) == 0:
|
||||||
return random.choice(ALPHA_MILITARY).upper() + "#" + str(random.randint(0, 100))
|
return random.choice(ALPHA_MILITARY).upper() + "#" + str(random.randint(0, 100))
|
||||||
else:
|
else:
|
||||||
animal = random.choice(self.ANIMALS)
|
animal = random.choice(cls.ANIMALS)
|
||||||
self.ANIMALS.remove(animal)
|
cls.ANIMALS.remove(animal)
|
||||||
return animal
|
return animal
|
||||||
|
|
||||||
|
|
||||||
namegen = NameGenerator()
|
namegen = NameGenerator
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user