| 1 | #!/usr/bin/env node |
| 2 | /** |
| 3 | * Magenta placeholder projectile art: one PNG per spell under |
| 4 | * client/assets/fx/projectile/spell-<spellId>.png |
| 5 | * |
| 6 | * Magenta (R≈B, G < R) is recolored at runtime via spellProjectileTint(element). |
| 7 | * Replace any file with hand-drawn art; keep magenta for tintable regions. |
| 8 | * |
| 9 | * node client/scripts/write-spell-projectile-template.mjs |
| 10 | */ |
| 11 | import { unlinkSync, existsSync } from "node:fs"; |
| 12 | import { join, dirname } from "node:path"; |
| 13 | import { fileURLToPath } from "node:url"; |
| 14 | import { writeRgbaPng, makeRgba, fillRect } from "../../server/src/assets/placeholderPng.js"; |
| 15 | import { SPELL_DEFINITIONS } from "../../shared/definitions/spells.js"; |
| 16 | |
| 17 | const SIZE = 8; |
| 18 | const OUT_DIR = join(dirname(fileURLToPath(import.meta.url)), "..", "assets", "fx", "projectile"); |
| 19 | |
| 20 | /** Pure magenta mask + a lighter magenta highlight (G channel → white at runtime). */ |
| 21 | const MAGENTA = [220, 0, 220, 255]; |
| 22 | const MAGENTA_HI = [255, 120, 255, 255]; |
| 23 | |
| 24 | const legacy = [ |
| 25 | "spell-light-0.png", |
| 26 | "spell-light-1.png", |
| 27 | "spell-light-2.png", |
| 28 | "spell-spark-0.png", |
| 29 | "spell-spark-1.png", |
| 30 | "spell-spark-2.png" |
| 31 | ]; |
| 32 | for (const name of legacy) |
| 33 | { |
| 34 | const path = join(OUT_DIR, name); |
| 35 | if (existsSync(path)) |
| 36 | { |
| 37 | unlinkSync(path); |
| 38 | console.log(`Removed legacy ${name}`); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | let wrote = 0; |
| 43 | for (const def of Object.values(SPELL_DEFINITIONS)) |
| 44 | { |
| 45 | const file = join(OUT_DIR, `spell-${def.spellId}.png`); |
| 46 | const image = makeRgba(SIZE, SIZE, [0, 0, 0, 0]); |
| 47 | // Diamond body |
| 48 | fillRect(image, 3, 1, 2, 1, MAGENTA); |
| 49 | fillRect(image, 2, 2, 4, 1, MAGENTA); |
| 50 | fillRect(image, 1, 3, 6, 2, MAGENTA); |
| 51 | fillRect(image, 2, 5, 4, 1, MAGENTA); |
| 52 | fillRect(image, 3, 6, 2, 1, MAGENTA); |
| 53 | // Center highlight |
| 54 | fillRect(image, 3, 3, 2, 2, MAGENTA_HI); |
| 55 | writeRgbaPng(file, SIZE, SIZE, image.pixels); |
| 56 | wrote += 1; |
| 57 | } |
| 58 | |
| 59 | console.log(`Wrote ${wrote} magenta spell projectile placeholders in ${OUT_DIR}`); |