import type { CircleHazardKind } from "./types";

export type BossHazardVfxMotion = "bubble" | "fall" | "flame" | "orbit" | "shockwave" | "spike" | "surge";
export type BossHazardVfxShape = "crystal" | "orb" | "spike";

export interface BossHazardVfxProfile {
  readonly warningColor: string;
  readonly activeColor: string;
  readonly highlightColor: string;
  readonly motion: BossHazardVfxMotion;
  readonly shape: BossHazardVfxShape;
  readonly particleCount: number;
  readonly height: number;
  readonly spinSpeed: number;
  readonly columnOpacity: number;
}

/**
 * Rendering-only identity for circular hazards. Combat rules remain in boss
 * mechanics; renderers can project this profile without branching on boss id.
 */
export const BOSS_HAZARD_VFX: Record<CircleHazardKind, BossHazardVfxProfile> = {
  venom_pool: {
    warningColor: "#9a54d6",
    activeColor: "#6fca45",
    highlightColor: "#d6ff7d",
    motion: "bubble",
    shape: "orb",
    particleCount: 7,
    height: 0.8,
    spinSpeed: 0.35,
    columnOpacity: 0,
  },
  skyfall: {
    warningColor: "#ff4d42",
    activeColor: "#ff792e",
    highlightColor: "#ffe0a1",
    motion: "fall",
    shape: "crystal",
    particleCount: 6,
    height: 5.2,
    spinSpeed: 0.55,
    columnOpacity: 0.13,
  },
  quake: {
    warningColor: "#ff5549",
    activeColor: "#d64226",
    highlightColor: "#ffd08a",
    motion: "shockwave",
    shape: "crystal",
    particleCount: 8,
    height: 0.75,
    spinSpeed: 0.18,
    columnOpacity: 0,
  },
  lava_pool: {
    warningColor: "#ff6a31",
    activeColor: "#ff3b18",
    highlightColor: "#ffd05a",
    motion: "flame",
    shape: "spike",
    particleCount: 7,
    height: 1.25,
    spinSpeed: 0.28,
    columnOpacity: 0.04,
  },
  stinger_eruption: {
    warningColor: "#ff4b42",
    activeColor: "#cf2442",
    highlightColor: "#ffd2b3",
    motion: "spike",
    shape: "spike",
    particleCount: 7,
    height: 1.75,
    spinSpeed: 0.12,
    columnOpacity: 0,
  },
  hourglass: {
    warningColor: "#ed8b3a",
    activeColor: "#c16a28",
    highlightColor: "#ffe3a3",
    motion: "orbit",
    shape: "crystal",
    particleCount: 8,
    height: 2.2,
    spinSpeed: 1.35,
    columnOpacity: 0.1,
  },
  tidal_burst: {
    warningColor: "#36cae2",
    activeColor: "#178fc6",
    highlightColor: "#c9fbff",
    motion: "surge",
    shape: "orb",
    particleCount: 8,
    height: 1.65,
    spinSpeed: 0.75,
    columnOpacity: 0.08,
  },
  soul_rift: {
    warningColor: "#aa78ff",
    activeColor: "#6f42cf",
    highlightColor: "#ebd8ff",
    motion: "orbit",
    shape: "orb",
    particleCount: 8,
    height: 2.45,
    spinSpeed: 1.65,
    columnOpacity: 0.14,
  },
  crownfall: {
    warningColor: "#e7c94d",
    activeColor: "#d95331",
    highlightColor: "#fff1a8",
    motion: "fall",
    shape: "crystal",
    particleCount: 7,
    height: 5.6,
    spinSpeed: -0.65,
    columnOpacity: 0.15,
  },
  royal_shockwave: {
    warningColor: "#edcb55",
    activeColor: "#c94631",
    highlightColor: "#fff0a6",
    motion: "shockwave",
    shape: "crystal",
    particleCount: 9,
    height: 0.85,
    spinSpeed: -0.22,
    columnOpacity: 0,
  },
};

export function bossHazardVfxProfile(kind: CircleHazardKind) {
  return BOSS_HAZARD_VFX[kind];
}

export function bossHazardVfxSeed(id: string) {
  let hash = 2166136261;
  for (let index = 0; index < id.length; index += 1) {
    hash ^= id.charCodeAt(index);
    hash = Math.imul(hash, 16777619);
  }
  return (hash >>> 0) / 0xffffffff;
}
