Take the icon sheet's base-forme slots from a generated dex table

ps-pokemon.sheet.mjs reads entry.num out of data/species.json to place a
base species on the sheet, which is the last thing in the build that
needs a number from that table. Move it to ps-pokemon.dexnums.mjs,
generated from pokemon-showdown alongside the hand-kept alt-forme index
table the file already carries.

The sheet is nameSensitive and rebuilt: pokemonicons-sheet.png hashes
the same before and after, and all three deploys materialize byte for
byte identically.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MQicnpaee6kQXGG7uVExLS
This commit is contained in:
Christopher Monsanto
2026-08-21 02:31:43 -04:00
parent a282c8a643
commit ded9d487d0
4 changed files with 1167 additions and 2 deletions

View File

@@ -0,0 +1,36 @@
import {createRequire} from 'node:module';
import * as path from 'node:path';
// Regenerates ps-pokemon.dexnums.mjs from a pokemon-showdown checkout:
//
// node tools/spritedata/dexnums.ts ~/smogon/pokemon-showdown > ps-pokemon.dexnums.mjs
//
// The PS icon sheet puts a base species at the slot named by its dex number,
// and only alt formes need the hand-kept index table in ps-pokemon.sheet.mjs.
type PokedexEntry = {
num: number,
name: string,
baseSpecies?: string
};
let ps = process.argv[2];
if (!ps) {
throw new Error('usage: node tools/spritedata/dexnums.ts <pokemon-showdown checkout>');
}
let require = createRequire(import.meta.url);
let {Pokedex} = require(path.resolve(ps, 'dist/data/pokedex.js')) as
{Pokedex: Record<string, PokedexEntry>};
let out = '';
out += '// Generated by tools/spritedata/dexnums.ts; do not edit.\n';
out += '// PS id of every base species -> its national dex number.\n\n';
out += 'export const DEX_NUMS = {\n';
for (let {num, name, baseSpecies} of Object.values(Pokedex)) {
if (baseSpecies) continue;
out += `\t${name.toLowerCase().replace(/[^a-z0-9]+/g, '')}: ${num},\n`;
}
out += '};\n';
process.stdout.write(out);