Fine-tune TGO-purchasability logic

This commit is contained in:
Raffson 2024-07-16 21:40:07 +02:00
parent 2c270306a1
commit f9e7772e09
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
3 changed files with 15 additions and 7 deletions

View File

@ -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:

View File

@ -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__}")

View File

@ -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)