New cheat option: manage REDFOR's TGOs

This commit is contained in:
Raffson
2024-03-01 23:06:46 +01:00
parent 9f7c9eec14
commit 32f8d8d0b7
5 changed files with 37 additions and 8 deletions

View File

@@ -188,7 +188,8 @@ class QGroundObjectTemplateLayout(QGroupBox):
@property
def affordable(self) -> bool:
return self.cost <= self.game.blue.budget
coalition = self.ground_object.coalition
return self.cost <= coalition.budget
def add_theater_group(
self, group_name: str, force_group: ForceGroup, groups: list[TgoLayoutUnitGroup]
@@ -226,7 +227,8 @@ class QGroundObjectTemplateLayout(QGroupBox):
self.game.theater.heading_to_conflict_from(self.ground_object.position)
or self.ground_object.heading
)
self.game.blue.budget -= self.cost
coalition = self.ground_object.coalition
coalition.budget -= self.cost
self.ground_object.groups = []
for group_name, groups in self.layout_model.groups.items():
for group in groups:
@@ -282,7 +284,8 @@ class QGroundObjectBuyMenu(QDialog):
if not tasks:
tasks = role.tasks
for group in game.blue.armed_forces.groups_for_tasks(tasks):
coalition = ground_object.coalition
for group in coalition.armed_forces.groups_for_tasks(tasks):
self.force_group_selector.addItem(group.name, userData=group)
self.force_group_selector.setEnabled(self.force_group_selector.count() > 1)
self.force_group_selector.adjustSize()

View File

@@ -109,10 +109,16 @@ class QGroundObjectMenu(QDialog):
self.actionLayout.addWidget(self.sell_all_button)
self.actionLayout.addWidget(self.buy_replace)
if self.cp.captured and self.ground_object.purchasable:
if self.show_buy_sell_actions and self.ground_object.purchasable:
self.mainLayout.addLayout(self.actionLayout)
self.setLayout(self.mainLayout)
@property
def show_buy_sell_actions(self) -> bool:
buysell_allowed = self.game.settings.enable_enemy_buy_sell
buysell_allowed |= self.cp.captured
return buysell_allowed
def doLayout(self):
self.update_total_value()
self.intelBox = QGroupBox("Units :")
@@ -240,7 +246,7 @@ class QGroundObjectMenu(QDialog):
self.actionLayout.addWidget(self.sell_all_button)
self.actionLayout.addWidget(self.buy_replace)
if self.cp.captured and self.ground_object.purchasable:
if self.show_buy_sell_actions and self.ground_object.purchasable:
self.mainLayout.addLayout(self.actionLayout)
except Exception as e:
logging.exception(e)
@@ -276,7 +282,8 @@ class QGroundObjectMenu(QDialog):
def sell_all(self):
self.update_total_value()
self.game.blue.budget += self.total_value
coalition = self.ground_object.coalition
coalition.budget += self.total_value
self.ground_object.groups = []
self.update_game()
@@ -296,7 +303,10 @@ class QGroundObjectMenu(QDialog):
for package in self.game.ato_for(player=False).packages
):
# Replan if the tgo was a target of the redfor
self.game.initialize_turn(events, for_red=True, for_blue=False)
coalition = self.ground_object.coalition
self.game.initialize_turn(
events, for_red=coalition.player, for_blue=not coalition.player
)
EventStream.put_nowait(events)
GameUpdateSignal.get_instance().updateGame(self.game)
# Refresh the dialog

View File

@@ -113,6 +113,15 @@ class CheatSettingsBox(QGroupBox):
)
self.main_layout.addLayout(self.air_wing_cheat)
# Buy/Sell actions for REDFOR
self.redfor_buysell_checkbox = QCheckBox()
self.redfor_buysell_checkbox.setChecked(sc.settings.enable_enemy_buy_sell)
self.redfor_buysell_checkbox.toggled.connect(apply_settings)
self.redfor_buysell_cheat = QLabeledWidget(
"Enable REDFOR Buy/Sell actions Cheat:", self.redfor_buysell_checkbox
)
self.main_layout.addLayout(self.redfor_buysell_cheat)
@property
def show_red_ato(self) -> bool:
return self.red_ato_checkbox.isChecked()
@@ -137,6 +146,10 @@ class CheatSettingsBox(QGroupBox):
def enable_air_wing_cheats(self) -> bool:
return self.air_wing_adjustments_checkbox.isChecked()
@property
def enable_redfor_buysell(self) -> bool:
return self.redfor_buysell_checkbox.isChecked()
class AutoSettingsLayout(QGridLayout):
def __init__(
@@ -495,6 +508,7 @@ class QSettingsWidget(QtWidgets.QWizardPage, SettingsContainer):
self.settings.enable_air_wing_adjustments = (
self.cheat_options.enable_air_wing_cheats
)
self.settings.enable_enemy_buy_sell = self.cheat_options.enable_redfor_buysell
if self.game:
events = GameUpdateEvents()