From f9e7772e09dda0f32a65e1f1716aee8642fbb1d4 Mon Sep 17 00:00:00 2001 From: Raffson Date: Tue, 16 Jul 2024 21:40:07 +0200 Subject: [PATCH] Fine-tune TGO-purchasability logic --- game/theater/theatergroundobject.py | 6 +++--- qt_ui/windows/groundobject/QGroundObjectBuyMenu.py | 8 ++++++++ qt_ui/windows/groundobject/QGroundObjectMenu.py | 8 ++++---- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/game/theater/theatergroundobject.py b/game/theater/theatergroundobject.py index 2f8d3bbf..b56cd207 100644 --- a/game/theater/theatergroundobject.py +++ b/game/theater/theatergroundobject.py @@ -376,7 +376,7 @@ class NavalGroundObject(TheaterGroundObject, ABC): @property def purchasable(self) -> bool: - return False + return self.control_point.coalition.game.turn == 0 @property def is_iads(self) -> bool: @@ -460,7 +460,7 @@ class MissileSiteGroundObject(TheaterGroundObject): @property def purchasable(self) -> bool: - return False + return self.control_point.coalition.game.turn == 0 @property def should_head_to_conflict(self) -> bool: @@ -501,7 +501,7 @@ class CoastalSiteGroundObject(TheaterGroundObject): @property def purchasable(self) -> bool: - return False + return self.control_point.coalition.game.turn == 0 @property def should_head_to_conflict(self) -> bool: diff --git a/qt_ui/windows/groundobject/QGroundObjectBuyMenu.py b/qt_ui/windows/groundobject/QGroundObjectBuyMenu.py index 91a51298..1d97ff51 100644 --- a/qt_ui/windows/groundobject/QGroundObjectBuyMenu.py +++ b/qt_ui/windows/groundobject/QGroundObjectBuyMenu.py @@ -33,6 +33,8 @@ from game.theater.theatergroundobject import ( SamGroundObject, VehicleGroupGroundObject, ShipGroundObject, + MissileSiteGroundObject, + CoastalSiteGroundObject, ) from qt_ui.uiconstants import EVENT_ICONS @@ -282,6 +284,12 @@ class QGroundObjectBuyMenu(QDialog): elif isinstance(ground_object, ShipGroundObject): role = GroupRole.NAVAL tasks.append(GroupTask.NAVY) + elif isinstance(ground_object, MissileSiteGroundObject): + role = GroupRole.DEFENSES + tasks.append(GroupTask.MISSILE) + elif isinstance(ground_object, CoastalSiteGroundObject): + role = GroupRole.DEFENSES + tasks.append(GroupTask.COASTAL) else: raise NotImplementedError(f"Unhandled TGO type {ground_object.__class__}") diff --git a/qt_ui/windows/groundobject/QGroundObjectMenu.py b/qt_ui/windows/groundobject/QGroundObjectMenu.py index e8faeec5..839fb46e 100644 --- a/qt_ui/windows/groundobject/QGroundObjectMenu.py +++ b/qt_ui/windows/groundobject/QGroundObjectMenu.py @@ -104,14 +104,14 @@ class QGroundObjectMenu(QDialog): self.buy_replace.clicked.connect(self.buy_group) self.buy_replace.setProperty("style", "btn-success") - if self.ground_object.purchasable or self.game.turn == 0: + if self.ground_object.purchasable: + # if not purchasable but is_iads => naval unit if self.total_value > 0: self.actionLayout.addWidget(self.sell_all_button) self.actionLayout.addWidget(self.buy_replace) - if self.show_buy_sell_actions and ( - self.ground_object.purchasable or self.game.turn == 0 - ): + if self.show_buy_sell_actions and self.ground_object.purchasable: + # if not purchasable but is_iads => naval unit self.mainLayout.addLayout(self.actionLayout) self.setLayout(self.mainLayout)