From 5277beede382e65e20ffa73058662b09767a5231 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Wed, 26 May 2021 18:18:22 -0700 Subject: [PATCH] Show active and available pilots in air wing view. https://github.com/dcs-liberation/dcs_liberation/issues/276 --- game/squadrons.py | 6 +++++- qt_ui/windows/AirWingDialog.py | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/game/squadrons.py b/game/squadrons.py index 237abf1b..44d70e30 100644 --- a/game/squadrons.py +++ b/game/squadrons.py @@ -84,9 +84,13 @@ class Squadron: def faker(self) -> Faker: return self.game.faker_for(self.player) + @property + def active_pilots(self) -> list[Pilot]: + return [p for p in self.pilots if p.alive] + @property def size(self) -> int: - return len(self.pilots) + return len(self.active_pilots) def pilot_at_index(self, index: int) -> Pilot: return self.pilots[index] diff --git a/qt_ui/windows/AirWingDialog.py b/qt_ui/windows/AirWingDialog.py index 3eac8416..bf7e434d 100644 --- a/qt_ui/windows/AirWingDialog.py +++ b/qt_ui/windows/AirWingDialog.py @@ -39,6 +39,10 @@ class SquadronDelegate(TwoColumnRowDelegate): ) elif (row, column) == (1, 0): return self.squadron(index).nickname + elif (row, column) == (1, 1): + squadron = self.squadron(index) + available = len(squadron.available_pilots) + return f"{squadron.size} active pilots, {available} available" return ""