Fixes issue where only first a/c in a flight would show in air inventory

This commit is contained in:
Brock Greman 2021-06-03 17:31:58 -04:00 committed by Dan Albert
parent 203f0d3851
commit 6b1048590f

View File

@ -109,7 +109,7 @@ class AircraftInventoryData:
yield self.player yield self.player
@classmethod @classmethod
def from_flight(cls, flight: Flight) -> AircraftInventoryData: def from_flight(cls, flight: Flight) -> Iterator[AircraftInventoryData]:
unit_type_name = cls.format_unit_type(flight.unit_type, flight.country) unit_type_name = cls.format_unit_type(flight.unit_type, flight.country)
num_units = flight.count num_units = flight.count
flight_type = flight.flight_type.value flight_type = flight.flight_type.value
@ -122,7 +122,7 @@ class AircraftInventoryData:
else: else:
pilot_name = pilot.name pilot_name = pilot.name
player = "Player" if pilot.player else "AI" player = "Player" if pilot.player else "AI"
return AircraftInventoryData( yield AircraftInventoryData(
flight.departure.name, flight.departure.name,
unit_type_name, unit_type_name,
flight_type, flight_type,
@ -194,7 +194,7 @@ class AirInventoryView(QWidget):
def iter_allocated_aircraft(self) -> Iterator[AircraftInventoryData]: def iter_allocated_aircraft(self) -> Iterator[AircraftInventoryData]:
for package in self.game_model.game.blue_ato.packages: for package in self.game_model.game.blue_ato.packages:
for flight in package.flights: for flight in package.flights:
yield AircraftInventoryData.from_flight(flight) yield from AircraftInventoryData.from_flight(flight)
def iter_unallocated_aircraft(self) -> Iterator[AircraftInventoryData]: def iter_unallocated_aircraft(self) -> Iterator[AircraftInventoryData]:
game = self.game_model.game game = self.game_model.game