bugfix: when nuking nearby water, the attacker was not marked as a traitor on launch (#1574)

## Description:

There was a bug where we only checked for betrayals if the target tile
was owned.

## 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
- [x] I have read and accepted the CLA aggreement (only required once).

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

evan
This commit is contained in:
evanpelle
2025-07-25 18:39:28 -04:00
committed by GitHub
parent e2fd7aaa0f
commit 65937b7e69
4 changed files with 53 additions and 16 deletions
+39 -11
View File
@@ -12,31 +12,34 @@ import { executeTicks } from "../../util/utils";
let game: Game;
let player: Player;
let otherPlayer: Player;
describe("NukeExecution", () => {
beforeEach(async () => {
game = await setup("big_plains", {
infiniteGold: true,
instantBuild: true,
});
game = await setup(
"big_plains",
{
infiniteGold: true,
instantBuild: true,
},
[
new PlayerInfo("player", PlayerType.Human, "client_id1", "player_id"),
new PlayerInfo("other", PlayerType.Human, "client_id2", "other_id"),
],
);
(game.config() as TestConfig).nukeMagnitudes = jest.fn(() => ({
inner: 10,
outer: 10,
}));
const player_info = new PlayerInfo(
"player_id",
PlayerType.Human,
null,
"player_id",
);
game.addPlayer(player_info);
(game.config() as TestConfig).nukeAllianceBreakThreshold = jest.fn(() => 5);
while (game.inSpawnPhase()) {
game.executeNextTick();
}
player = game.player("player_id");
otherPlayer = game.player("other_id");
});
test("nuke should destroy buildings and redraw out of range buildings", async () => {
@@ -94,4 +97,29 @@ describe("NukeExecution", () => {
executeTicks(game, 35);
expect(nukeExec.getNuke()!.isTargetable()).toBeTruthy();
});
test("nuke should break alliances on launch", async () => {
const req = player.createAllianceRequest(otherPlayer);
req!.accept();
player.conquer(game.ref(1, 1));
player.buildUnit(UnitType.MissileSilo, game.ref(1, 1), {});
for (let x = 90; x < 99; x++) {
for (let y = 90; y < 99; y++) {
otherPlayer.conquer(game.ref(x, y));
}
}
// Add a nuke targeting just outside the other player's territory.
game.addExecution(
new NukeExecution(UnitType.AtomBomb, player, game.ref(85, 85), null),
);
game.executeNextTick(); // init
game.executeNextTick(); // exec
expect(player.isTraitor()).toBe(true);
expect(player.isAlliedWith(otherPlayer)).toBe(false);
});
});