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:
Daniel Popsuevich
2025-09-29 03:56:09 +03:00
committed by GitHub
parent 2450ef29ca
commit d16accafef
2 changed files with 39 additions and 5 deletions
+12 -4
View File
@@ -76,18 +76,26 @@ export class NukeExecution implements Execution {
}
const threshold = this.mg.config().nukeAllianceBreakThreshold();
for (const [other, tilesDestroyed] of attacked) {
for (const [attackedPlayer, tilesDestroyed] of attacked) {
if (
tilesDestroyed > threshold &&
this.nuke.type() !== UnitType.MIRVWarhead
) {
// Resolves exploit of alliance breaking in which a pending alliance request
// was accepeted in the middle of an missle attack.
const allianceRequest = attackedPlayer
.incomingAllianceRequests()
.find((ar) => ar.requestor() === this.player);
if (allianceRequest) {
allianceRequest?.reject();
}
// Mirv warheads shouldn't break alliances
const alliance = this.player.allianceWith(other);
const alliance = this.player.allianceWith(attackedPlayer);
if (alliance !== null) {
this.player.breakAlliance(alliance);
}
if (other !== this.player) {
other.updateRelation(this.player, -100);
if (attackedPlayer !== this.player) {
attackedPlayer.updateRelation(this.player, -100);
}
}
}