Enhance nuke alliance breaking logic to account for allied structures in blast radius 💣 (#2887)

## Description:

Doesn't need a description :D


https://github.com/user-attachments/assets/8de576fd-050b-4b35-8526-e4c88d1a9f25


https://github.com/user-attachments/assets/c99147a1-efdf-426b-96d1-e996e01f89aa

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

FloPinguin
This commit is contained in:
FloPinguin
2026-01-13 12:30:25 -08:00
committed by GitHub
parent 0e3b9cca29
commit 35b7213c5c
8 changed files with 204 additions and 37 deletions
@@ -125,4 +125,36 @@ describe("NukeExecution", () => {
expect(player.isTraitor()).toBe(true);
expect(player.isAlliedWith(otherPlayer)).toBe(false);
});
test("nuke should break alliance when destroying ally's building even with few tiles", async () => {
const req = player.createAllianceRequest(otherPlayer);
req!.accept();
expect(player.isAlliedWith(otherPlayer)).toBe(true);
player.conquer(game.ref(1, 1));
player.buildUnit(UnitType.MissileSilo, game.ref(1, 1), {});
// Give the other player just a few tiles (below the threshold of 5)
// and build a port on one of them
otherPlayer.conquer(game.ref(50, 50));
otherPlayer.conquer(game.ref(51, 50));
otherPlayer.conquer(game.ref(50, 51));
otherPlayer.buildUnit(UnitType.Port, game.ref(50, 50), {});
expect(otherPlayer.units(UnitType.Port)).toHaveLength(1);
// Nuke targeting the ally's port - this should break alliance
// even though the tile count is below threshold
game.addExecution(
new NukeExecution(UnitType.AtomBomb, player, game.ref(50, 50), null),
);
game.executeNextTick(); // init
game.executeNextTick(); // exec
// Alliance should be broken because we're destroying ally's building
expect(player.isTraitor()).toBe(true);
expect(player.isAlliedWith(otherPlayer)).toBe(false);
});
});