Convert TOTs to datetime.

https://github.com/dcs-liberation/dcs_liberation/issues/1680
This commit is contained in:
Dan Albert
2022-09-02 20:58:26 -07:00
committed by Raffson
parent 625c4f2dfb
commit 59673e7911
50 changed files with 333 additions and 239 deletions

View File

@@ -2,6 +2,7 @@ from __future__ import annotations
import logging
from collections import defaultdict
from datetime import datetime
from typing import Optional, TYPE_CHECKING
from game.theater import ControlPoint
@@ -52,7 +53,7 @@ class GroundUnitOrders:
pending_units = 0
return pending_units
def process(self, game: Game) -> None:
def process(self, game: Game, now: datetime) -> None:
coalition = game.coalition_for(self.destination.captured)
ground_unit_source = self.find_ground_unit_source(game)
if ground_unit_source is None:
@@ -95,15 +96,20 @@ class GroundUnitOrders:
"still tried to transfer units to there"
)
ground_unit_source.base.commission_units(units_needing_transfer)
self.create_transfer(coalition, ground_unit_source, units_needing_transfer)
self.create_transfer(
coalition, ground_unit_source, units_needing_transfer, now
)
def create_transfer(
self,
coalition: Coalition,
source: ControlPoint,
units: dict[GroundUnitType, int],
now: datetime,
) -> None:
coalition.transfers.new_transfer(TransferOrder(source, self.destination, units))
coalition.transfers.new_transfer(
TransferOrder(source, self.destination, units), now
)
def find_ground_unit_source(self, game: Game) -> Optional[ControlPoint]:
# This is running *after* the turn counter has been incremented, so this is the