import { spellDifficultyFromTier } from "../spells/constants.js"; /** * @typedef {object} SpellDefinition * @property {string} spellId * @property {string} displayName * @property {number} tier Spell tier (sets difficulty and cast flash radius) * @property {import("../combat/magic.js").SpellElement} [element] * @property {"tile"|"entity"} target * @property {boolean} [autoRepeat] Auto-cast repeats while target stays in range * @property {number} [minMagicLevel] Minimum Magic level to cast / favourite * @property {string} description In-world spell description * @property {string} [projectileSprite] fx:projectile:spell-* base name * @property {string} [effect] Server impact kind (defaults to spellId) * @property {boolean} [starter] Known by default; no spellbook required */ export const SpellId = Object.freeze({ light: "light", dark: "dark", spark: "spark", firebolt: "firebolt", fireball: "fireball", blaze: "blaze", inferno: "inferno", hellfire: "hellfire", poison: "poison", drain: "drain", tinders: "tinders", shade: "shade", revitalize: "revitalize" }); /** @type {Record} */ export const SPELL_DEFINITIONS = Object.freeze({ [SpellId.light]: Object.freeze({ spellId: SpellId.light, displayName: "Light", tier: 1, element: "none", target: "tile", autoRepeat: false, minMagicLevel: 1, starter: true, projectileSprite: "fx:projectile:spell-light", effect: "light", description: "A whisper of radiance that settles on stone or grass, holding back the dark for a while." }), [SpellId.dark]: Object.freeze({ spellId: SpellId.dark, displayName: "Dark", tier: 2, element: "dark", target: "tile", autoRepeat: false, minMagicLevel: 2, projectileSprite: "fx:projectile:spell-light", effect: "dark", description: "A pool of shadow that drinks the light from a place, leaving the air thick and dim." }), [SpellId.spark]: Object.freeze({ spellId: SpellId.spark, displayName: "Spark", tier: 2, element: "fire", target: "entity", autoRepeat: true, minMagicLevel: 2, projectileSprite: "fx:projectile:spell-spark", effect: "damage", description: "A snapping mote of flame that leaps at a foe and bites on arrival." }), [SpellId.firebolt]: Object.freeze({ spellId: SpellId.firebolt, displayName: "Firebolt", tier: 3, element: "fire", target: "entity", autoRepeat: true, minMagicLevel: 3, projectileSprite: "fx:projectile:spell-spark", effect: "damage", description: "A fierce bolt of fire that streaks toward a foe and scorches on impact." }), [SpellId.fireball]: Object.freeze({ spellId: SpellId.fireball, displayName: "Fireball", tier: 4, element: "fire", target: "entity", autoRepeat: true, minMagicLevel: 4, projectileSprite: "fx:projectile:spell-spark", effect: "damage", description: "A roaring sphere of flame that bursts against whatever it strikes." }), [SpellId.blaze]: Object.freeze({ spellId: SpellId.blaze, displayName: "Blaze", tier: 5, element: "fire", target: "entity", autoRepeat: true, minMagicLevel: 5, projectileSprite: "fx:projectile:spell-spark", effect: "damage", description: "A searing tongue of fire that clings to flesh and armour alike." }), [SpellId.inferno]: Object.freeze({ spellId: SpellId.inferno, displayName: "Inferno", tier: 6, element: "fire", target: "entity", autoRepeat: true, minMagicLevel: 6, projectileSprite: "fx:projectile:spell-spark", effect: "damage", description: "A storm of fire that overwhelms a foe in a rush of heat and ash." }), [SpellId.hellfire]: Object.freeze({ spellId: SpellId.hellfire, displayName: "Hellfire", tier: 7, element: "fire", target: "entity", autoRepeat: true, minMagicLevel: 7, projectileSprite: "fx:projectile:spell-spark", effect: "damage", description: "The deepest flame, white-hot and merciless, called down upon a single mark." }), [SpellId.poison]: Object.freeze({ spellId: SpellId.poison, displayName: "Poison", tier: 3, element: "earth", target: "entity", autoRepeat: true, minMagicLevel: 3, projectileSprite: "fx:projectile:spell-spark", effect: "poison", description: "A venomous curse that sinks in without a wound, then eats at the body over time." }), [SpellId.drain]: Object.freeze({ spellId: SpellId.drain, displayName: "Drain", tier: 4, element: "dark", target: "entity", autoRepeat: true, minMagicLevel: 4, projectileSprite: "fx:projectile:spell-light", effect: "drain", description: "A hunger that saps a foe's wind, leaving them gasping and slow to recover." }), [SpellId.tinders]: Object.freeze({ spellId: SpellId.tinders, displayName: "Tinders", tier: 3, element: "fire", target: "tile", autoRepeat: false, minMagicLevel: 3, projectileSprite: "fx:projectile:spell-spark", effect: "tinders", description: "Sparks of will that can coax logs into flame or sear raw meat as a cookfire would." }), [SpellId.shade]: Object.freeze({ spellId: SpellId.shade, displayName: "Shade", tier: 6, element: "dark", target: "tile", autoRepeat: false, minMagicLevel: 6, projectileSprite: "fx:projectile:spell-light", effect: "shade", description: "A summoned shadow that fights beside you until the magic frays." }), [SpellId.revitalize]: Object.freeze({ spellId: SpellId.revitalize, displayName: "Revitalize", tier: 5, element: "holy", target: "entity", autoRepeat: false, minMagicLevel: 5, projectileSprite: "fx:projectile:spell-light", effect: "revitalize", description: "A gentle current of life that mends wounds one breath at a time." }) }); export function spellDefinition (spellId) { return SPELL_DEFINITIONS[spellId] ?? null; } export function spellDifficulty (spellDef) { return spellDifficultyFromTier(spellDef?.tier ?? 1); } /** Spells that are not starter knowledge and need a spellbook to learn. */ export function learnableSpellIds () { return Object.values(SPELL_DEFINITIONS) .filter((def) => !def.starter) .map((def) => def.spellId); }