mirror of
https://github.com/smogon/sprites.git
synced 2026-09-27 11:47:45 -05:00
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:
1125
ps-pokemon.dexnums.mjs
Normal file
1125
ps-pokemon.dexnums.mjs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -4,6 +4,8 @@ import path from 'path';
|
||||
import * as spritedata from '@smogon/sprite-data/index.ts';
|
||||
import root from '@smogon/sprite-root/index.ts';
|
||||
|
||||
import {DEX_NUMS} from './ps-pokemon.dexnums.mjs';
|
||||
|
||||
const srcDir = path.join(root, "src");
|
||||
const spritesDir = path.join(srcDir, "minisprites/pokemon/gen6");
|
||||
|
||||
@@ -687,8 +689,10 @@ for (const name of fs.readdirSync(spritesDir)) {
|
||||
}
|
||||
|
||||
if (index === undefined) {
|
||||
// A base species sits at the slot named by its dex number; only alt
|
||||
// formes need the hand-kept table above.
|
||||
if (entry && !entry.forme) {
|
||||
index = entry.num;
|
||||
index = DEX_NUMS[toPSID(entry.base)];
|
||||
} else {
|
||||
errors.push(`can't find ${name}`);
|
||||
continue;
|
||||
|
||||
@@ -22,7 +22,7 @@ let sheetDeps = [
|
||||
rule('ps-pokemon.sheet.mjs', {
|
||||
display: 'ps pokemon sheet',
|
||||
nameSensitive: true,
|
||||
deps: ['src/minisprites/pokemon/gen6/*', ...sheetDeps],
|
||||
deps: ['src/minisprites/pokemon/gen6/*', 'ps-pokemon.dexnums.mjs', ...sheetDeps],
|
||||
cmds: ['node tools/sheet/index.ts %f %o', compresspng({config: 'SPRITESHEET'})],
|
||||
}, 'pokemonicons-sheet.png');
|
||||
|
||||
|
||||
36
tools/spritedata/dexnums.ts
Normal file
36
tools/spritedata/dexnums.ts
Normal 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);
|
||||
Reference in New Issue
Block a user