mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Support display of dead flights.
This commit is contained in:
@@ -49,7 +49,7 @@ class AircraftSimulation:
|
||||
|
||||
still_active = []
|
||||
for combat in self.combats:
|
||||
if combat.on_game_tick(duration, self.results):
|
||||
if combat.on_game_tick(duration, self.results, events):
|
||||
events.end_combat(combat)
|
||||
else:
|
||||
still_active.append(combat)
|
||||
|
||||
@@ -10,6 +10,7 @@ from shapely.ops import unary_union
|
||||
from game.ato.flightstate import InCombat, InFlight
|
||||
from game.utils import dcs_to_shapely_point
|
||||
from .joinablecombat import JoinableCombat
|
||||
from .. import GameUpdateEvents
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from game.ato import Flight
|
||||
@@ -60,7 +61,7 @@ class AirCombat(JoinableCombat):
|
||||
def describe(self) -> str:
|
||||
return f"in air-to-air combat"
|
||||
|
||||
def resolve(self, results: SimulationResults) -> None:
|
||||
def resolve(self, results: SimulationResults, events: GameUpdateEvents) -> None:
|
||||
blue = []
|
||||
red = []
|
||||
for flight in self.flights:
|
||||
@@ -87,11 +88,11 @@ class AirCombat(JoinableCombat):
|
||||
logging.debug(f"{self} auto-resolved as red victory")
|
||||
|
||||
for flight in loser:
|
||||
flight.kill(results)
|
||||
flight.kill(results, events)
|
||||
|
||||
for flight in winner:
|
||||
assert isinstance(flight.state, InCombat)
|
||||
if random.random() / flight.count >= 0.5:
|
||||
flight.kill(results)
|
||||
flight.kill(results, events)
|
||||
else:
|
||||
flight.state.exit_combat()
|
||||
|
||||
@@ -6,6 +6,7 @@ from datetime import timedelta
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from .frozencombat import FrozenCombat
|
||||
from .. import GameUpdateEvents
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from game.ato import Flight
|
||||
@@ -26,7 +27,7 @@ class AtIp(FrozenCombat):
|
||||
def iter_flights(self) -> Iterator[Flight]:
|
||||
yield self.flight
|
||||
|
||||
def resolve(self, results: SimulationResults) -> None:
|
||||
def resolve(self, results: SimulationResults, events: GameUpdateEvents) -> None:
|
||||
logging.debug(
|
||||
f"{self.flight} attack on {self.flight.package.target} auto-resolved with "
|
||||
"mission failure but no losses"
|
||||
|
||||
@@ -8,6 +8,7 @@ from typing import TYPE_CHECKING
|
||||
|
||||
from game.ato.flightstate import InCombat
|
||||
from .frozencombat import FrozenCombat
|
||||
from .. import GameUpdateEvents
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from game.ato import Flight
|
||||
@@ -36,11 +37,11 @@ class DefendingSam(FrozenCombat):
|
||||
def iter_flights(self) -> Iterator[Flight]:
|
||||
yield self.flight
|
||||
|
||||
def resolve(self, results: SimulationResults) -> None:
|
||||
def resolve(self, results: SimulationResults, events: GameUpdateEvents) -> None:
|
||||
assert isinstance(self.flight.state, InCombat)
|
||||
if random.random() / self.flight.count >= 0.5:
|
||||
logging.debug(f"Air defense combat auto-resolved with {self.flight} lost")
|
||||
self.flight.kill(results)
|
||||
self.flight.kill(results, events)
|
||||
else:
|
||||
logging.debug(
|
||||
f"Air defense combat auto-resolved with {self.flight} surviving"
|
||||
|
||||
@@ -7,6 +7,7 @@ from datetime import timedelta
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from game.ato.flightstate import InCombat, InFlight
|
||||
from .. import GameUpdateEvents
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from game.ato import Flight
|
||||
@@ -19,15 +20,17 @@ class FrozenCombat(ABC):
|
||||
self.freeze_duration = freeze_duration
|
||||
self.elapsed_time = timedelta()
|
||||
|
||||
def on_game_tick(self, duration: timedelta, results: SimulationResults) -> bool:
|
||||
def on_game_tick(
|
||||
self, duration: timedelta, results: SimulationResults, events: GameUpdateEvents
|
||||
) -> bool:
|
||||
self.elapsed_time += duration
|
||||
if self.elapsed_time >= self.freeze_duration:
|
||||
self.resolve(results)
|
||||
self.resolve(results, events)
|
||||
return True
|
||||
return False
|
||||
|
||||
@abstractmethod
|
||||
def resolve(self, results: SimulationResults) -> None:
|
||||
def resolve(self, results: SimulationResults, events: GameUpdateEvents) -> None:
|
||||
...
|
||||
|
||||
@abstractmethod
|
||||
|
||||
Reference in New Issue
Block a user