Cancel nukes when accepting alliance via radial menu (#3155)

Resolves #3154

## Description:

#2716 introduced nuke cancellation logic on alliance acceptance via
`AllianceRequestReplyExecution`. The radial menu action, though, calls
`AllianceRequestExecution` instead, which accepts the alliance if a
request has already been made by the other player.

This PR moves the nuke cancellation logic to `GameImpl`, hooking into
the `acceptAllianceRequest` method, therefore accounting for every
alliance acceptance, regardless of the specific action that brought to
that.

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced

## Please put your Discord username so you can be contacted if a bug or
regression is found:

deshack_82603
This commit is contained in:
Mattia Migliorini
2026-02-16 11:10:26 -08:00
committed by GitHub
parent d0bb3a016e
commit f362e47413
13 changed files with 171 additions and 232 deletions
+14 -16
View File
@@ -1,5 +1,5 @@
import { AllianceRejectExecution } from "../src/core/execution/alliance/AllianceRejectExecution";
import { AllianceRequestExecution } from "../src/core/execution/alliance/AllianceRequestExecution";
import { AllianceRequestReplyExecution } from "../src/core/execution/alliance/AllianceRequestReplyExecution";
import { NukeExecution } from "../src/core/execution/NukeExecution";
import { Game, Player, PlayerType, UnitType } from "../src/core/game/Game";
import { playerInfo, setup } from "./util/Setup";
@@ -36,21 +36,7 @@ describe("AllianceRequestExecution", () => {
}
});
test("Can create alliance by replying", () => {
game.addExecution(new AllianceRequestExecution(player1, player2.id()));
game.executeNextTick();
game.addExecution(
new AllianceRequestReplyExecution(player1.id(), player2, true),
);
game.executeNextTick();
game.executeNextTick();
expect(player1.isAlliedWith(player2)).toBeTruthy();
expect(player2.isAlliedWith(player1)).toBeTruthy();
});
test("Can create alliance by sending alliance request back", () => {
test("Can create alliance by counter-request", () => {
game.addExecution(new AllianceRequestExecution(player1, player2.id()));
game.executeNextTick();
@@ -61,6 +47,18 @@ describe("AllianceRequestExecution", () => {
expect(player2.isAlliedWith(player1)).toBeTruthy();
});
test("Can reject alliance request", () => {
game.addExecution(new AllianceRequestExecution(player1, player2.id()));
game.executeNextTick();
game.addExecution(new AllianceRejectExecution(player1.id(), player2));
game.executeNextTick();
expect(player1.isAlliedWith(player2)).toBeFalsy();
expect(player2.isAlliedWith(player1)).toBeFalsy();
expect(player1.outgoingAllianceRequests().length).toBe(0);
});
test("Alliance request expires", () => {
game.config().allianceRequestDuration = () => 5;
game.addExecution(new AllianceRequestExecution(player1, player2.id()));