From 02353cf77d32faddb14ed32d5cf6d30f9abce8fd Mon Sep 17 00:00:00 2001 From: evanpelle Date: Thu, 30 Apr 2026 17:17:28 -0600 Subject: [PATCH] Fix nuke cancellation on alliance to use blast radius MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cancelNukesBetweenAlliedPlayers previously only cancelled a nuke if its exact target tile was owned by the new ally. This meant nukes aimed at neutral or own tiles near allied territory would survive alliance formation and still land (and break the alliance). Now uses wouldNukeBreakAlliance — the same blast-radius logic used by maybeBreakAlliances on impact — so a nuke is cancelled if its blast would have meaningfully hit the ally's tiles or structures. Also switches from the exhaustive listNukeBreakAlliance (scans all players) to wouldNukeBreakAlliance with a single-player allySmallIds set for early-exit performance. --- .../alliance/AllianceRequestExecution.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/core/execution/alliance/AllianceRequestExecution.ts b/src/core/execution/alliance/AllianceRequestExecution.ts index 4a109c45e..379f14b6a 100644 --- a/src/core/execution/alliance/AllianceRequestExecution.ts +++ b/src/core/execution/alliance/AllianceRequestExecution.ts @@ -7,6 +7,7 @@ import { PlayerID, UnitType, } from "../../game/Game"; +import { wouldNukeBreakAlliance } from "../Util"; export class AllianceRequestExecution implements Execution { private req: AllianceRequest | null = null; @@ -100,12 +101,19 @@ export class AllianceRequestExecution implements Execution { const targetTile = unit.targetTile(); if (!targetTile) continue; - const targetOwner = this.mg.owner(targetTile); - if (!targetOwner.isPlayer()) continue; - const other = launcher === this.requestor ? recipient : this.requestor; - if (targetOwner !== other) continue; - + const magnitude = this.mg.config().nukeMagnitudes(unit.type()); + if ( + !wouldNukeBreakAlliance({ + game: this.mg, + targetTile, + magnitude, + allySmallIds: new Set([other.smallID()]), + threshold: this.mg.config().nukeAllianceBreakThreshold(), + }) + ) { + continue; + } unit.delete(false); neutralized.set(launcher, (neutralized.get(launcher) ?? 0) + 1); }