From 7170a7b3023d3b4aa5ddfb65c467b07f9f9ffd31 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Wed, 16 Jun 2021 20:11:36 -0700 Subject: [PATCH] Fix spawning unused aircraft. These are assigned a squadron even though they're unused as a hack. We need to tolerate these aircraft having no pilot assigned since that's the desired case for unused aircraft (though only happens when the squadron runs out of pilots, which should be fixed). --- game/event/event.py | 2 +- game/unitmap.py | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/game/event/event.py b/game/event/event.py index df63d34b..6c842347 100644 --- a/game/event/event.py +++ b/game/event/event.py @@ -122,7 +122,7 @@ class Event: def commit_air_losses(self, debriefing: Debriefing) -> None: for loss in debriefing.air_losses.losses: - if ( + if loss.pilot is not None and ( not loss.pilot.player or not self.game.settings.invulnerable_player_pilots ): diff --git a/game/unitmap.py b/game/unitmap.py index c1778091..c3273cf7 100644 --- a/game/unitmap.py +++ b/game/unitmap.py @@ -19,7 +19,7 @@ from gen.flights.flight import Flight @dataclass(frozen=True) class FlyingUnit: flight: Flight - pilot: Pilot + pilot: Optional[Pilot] @dataclass(frozen=True) @@ -70,8 +70,6 @@ class UnitMap: name = str(unit.name) if name in self.aircraft: raise RuntimeError(f"Duplicate unit name: {name}") - if pilot is None: - raise ValueError(f"{name} has no pilot assigned") self.aircraft[name] = FlyingUnit(flight, pilot) if flight.cargo is not None: self.add_airlift_units(group, flight.cargo)