From fa3b3478b71aba48bf6cc2bd93e322f9c8b40296 Mon Sep 17 00:00:00 2001 From: Evan Date: Thu, 26 Dec 2024 09:56:12 -0800 Subject: [PATCH] don't delete nukes when player dies. was creating a an error because nukeexecution tried deleting inactive unit. --- src/core/execution/NukeExecution.ts | 3 --- src/core/execution/PlayerExecution.ts | 8 ++++++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/core/execution/NukeExecution.ts b/src/core/execution/NukeExecution.ts index 14a87a081..7875870f5 100644 --- a/src/core/execution/NukeExecution.ts +++ b/src/core/execution/NukeExecution.ts @@ -108,9 +108,6 @@ export class NukeExecution implements Execution { } } } - // this.mg.units() - // .filter(b => euclideanDist(this.cell, b.tile().cell()) < this.magnitude + 50) - // .forEach(b => b.delete()) this.active = false this.nuke.delete(false) } diff --git a/src/core/execution/PlayerExecution.ts b/src/core/execution/PlayerExecution.ts index 606d0cc9e..667673ed8 100644 --- a/src/core/execution/PlayerExecution.ts +++ b/src/core/execution/PlayerExecution.ts @@ -1,5 +1,5 @@ import { Config } from "../configuration/Config" -import { Execution, MutableGame, MutablePlayer, Player, PlayerID, TerraNullius, Tile } from "../game/Game" +import { Execution, MutableGame, MutablePlayer, Player, PlayerID, TerraNullius, Tile, UnitType } from "../game/Game" import { bfs, calculateBoundingBox, getMode, inscribed, simpleHash } from "../Util" import { GameImpl } from "../game/GameImpl" import { consolex } from "../Consolex" @@ -48,7 +48,11 @@ export class PlayerExecution implements Execution { }) if (!this.player.isAlive()) { - this.player.units().forEach(u => u.delete()) + this.player.units().forEach(u => { + if (u.type() != UnitType.AtomBomb && u.type() != UnitType.HydrogenBomb) { + u.delete() + } + }) this.active = false return }