mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-11 07:48:26 +00:00
Revoking alliances request during nuke (#2101)
Closes #2071 ## Description: - Created Functional Test for scenario - Added an alliance revoker function to 'NukeExection' ## Please complete the following: - [ ] I have added screenshots for all UI updates - [ ] 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: dpop
This commit is contained in:
committed by
GitHub
parent
2450ef29ca
commit
d16accafef
@@ -1,7 +1,9 @@
|
||||
import { AllianceRequestExecution } from "../src/core/execution/alliance/AllianceRequestExecution";
|
||||
import { AllianceRequestReplyExecution } from "../src/core/execution/alliance/AllianceRequestReplyExecution";
|
||||
import { Game, Player, PlayerType } from "../src/core/game/Game";
|
||||
import { NukeExecution } from "../src/core/execution/NukeExecution";
|
||||
import { Game, Player, PlayerType, UnitType } from "../src/core/game/Game";
|
||||
import { playerInfo, setup } from "./util/Setup";
|
||||
import { constructionExecution } from "./util/utils";
|
||||
|
||||
let game: Game;
|
||||
let player1: Player;
|
||||
@@ -74,4 +76,28 @@ describe("AllianceRequestExecution", () => {
|
||||
expect(player1.isAlliedWith(player2)).toBeFalsy();
|
||||
expect(player2.isAlliedWith(player1)).toBeFalsy();
|
||||
});
|
||||
|
||||
// Resolves exploit https://github.com/openfrontio/OpenFrontIO/issues/2071
|
||||
test("alliance request is revoked immediately if requester launches a nuke", () => {
|
||||
game.config().nukeAllianceBreakThreshold = () => 0;
|
||||
// Player 1 sends an alliance request to player 2.
|
||||
game.addExecution(new AllianceRequestExecution(player1, player2.id()));
|
||||
game.executeNextTick();
|
||||
|
||||
expect(player1.outgoingAllianceRequests().length).toBe(1);
|
||||
expect(player2.incomingAllianceRequests().length).toBe(1);
|
||||
|
||||
// Player 1 Builds a silo & launches a missle at player 2.
|
||||
constructionExecution(game, player1, 0, 0, UnitType.MissileSilo);
|
||||
game.addExecution(
|
||||
new NukeExecution(UnitType.AtomBomb, player1, game.ref(0, 1), null),
|
||||
);
|
||||
game.executeNextTick();
|
||||
game.executeNextTick();
|
||||
|
||||
expect(player1.outgoingAllianceRequests().length).toBe(0);
|
||||
expect(player2.incomingAllianceRequests().length).toBe(0);
|
||||
expect(player1.isAlliedWith(player2)).toBeFalsy();
|
||||
expect(player2.isAlliedWith(player1)).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user