| 1 | import { spellDifficultyFromTier } from "../spells/constants.js"; |
| 2 | |
| 3 | /** |
| 4 | * @typedef {object} SpellDefinition |
| 5 | * @property {string} spellId |
| 6 | * @property {string} displayName |
| 7 | * @property {number} tier Spell tier (sets difficulty and cast flash radius) |
| 8 | * @property {import("../combat/magic.js").SpellElement} [element] |
| 9 | * @property {"tile"|"entity"} target |
| 10 | * @property {boolean} [autoRepeat] Auto-cast repeats while target stays in range |
| 11 | * @property {number} [minMagicLevel] Minimum Magic level to cast / favourite |
| 12 | * @property {string} description In-world spell description |
| 13 | * @property {string} [projectileSprite] fx:projectile:spell-* base name |
| 14 | */ |
| 15 | |
| 16 | export const SpellId = Object.freeze({ |
| 17 | light: "light", |
| 18 | spark: "spark" |
| 19 | }); |
| 20 | |
| 21 | /** @type {Record<string, SpellDefinition>} */ |
| 22 | export const SPELL_DEFINITIONS = Object.freeze({ |
| 23 | [SpellId.light]: Object.freeze({ |
| 24 | spellId: SpellId.light, |
| 25 | displayName: "Light", |
| 26 | tier: 1, |
| 27 | element: "none", |
| 28 | target: "tile", |
| 29 | autoRepeat: false, |
| 30 | minMagicLevel: 1, |
| 31 | projectileSprite: "fx:projectile:spell-light", |
| 32 | description: "A whisper of radiance that settles on stone or grass, holding back the dark for a while." |
| 33 | }), |
| 34 | [SpellId.spark]: Object.freeze({ |
| 35 | spellId: SpellId.spark, |
| 36 | displayName: "Spark", |
| 37 | tier: 2, |
| 38 | element: "fire", |
| 39 | target: "entity", |
| 40 | autoRepeat: true, |
| 41 | minMagicLevel: 2, |
| 42 | projectileSprite: "fx:projectile:spell-spark", |
| 43 | description: "A snapping mote of flame that leaps at a foe and bites on arrival." |
| 44 | }) |
| 45 | }); |
| 46 | |
| 47 | export function spellDefinition (spellId) |
| 48 | { |
| 49 | return SPELL_DEFINITIONS[spellId] ?? null; |
| 50 | } |
| 51 | |
| 52 | export function spellDifficulty (spellDef) |
| 53 | { |
| 54 | return spellDifficultyFromTier(spellDef?.tier ?? 1); |
| 55 | } |