Disband squadrons sinking with ship + Sink/Resurrect cheat

This commit is contained in:
Raffson
2024-06-30 01:41:09 +02:00
parent 22f7767b99
commit 6dc5296130
4 changed files with 40 additions and 5 deletions

View File

@@ -159,7 +159,8 @@ class QBaseMenu2(QDialog):
transfer_button.clicked.connect(self.open_transfer_dialog)
if self.cheat_capturable:
capture_button = QPushButton("CHEAT: Capture")
label = "Sink/Resurrect" if self.cp.is_fleet else "Capture"
capture_button = QPushButton(f"CHEAT: {label}")
capture_button.setProperty("style", "btn-danger")
bottom_row.addWidget(capture_button)
capture_button.clicked.connect(self.cheat_capture)
@@ -181,11 +182,23 @@ class QBaseMenu2(QDialog):
def cheat_capture(self) -> None:
events = GameUpdateEvents()
self.cp.capture(self.game_model.game, events, for_player=not self.cp.captured)
mrp = MissionResultsProcessor(self.game_model.game)
mrp.redeploy_units(self.cp)
if self.cp.is_fleet:
for go in self.cp.ground_objects:
if go.is_naval_control_point:
if go.alive_unit_count > 0:
for u in go.units:
u.kill(events)
else:
for u in go.units:
u.revive(events)
else:
self.cp.capture(
self.game_model.game, events, for_player=not self.cp.captured
)
mrp = MissionResultsProcessor(self.game_model.game)
mrp.redeploy_units(self.cp)
# Reinitialized ground planners and the like. The ATO needs to be reset because
# missions planned against the flipped base are no longer valid.
# missions planned against the flipped base (or killed carrier) are no longer valid.
self.game_model.game.initialize_turn(events)
EventStream.put_nowait(events)
GameUpdateSignal.get_instance().updateGame(self.game_model.game)