Add custom name for packages in ATO overview

Resolves #55
This commit is contained in:
Raffson
2023-01-02 02:26:00 +01:00
parent f4d75a2c6f
commit 2aed461b3a
4 changed files with 32 additions and 2 deletions

View File

@@ -22,10 +22,15 @@ class Package:
"""A mission package."""
def __init__(
self, target: MissionTarget, db: Database[Flight], auto_asap: bool = False
self,
target: MissionTarget,
db: Database[Flight],
auto_asap: bool = False,
custom_name: str | None = None,
) -> None:
self.target = target
self._db = db
self.custom_name = custom_name
# True if the package ToT should be reset to ASAP whenever the player makes a
# change. This is really a UI property rather than a game property, but we want

View File

@@ -17,6 +17,7 @@ class Migrator:
def _migrate_game(self) -> None:
self._update_doctrine()
self._update_packagewaypoints()
self._update_package_attributes()
def _update_doctrine(self) -> None:
doctrines = [
@@ -41,3 +42,9 @@ class Migrator:
for p in c.ato.packages:
if not hasattr(p.waypoints, "initial"):
p.waypoints = PackageWaypoints.create(p, c)
def _update_package_attributes(self) -> None:
for c in self.game.coalitions:
for p in c.ato.packages:
if not hasattr(p, "custom_name"):
p.custom_name = None