From 1af95955b63f3d9745fa7b0d155a0e7b3c980f12 Mon Sep 17 00:00:00 2001 From: Khopa Date: Sun, 30 May 2021 17:49:15 +0200 Subject: [PATCH] Base menu UI : Added ammo depots & factory information (WIP UX) --- game/theater/controlpoint.py | 25 +++++++++++++++++-------- qt_ui/windows/basemenu/QBaseMenu2.py | 2 ++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/game/theater/controlpoint.py b/game/theater/controlpoint.py index a9312545..270f5986 100644 --- a/game/theater/controlpoint.py +++ b/game/theater/controlpoint.py @@ -791,18 +791,27 @@ class ControlPoint(MissionTarget, ABC): @property def frontline_unit_count_limit(self) -> int: - - tally_connected_ammo_depots = 0 - - for cp_objective in self.connected_objectives: - if cp_objective.category == "ammo" and not cp_objective.is_dead: - tally_connected_ammo_depots += 1 - return ( FREE_FRONTLINE_UNIT_SUPPLY - + tally_connected_ammo_depots * AMMO_DEPOT_FRONTLINE_UNIT_CONTRIBUTION + + self.active_ammo_depots_count * AMMO_DEPOT_FRONTLINE_UNIT_CONTRIBUTION ) + @property + def active_ammo_depots_count(self) -> int: + """Return the number of available ammo depots""" + return sum( + [ + 1 + for obj in self.connected_objectives + if obj.category == "ammo" and not obj.is_dead + ] + ) + + @property + def total_ammo_depots_count(self) -> int: + """Return the number of ammo depots, including dead ones""" + return sum([1 for obj in self.connected_objectives if obj.category == "ammo"]) + @property def strike_targets(self) -> List[Union[MissionTarget, Unit]]: return [] diff --git a/qt_ui/windows/basemenu/QBaseMenu2.py b/qt_ui/windows/basemenu/QBaseMenu2.py index 448e89e4..47d63b3b 100644 --- a/qt_ui/windows/basemenu/QBaseMenu2.py +++ b/qt_ui/windows/basemenu/QBaseMenu2.py @@ -201,6 +201,8 @@ class QBaseMenu2(QDialog): f"{aircraft}/{parking} aircraft", f"{self.cp.base.total_armor} ground units", str(self.cp.runway_status), + f"{self.cp.active_ammo_depots_count}/{self.cp.total_ammo_depots_count} ammo depots", + f"{'Factory can produce units' if self.cp.has_factory else 'Does not have a factory'}", ] ) )