mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Convert TOTs to datetime.
https://github.com/dcs-liberation/dcs_liberation/issues/1680
This commit is contained in:
@@ -4,6 +4,7 @@ import logging
|
||||
import random
|
||||
from collections.abc import Iterable
|
||||
from dataclasses import dataclass, field
|
||||
from datetime import datetime
|
||||
from typing import Optional, Sequence, TYPE_CHECKING
|
||||
|
||||
from faker import Faker
|
||||
@@ -334,7 +335,7 @@ class Squadron:
|
||||
def arrival(self) -> ControlPoint:
|
||||
return self.location if self.destination is None else self.destination
|
||||
|
||||
def plan_relocation(self, destination: ControlPoint) -> None:
|
||||
def plan_relocation(self, destination: ControlPoint, now: datetime) -> None:
|
||||
if destination == self.location:
|
||||
logging.warning(
|
||||
f"Attempted to plan relocation of {self} to current location "
|
||||
@@ -353,7 +354,7 @@ class Squadron:
|
||||
if not destination.can_operate(self.aircraft):
|
||||
raise RuntimeError(f"{self} cannot operate at {destination}.")
|
||||
self.destination = destination
|
||||
self.replan_ferry_flights()
|
||||
self.replan_ferry_flights(now)
|
||||
|
||||
def cancel_relocation(self) -> None:
|
||||
if self.destination is None:
|
||||
@@ -368,9 +369,9 @@ class Squadron:
|
||||
self.destination = None
|
||||
self.cancel_ferry_flights()
|
||||
|
||||
def replan_ferry_flights(self) -> None:
|
||||
def replan_ferry_flights(self, now: datetime) -> None:
|
||||
self.cancel_ferry_flights()
|
||||
self.plan_ferry_flights()
|
||||
self.plan_ferry_flights(now)
|
||||
|
||||
def cancel_ferry_flights(self) -> None:
|
||||
for package in self.coalition.ato.packages:
|
||||
@@ -381,7 +382,7 @@ class Squadron:
|
||||
if not package.flights:
|
||||
self.coalition.ato.remove_package(package)
|
||||
|
||||
def plan_ferry_flights(self) -> None:
|
||||
def plan_ferry_flights(self, now: datetime) -> None:
|
||||
if self.destination is None:
|
||||
raise RuntimeError(
|
||||
f"Cannot plan ferry flights for {self} because there is no destination."
|
||||
@@ -395,7 +396,7 @@ class Squadron:
|
||||
size = min(remaining, self.aircraft.max_group_size)
|
||||
self.plan_ferry_flight(package, size)
|
||||
remaining -= size
|
||||
package.set_tot_asap()
|
||||
package.set_tot_asap(now)
|
||||
self.coalition.ato.add_package(package)
|
||||
|
||||
def plan_ferry_flight(self, package: Package, size: int) -> None:
|
||||
|
||||
Reference in New Issue
Block a user