From 6c22cbe116d9c1b44808fe5efb95d74df71e00f2 Mon Sep 17 00:00:00 2001 From: JimmyErickson Date: Thu, 5 Nov 2026 11:11:16 +0100 Subject: [PATCH] Fix missile launch stats not recording on unowned tiles (#6285) --- .../engine/src/execution/NukeExecution.ts | 10 ++++----- tests/core/executions/NukeExecution.test.ts | 21 ++++++++++++++++++- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/packages/engine/src/execution/NukeExecution.ts b/packages/engine/src/execution/NukeExecution.ts index 7d2222e80e3..9220e855021 100644 --- a/packages/engine/src/execution/NukeExecution.ts +++ b/packages/engine/src/execution/NukeExecution.ts @@ -254,13 +254,13 @@ export class NukeExecution implements Execution { target.id(), ); } + } - if (this.nukeType === UnitType.MIRV) { - this.mg.recordMirvLaunch(); - } - // Record stats - this.mg.stats().bombLaunch(this.player, target, this.nukeType); + if (this.nukeType === UnitType.MIRV) { + this.mg.recordMirvLaunch(); } + // Record stats + this.mg.stats().bombLaunch(this.player, this.target(), this.nukeType); // after sending a nuke set the missilesilo on cooldown if (silo) { diff --git a/tests/core/executions/NukeExecution.test.ts b/tests/core/executions/NukeExecution.test.ts index 7fa36042edf..7c91f12c27e 100644 --- a/tests/core/executions/NukeExecution.test.ts +++ b/tests/core/executions/NukeExecution.test.ts @@ -5,7 +5,11 @@ import { PlayerType, UnitType, } from "@openfront/engine-api/game/GameTypes"; -import { OTHER_INDEX_DESTROY } from "@openfront/engine-api/StatsSchemas"; +import { + BOMB_INDEX_LAND, + BOMB_INDEX_LAUNCH, + OTHER_INDEX_DESTROY, +} from "@openfront/engine-api/StatsSchemas"; import { ConstructionExecution } from "@openfront/engine/execution/ConstructionExecution"; import { MissileSiloExecution } from "@openfront/engine/execution/MissileSiloExecution"; import { NukeExecution } from "@openfront/engine/execution/NukeExecution"; @@ -562,6 +566,21 @@ describe("NukeExecution", () => { const tiles = nukes.map((n) => n.tile()); expect(new Set(tiles).size).toBe(6); }); + + test("records bombLaunch and bombLand stats when targeting an unowned tile", () => { + player.buildUnit(UnitType.MissileSilo, game.ref(1, 1), {}); + const unownedTarget = game.ref(50, 50); + expect(game.hasOwner(unownedTarget)).toBe(false); + + game.addExecution( + new NukeExecution(UnitType.HydrogenBomb, player, unownedTarget), + ); + executeTicks(game, 200); + + const hbomb = game.stats().getPlayerStats(player)?.bombs?.hbomb; + expect(hbomb?.[BOMB_INDEX_LAUNCH]).toBe(1n); + expect(hbomb?.[BOMB_INDEX_LAND]).toBe(1n); + }); }); describe("NukeExecution kill credit", () => {