From 239046d3a42c13ccc68b16428e5199f557398c58 Mon Sep 17 00:00:00 2001 From: Scott Anderson <662325+scottanderson@users.noreply.github.com> Date: Fri, 8 Aug 2025 05:27:56 -0400 Subject: [PATCH] isNukeType --- src/client/graphics/layers/NameLayer.ts | 4 ++-- src/core/game/Game.ts | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/client/graphics/layers/NameLayer.ts b/src/client/graphics/layers/NameLayer.ts index 2a1863c12..6ff96d51c 100644 --- a/src/client/graphics/layers/NameLayer.ts +++ b/src/client/graphics/layers/NameLayer.ts @@ -14,7 +14,7 @@ import { renderPlayerFlag } from "../../../core/CustomFlag"; import { EventBus } from "../../../core/EventBus"; import { PseudoRandom } from "../../../core/PseudoRandom"; import { Theme } from "../../../core/configuration/Config"; -import { AllPlayers, Cell, nukeTypes } from "../../../core/game/Game"; +import { AllPlayers, Cell, isNukeType } from "../../../core/game/Game"; import { GameView, PlayerView } from "../../../core/game/GameView"; import { UserSettings } from "../../../core/game/UserSettings"; import { AlternateViewEvent } from "../../InputHandler"; @@ -561,7 +561,7 @@ export class NameLayer implements Layer { const isSendingNuke = render.player.id() === unit.owner().id(); const notMyPlayer = !myPlayer || unit.owner().id() !== myPlayer.id(); return ( - nukeTypes.includes(unit.type()) && + isNukeType(unit.type()) && isSendingNuke && notMyPlayer && unit.isActive() diff --git a/src/core/game/Game.ts b/src/core/game/Game.ts index bacbda749..9b7a5208f 100644 --- a/src/core/game/Game.ts +++ b/src/core/game/Game.ts @@ -1,5 +1,6 @@ import { Config } from "../configuration/Config"; import { AllPlayersStats, ClientID } from "../Schemas"; +import { NukeType } from "../StatsSchemas"; import { GameMap, TileRef } from "./GameMap"; import { GameUpdate, @@ -267,6 +268,10 @@ export const nukeTypes = [ UnitType.MIRV, ] as const satisfies UnitType[]; +export function isNukeType(type: UnitType): type is NukeType { + return (nukeTypes as readonly UnitType[]).includes(type); +} + export enum Relation { Hostile = 0, Distrustful = 1,