mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-27 12:24:16 +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
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user