diff --git a/game/theater/theatergroundobject.py b/game/theater/theatergroundobject.py index 00203ade..926bbe82 100644 --- a/game/theater/theatergroundobject.py +++ b/game/theater/theatergroundobject.py @@ -254,6 +254,11 @@ class TheaterGroundObject(MissionTarget, SidcDescribable, ABC): def purchasable(self) -> bool: raise NotImplementedError + @property + def value(self) -> int: + """The value of all units of the Ground Objects""" + return sum(u.unit_type.price for u in self.units if u.unit_type and u.alive) + def group_by_name(self, name: str) -> Optional[TheaterGroup]: for group in self.groups: if group.name == name: diff --git a/qt_ui/windows/groundobject/QGroundObjectMenu.py b/qt_ui/windows/groundobject/QGroundObjectMenu.py index d8056193..27b0fe06 100644 --- a/qt_ui/windows/groundobject/QGroundObjectMenu.py +++ b/qt_ui/windows/groundobject/QGroundObjectMenu.py @@ -217,11 +217,7 @@ class QGroundObjectMenu(QDialog): def update_total_value(self): if not self.ground_object.purchasable: return - self.total_value = sum( - u.unit_type.price - for u in self.ground_object.units - if u.unit_type and u.alive - ) + self.total_value = self.ground_object.value if self.sell_all_button is not None: self.sell_all_button.setText("Disband (+$" + str(self.total_value) + "M)") @@ -248,7 +244,7 @@ class QGroundObjectMenu(QDialog): def sell_all(self): self.update_total_value() - self.game.blue.budget = self.game.blue.budget + self.total_value + self.game.blue.budget += self.total_value self.ground_object.groups = [] self.update_game()