diff --git a/src/core/execution/NukeExecution.ts b/src/core/execution/NukeExecution.ts index 74e38ca35..daa50dca1 100644 --- a/src/core/execution/NukeExecution.ts +++ b/src/core/execution/NukeExecution.ts @@ -119,7 +119,7 @@ export class NukeExecution implements Execution { this.type !== UnitType.MIRVWarhead, ); this.nuke = this.player.buildUnit(this.type, spawn, { - detonationDst: this.dst, + targetTile: this.dst, }); if (this.mg.hasOwner(this.dst)) { const target = this.mg.owner(this.dst); diff --git a/src/core/game/Game.ts b/src/core/game/Game.ts index 31f581586..ea983b7e0 100644 --- a/src/core/game/Game.ts +++ b/src/core/game/Game.ts @@ -164,9 +164,13 @@ export interface UnitParamsMap { [UnitType.Port]: {}; - [UnitType.AtomBomb]: {}; + [UnitType.AtomBomb]: { + targetTile?: number; + }; - [UnitType.HydrogenBomb]: {}; + [UnitType.HydrogenBomb]: { + targetTile?: number; + }; [UnitType.TradeShip]: { dstPort: Unit; @@ -185,7 +189,9 @@ export interface UnitParamsMap { [UnitType.MIRV]: {}; - [UnitType.MIRVWarhead]: {}; + [UnitType.MIRVWarhead]: { + targetTile?: number; + }; [UnitType.Construction]: {}; } diff --git a/src/core/game/UnitImpl.ts b/src/core/game/UnitImpl.ts index a68f566d7..9c9f965e6 100644 --- a/src/core/game/UnitImpl.ts +++ b/src/core/game/UnitImpl.ts @@ -39,7 +39,8 @@ export class UnitImpl implements Unit { ) { this._lastTile = _tile; this._health = toInt(this.mg.unitInfo(_type).maxHealth ?? 1); - + this._targetTile = + "targetTile" in params ? (params.targetTile ?? undefined) : undefined; this._troops = "troops" in params ? (params.troops ?? 0) : 0; this._lastSetSafeFromPirates = "lastSetSafeFromPirates" in params diff --git a/tests/SAM.test.ts b/tests/SAM.test.ts index 1da6e9114..d8eb2d325 100644 --- a/tests/SAM.test.ts +++ b/tests/SAM.test.ts @@ -63,10 +63,10 @@ describe("SAM", () => { const sam = defender.buildUnit(UnitType.SAMLauncher, game.ref(1, 1), {}); game.addExecution(new SAMLauncherExecution(defender.id(), null, sam)); attacker.buildUnit(UnitType.AtomBomb, game.ref(2, 1), { - detonationDst: game.ref(2, 1), + targetTile: game.ref(2, 1), }); attacker.buildUnit(UnitType.AtomBomb, game.ref(1, 2), { - detonationDst: game.ref(1, 2), + targetTile: game.ref(1, 2), }); expect(attacker.units(UnitType.AtomBomb)).toHaveLength(2); @@ -80,7 +80,7 @@ describe("SAM", () => { game.addExecution(new SAMLauncherExecution(defender.id(), null, sam)); expect(sam.isInCooldown()).toBeFalsy(); const nuke = attacker.buildUnit(UnitType.AtomBomb, game.ref(1, 2), { - detonationDst: game.ref(1, 2), + targetTile: game.ref(1, 2), }); executeTicks(game, 3); @@ -104,7 +104,7 @@ describe("SAM", () => { const sam2 = defender.buildUnit(UnitType.SAMLauncher, game.ref(1, 2), {}); game.addExecution(new SAMLauncherExecution(defender.id(), null, sam2)); const nuke = attacker.buildUnit(UnitType.AtomBomb, game.ref(2, 2), { - detonationDst: game.ref(2, 2), + targetTile: game.ref(2, 2), }); executeTicks(game, 3);