Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/engine/src/execution/NukeExecution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
21 changes: 20 additions & 1 deletion tests/core/executions/NukeExecution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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", () => {
Expand Down
Loading