mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Fix squadron roster size.
This was excluding a number of pilots from the end of the roster equal to the number of losses the squadron had suffered.
This commit is contained in:
parent
558502d8ea
commit
8bb1b1da7c
@ -163,6 +163,9 @@ class Squadron:
|
||||
def _pilots_with_status(self, status: PilotStatus) -> list[Pilot]:
|
||||
return [p for p in self.pilots if p.status == status]
|
||||
|
||||
def _pilots_without_status(self, status: PilotStatus) -> list[Pilot]:
|
||||
return [p for p in self.pilots if p.status != status]
|
||||
|
||||
@property
|
||||
def active_pilots(self) -> list[Pilot]:
|
||||
return self._pilots_with_status(PilotStatus.Active)
|
||||
@ -172,8 +175,12 @@ class Squadron:
|
||||
return self._pilots_with_status(PilotStatus.OnLeave)
|
||||
|
||||
@property
|
||||
def size(self) -> int:
|
||||
return len(self.active_pilots) + len(self.pilots_on_leave)
|
||||
def number_of_pilots_including_dead(self) -> int:
|
||||
return len(self.pilots)
|
||||
|
||||
@property
|
||||
def number_of_living_pilots(self) -> int:
|
||||
return len(self._pilots_without_status(PilotStatus.Dead))
|
||||
|
||||
def pilot_at_index(self, index: int) -> Pilot:
|
||||
return self.pilots[index]
|
||||
|
||||
@ -424,7 +424,7 @@ class SquadronModel(QAbstractListModel):
|
||||
self.squadron = squadron
|
||||
|
||||
def rowCount(self, parent: QModelIndex = QModelIndex()) -> int:
|
||||
return self.squadron.size
|
||||
return self.squadron.number_of_pilots_including_dead
|
||||
|
||||
def data(self, index: QModelIndex, role: int = Qt.DisplayRole) -> Any:
|
||||
if not index.isValid():
|
||||
|
||||
@ -52,9 +52,10 @@ class SquadronDelegate(TwoColumnRowDelegate):
|
||||
return self.squadron(index).nickname
|
||||
elif (row, column) == (1, 1):
|
||||
squadron = self.squadron(index)
|
||||
alive = squadron.number_of_living_pilots
|
||||
active = len(squadron.active_pilots)
|
||||
available = len(squadron.available_pilots)
|
||||
return f"{squadron.size} pilots, {active} active, {available} unassigned"
|
||||
return f"{alive} pilots, {active} active, {available} unassigned"
|
||||
return ""
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user