Add clone buttons for flights & packages

Resolves #56
This commit is contained in:
Raffson
2023-01-01 23:39:00 +01:00
parent 6d0ac603f2
commit 62d1a89269
4 changed files with 76 additions and 4 deletions

View File

@@ -276,3 +276,15 @@ class Flight(SidcDescribable):
self._flight_plan_builder.regenerate()
EventStream.put_nowait(GameUpdateEvents().update_flight(self))
@staticmethod
def clone_flight(flight: Flight) -> Flight:
return Flight(
flight.package,
flight.country,
flight.squadron,
flight.count,
flight.flight_type,
flight.start_type,
flight.divert,
)

View File

@@ -214,3 +214,12 @@ class Package:
if flight.departure == airfield:
return airfield
raise RuntimeError("Could not find any airfield assigned to this package")
@staticmethod
def clone_package(package: Package) -> Package:
clone = Package(package.target, package._db, package.auto_asap)
clone.time_over_target = package.time_over_target
for f in package.flights:
cf = Flight.clone_flight(f)
clone.add_flight(cf)
return clone