sprites/ps-pokemon.sheet.mjs
2023-09-17 15:21:33 -04:00

629 lines
15 KiB
JavaScript

import fs from 'fs';
import path from 'path';
import * as spritedata from '@smogon/sprite-data';
import root from '@smogon/sprite-root';
const srcDir = path.join(root, "src");
const spritesDir = path.join(srcDir, "minisprites/pokemon/gen6");
function toPSID(name) {
return name.toLowerCase().replace(/[^a-z0-9]+/g, '');
}
// Derived from pokemon-showdown-client/src/battle-dex-data.ts
const BattlePokemonIconIndexes = {
unknown: 0,
// alt forms
egg: 1020 + 1,
pikachubelle: 1020 + 2,
pikachulibre: 1020 + 3,
pikachuphd: 1020 + 4,
pikachupopstar: 1020 + 5,
pikachurockstar: 1020 + 6,
pikachucosplay: 1020 + 7,
unownexclamation: 1020 + 8,
unownquestion: 1020 + 9,
unownb: 1020 + 10,
unownc: 1020 + 11,
unownd: 1020 + 12,
unowne: 1020 + 13,
unownf: 1020 + 14,
unowng: 1020 + 15,
unownh: 1020 + 16,
unowni: 1020 + 17,
unownj: 1020 + 18,
unownk: 1020 + 19,
unownl: 1020 + 20,
unownm: 1020 + 21,
unownn: 1020 + 22,
unowno: 1020 + 23,
unownp: 1020 + 24,
unownq: 1020 + 25,
unownr: 1020 + 26,
unowns: 1020 + 27,
unownt: 1020 + 28,
unownu: 1020 + 29,
unownv: 1020 + 30,
unownw: 1020 + 31,
unownx: 1020 + 32,
unowny: 1020 + 33,
unownz: 1020 + 34,
castformrainy: 1020 + 35,
castformsnowy: 1020 + 36,
castformsunny: 1020 + 37,
deoxysattack: 1020 + 38,
deoxysdefense: 1020 + 39,
deoxysspeed: 1020 + 40,
burmysandy: 1020 + 41,
burmytrash: 1020 + 42,
wormadamsandy: 1020 + 43,
wormadamtrash: 1020 + 44,
cherrimsunshine: 1020 + 45,
shelloseast: 1020 + 46,
gastrodoneast: 1020 + 47,
rotomfan: 1020 + 48,
rotomfrost: 1020 + 49,
rotomheat: 1020 + 50,
rotommow: 1020 + 51,
rotomwash: 1020 + 52,
giratinaorigin: 1020 + 53,
shayminsky: 1020 + 54,
unfezantf: 1020 + 55,
basculinbluestriped: 1020 + 56,
darmanitanzen: 1020 + 57,
deerlingautumn: 1020 + 58,
deerlingsummer: 1020 + 59,
deerlingwinter: 1020 + 60,
sawsbuckautumn: 1020 + 61,
sawsbucksummer: 1020 + 62,
sawsbuckwinter: 1020 + 63,
frillishf: 1020 + 64,
jellicentf: 1020 + 65,
tornadustherian: 1020 + 66,
thundurustherian: 1020 + 67,
landorustherian: 1020 + 68,
kyuremblack: 1020 + 69,
kyuremwhite: 1020 + 70,
keldeoresolute: 1020 + 71,
meloettapirouette: 1020 + 72,
vivillonarchipelago: 1020 + 73,
vivilloncontinental: 1020 + 74,
vivillonelegant: 1020 + 75,
vivillonfancy: 1020 + 76,
vivillongarden: 1020 + 77,
vivillonhighplains: 1020 + 78,
vivillonicysnow: 1020 + 79,
vivillonjungle: 1020 + 80,
vivillonmarine: 1020 + 81,
vivillonmodern: 1020 + 82,
vivillonmonsoon: 1020 + 83,
vivillonocean: 1020 + 84,
vivillonpokeball: 1020 + 85,
vivillonpolar: 1020 + 86,
vivillonriver: 1020 + 87,
vivillonsandstorm: 1020 + 88,
vivillonsavanna: 1020 + 89,
vivillonsun: 1020 + 90,
vivillontundra: 1020 + 91,
pyroarf: 1020 + 92,
flabebeblue: 1020 + 93,
flabebeorange: 1020 + 94,
flabebewhite: 1020 + 95,
flabebeyellow: 1020 + 96,
floetteblue: 1020 + 97,
floetteeternal: 1020 + 98,
floetteorange: 1020 + 99,
floettewhite: 1020 + 100,
floetteyellow: 1020 + 101,
florgesblue: 1020 + 102,
florgesorange: 1020 + 103,
florgeswhite: 1020 + 104,
florgesyellow: 1020 + 105,
furfroudandy: 1020 + 106,
furfroudebutante: 1020 + 107,
furfroudiamond: 1020 + 108,
furfrouheart: 1020 + 109,
furfroukabuki: 1020 + 110,
furfroulareine: 1020 + 111,
furfroumatron: 1020 + 112,
furfroupharaoh: 1020 + 113,
furfroustar: 1020 + 114,
meowsticf: 1020 + 115,
aegislashblade: 1020 + 116,
xerneasneutral: 1020 + 117,
hoopaunbound: 1020 + 118,
rattataalola: 1020 + 119,
raticatealola: 1020 + 120,
raichualola: 1020 + 121,
sandshrewalola: 1020 + 122,
sandslashalola: 1020 + 123,
vulpixalola: 1020 + 124,
ninetalesalola: 1020 + 125,
diglettalola: 1020 + 126,
dugtrioalola: 1020 + 127,
meowthalola: 1020 + 128,
persianalola: 1020 + 129,
geodudealola: 1020 + 130,
graveleralola: 1020 + 131,
golemalola: 1020 + 132,
grimeralola: 1020 + 133,
mukalola: 1020 + 134,
exeggutoralola: 1020 + 135,
marowakalola: 1020 + 136,
greninjaash: 1020 + 137,
zygarde10: 1020 + 138,
zygardecomplete: 1020 + 139,
oricoriopompom: 1020 + 140,
oricoriopau: 1020 + 141,
oricoriosensu: 1020 + 142,
lycanrocmidnight: 1020 + 143,
wishiwashischool: 1020 + 144,
miniormeteor: 1020 + 145,
miniororange: 1020 + 146,
minioryellow: 1020 + 147,
miniorgreen: 1020 + 148,
miniorblue: 1020 + 149,
miniorindigo: 1020 + 150,
miniorviolet: 1020 + 151,
magearnaoriginal: 1020 + 152,
pikachuoriginal: 1020 + 153,
pikachuhoenn: 1020 + 154,
pikachusinnoh: 1020 + 155,
pikachuunova: 1020 + 156,
pikachukalos: 1020 + 157,
pikachualola: 1020 + 158,
pikachupartner: 1020 + 159,
lycanrocdusk: 1020 + 160,
necrozmaduskmane: 1020 + 161,
necrozmadawnwings: 1020 + 162,
necrozmaultra: 1020 + 163,
pikachustarter: 1020 + 164,
eeveestarter: 1020 + 165,
meowthgalar: 1020 + 166,
ponytagalar: 1020 + 167,
rapidashgalar: 1020 + 168,
farfetchdgalar: 1020 + 169,
weezinggalar: 1020 + 170,
mrmimegalar: 1020 + 171,
corsolagalar: 1020 + 172,
zigzagoongalar: 1020 + 173,
linoonegalar: 1020 + 174,
darumakagalar: 1020 + 175,
darmanitangalar: 1020 + 176,
darmanitangalarzen: 1020 + 177,
yamaskgalar: 1020 + 178,
stunfiskgalar: 1020 + 179,
cramorantgulping: 1020 + 180,
cramorantgorging: 1020 + 181,
toxtricitylowkey: 1020 + 182,
alcremierubycream: 1020 + 183,
alcremiematchacream: 1020 + 184,
alcremiemintcream: 1020 + 185,
alcremielemoncream: 1020 + 186,
alcremiesaltedcream: 1020 + 187,
alcremierubyswirl: 1020 + 188,
alcremiecaramelswirl: 1020 + 189,
alcremierainbowswirl: 1020 + 190,
eiscuenoice: 1020 + 191,
indeedeef: 1020 + 192,
morpekohangry: 1020 + 193,
zaciancrowned: 1020 + 194,
zamazentacrowned: 1020 + 195,
slowpokegalar: 1020 + 196,
slowbrogalar: 1020 + 197,
zarudedada: 1020 + 198,
pikachuworld: 1020 + 199,
articunogalar: 1020 + 200,
zapdosgalar: 1020 + 201,
moltresgalar: 1020 + 202,
slowkinggalar: 1020 + 203,
calyrexice: 1020 + 204,
calyrexshadow: 1020 + 205,
growlithehisui: 1020 + 206,
arcaninehisui: 1020 + 207,
voltorbhisui: 1020 + 208,
electrodehisui: 1020 + 209,
typhlosionhisui: 1020 + 210,
qwilfishhisui: 1020 + 211,
sneaselhisui: 1020 + 212,
samurotthisui: 1020 + 213,
lilliganthisui: 1020 + 214,
zoruahisui: 1020 + 215,
zoroarkhisui: 1020 + 216,
braviaryhisui: 1020 + 217,
sliggoohisui: 1020 + 218,
goodrahisui: 1020 + 219,
avalugghisui: 1020 + 220,
decidueyehisui: 1020 + 221,
basculegionf: 1020 + 222,
enamorustherian: 1020 + 223,
taurospaldeacombat: 1020 + 224,
taurospaldeablaze: 1020 + 225,
taurospaldeaaqua: 1020 + 226,
wooperpaldea: 1020 + 227,
oinkolognef: 1020 + 228,
palafinhero: 1020 + 229,
mausholdfour: 1020 + 230,
tatsugiridroopy: 1020 + 231,
tatsugiristretchy: 1020 + 232,
squawkabillyblue: 1020 + 233,
squawkabillyyellow: 1020 + 234,
squawkabillywhite: 1020 + 235,
gimmighoulroaming: 1020 + 236,
dialgaorigin: 1020 + 237,
palkiaorigin: 1020 + 238,
basculinwhitestriped: 1020 + 239,
ursalunabloodmoon: 1020 + 240,
ogerponwellspring: 1020 + 241,
ogerponhearthflame: 1020 + 242,
ogerponcornerstone: 1020 + 243,
// alt forms with duplicate icons
/* greninjabond: 658,
gumshoostotem: 735,
raticatealolatotem: 1020 + 120,
marowakalolatotem: 1020 + 136,
araquanidtotem: 752,
lurantistotem: 754,
salazzletotem: 758,
vikavolttotem: 738,
togedemarutotem: 777,
mimikyutotem: 778,
mimikyubustedtotem: 778,
ribombeetotem: 743,
kommoototem: 784,
sinisteaantique: 854,
polteageistantique: 855,
poltchageistartisan: 1012,
sinistchamasterpiece: 1013,
ogerpontealtera: 1017,
ogerponwellspringtera: 1020 + 241,
ogerponhearthflametera: 1020 + 242,
ogerponcornerstonetera: 1020 + 243,
toxtricitylowkeygmax: 1272 + 69, */
// Mega/G-Max
venusaurmega: 1272 + 0,
charizardmegax: 1272 + 1,
charizardmegay: 1272 + 2,
blastoisemega: 1272 + 3,
beedrillmega: 1272 + 4,
pidgeotmega: 1272 + 5,
alakazammega: 1272 + 6,
slowbromega: 1272 + 7,
gengarmega: 1272 + 8,
kangaskhanmega: 1272 + 9,
pinsirmega: 1272 + 10,
gyaradosmega: 1272 + 11,
aerodactylmega: 1272 + 12,
mewtwomegax: 1272 + 13,
mewtwomegay: 1272 + 14,
ampharosmega: 1272 + 15,
steelixmega: 1272 + 16,
scizormega: 1272 + 17,
heracrossmega: 1272 + 18,
houndoommega: 1272 + 19,
tyranitarmega: 1272 + 20,
sceptilemega: 1272 + 21,
blazikenmega: 1272 + 22,
swampertmega: 1272 + 23,
gardevoirmega: 1272 + 24,
sableyemega: 1272 + 25,
mawilemega: 1272 + 26,
aggronmega: 1272 + 27,
medichammega: 1272 + 28,
manectricmega: 1272 + 29,
sharpedomega: 1272 + 30,
cameruptmega: 1272 + 31,
altariamega: 1272 + 32,
banettemega: 1272 + 33,
absolmega: 1272 + 34,
glaliemega: 1272 + 35,
salamencemega: 1272 + 36,
metagrossmega: 1272 + 37,
latiasmega: 1272 + 38,
latiosmega: 1272 + 39,
kyogreprimal: 1272 + 40,
groudonprimal: 1272 + 41,
rayquazamega: 1272 + 42,
lopunnymega: 1272 + 43,
garchompmega: 1272 + 44,
lucariomega: 1272 + 45,
abomasnowmega: 1272 + 46,
gallademega: 1272 + 47,
audinomega: 1272 + 48,
dianciemega: 1272 + 49,
charizardgmax: 1272 + 50,
butterfreegmax: 1272 + 51,
pikachugmax: 1272 + 52,
meowthgmax: 1272 + 53,
machampgmax: 1272 + 54,
gengargmax: 1272 + 55,
kinglergmax: 1272 + 56,
laprasgmax: 1272 + 57,
eeveegmax: 1272 + 58,
snorlaxgmax: 1272 + 59,
garbodorgmax: 1272 + 60,
melmetalgmax: 1272 + 61,
corviknightgmax: 1272 + 62,
orbeetlegmax: 1272 + 63,
drednawgmax: 1272 + 64,
coalossalgmax: 1272 + 65,
flapplegmax: 1272 + 66,
appletungmax: 1272 + 67,
sandacondagmax: 1272 + 68,
toxtricitygmax: 1272 + 69,
centiskorchgmax: 1272 + 70,
hatterenegmax: 1272 + 71,
grimmsnarlgmax: 1272 + 72,
alcremiegmax: 1272 + 73,
copperajahgmax: 1272 + 74,
duraludongmax: 1272 + 75,
eternatuseternamax: 1272 + 76,
venusaurgmax: 1272 + 77,
blastoisegmax: 1272 + 78,
rillaboomgmax: 1272 + 79,
cinderacegmax: 1272 + 80,
inteleongmax: 1272 + 81,
urshifugmax: 1272 + 82,
urshifurapidstrikegmax: 1272 + 83,
// CAP
syclant: 1464 + 0,
revenankh: 1464 + 1,
pyroak: 1464 + 2,
fidgit: 1464 + 3,
stratagem: 1464 + 4,
arghonaut: 1464 + 5,
kitsunoh: 1464 + 6,
cyclohm: 1464 + 7,
colossoil: 1464 + 8,
krilowatt: 1464 + 9,
voodoom: 1464 + 10,
tomohawk: 1464 + 11,
necturna: 1464 + 12,
mollux: 1464 + 13,
aurumoth: 1464 + 14,
malaconda: 1464 + 15,
cawmodore: 1464 + 16,
volkraken: 1464 + 17,
plasmanta: 1464 + 18,
naviathan: 1464 + 19,
crucibelle: 1464 + 20,
crucibellemega: 1464 + 21,
kerfluffle: 1464 + 22,
pajantom: 1464 + 23,
jumbao: 1464 + 24,
caribolt: 1464 + 25,
smokomodo: 1464 + 26,
snaelstrom: 1464 + 27,
equilibra: 1464 + 28,
astrolotl: 1464 + 29,
miasmaw: 1464 + 30,
chromera: 1464 + 31,
venomicon: 1464 + 32,
venomiconepilogue: 1464 + 33,
saharaja: 1464 + 34,
hemogoblin: 1464 + 35,
// CAP prevos
syclar: 1500 + 0,
embirch: 1500 + 1,
flarelm: 1500 + 2,
breezi: 1500 + 3,
scratchet: 1500 + 4,
necturine: 1500 + 5,
cupra: 1500 + 6,
argalis: 1500 + 7,
brattler: 1500 + 8,
cawdet: 1500 + 9,
volkritter: 1500 + 10,
snugglow: 1500 + 11,
floatoy: 1500 + 12,
caimanoe: 1500 + 13,
pluffle: 1500 + 14,
rebble: 1500 + 15,
tactite: 1500 + 16,
privatyke: 1500 + 17,
nohface: 1500 + 18,
monohm: 1500 + 19,
duohm: 1500 + 20,
protowatt: 1500 + 21,
voodoll: 1500 + 22,
mumbao: 1500 + 23,
fawnifer: 1500 + 24,
electrelk: 1500 + 25,
smogecko: 1500 + 26,
smoguana: 1500 + 27,
swirlpool: 1500 + 28,
coribalis: 1500 + 29,
justyke: 1500 + 30,
solotl: 1500 + 31,
miasmite: 1500 + 32,
dorsoil: 1500 + 33,
saharascal: 1500 + 34,
ababo: 1500 + 35,
scattervein: 1500 + 36,
};
const BattlePokemonIconIndexesLeft = {
pikachubelle: 1344 + 0,
pikachupopstar: 1344 + 1,
clefairy: 1344 + 2,
clefable: 1344 + 3,
jigglypuff: 1344 + 4,
wigglytuff: 1344 + 5,
dugtrioalola: 1344 + 6,
poliwhirl: 1344 + 7,
poliwrath: 1344 + 8,
mukalola: 1344 + 9,
kingler: 1344 + 10,
croconaw: 1344 + 11,
cleffa: 1344 + 12,
igglybuff: 1344 + 13,
politoed: 1344 + 14,
unownb: 1344 + 15,
unownc: 1344 + 16,
unownd: 1344 + 17,
unowne: 1344 + 18,
unownf: 1344 + 19,
unowng: 1344 + 20,
unownh: 1344 + 21,
unownj: 1344 + 22,
unownk: 1344 + 23,
unownl: 1344 + 24,
unownm: 1344 + 25,
unownn: 1344 + 26,
unownp: 1344 + 27,
unownq: 1344 + 28,
unownquestion: 1344 + 29,
unownr: 1344 + 30,
unowns: 1344 + 31,
unownt: 1344 + 32,
unownv: 1344 + 33,
unownz: 1344 + 34,
sneasel: 1344 + 35,
teddiursa: 1344 + 36,
roselia: 1344 + 37,
zangoose: 1344 + 38,
seviper: 1344 + 39,
castformsnowy: 1344 + 40,
absolmega: 1344 + 41,
absol: 1344 + 42,
regirock: 1344 + 43,
torterra: 1344 + 44,
budew: 1344 + 45,
roserade: 1344 + 46,
magmortar: 1344 + 47,
togekiss: 1344 + 48,
rotomwash: 1344 + 49,
shayminsky: 1344 + 50,
emboar: 1344 + 51,
pansear: 1344 + 52,
simisear: 1344 + 53,
drilbur: 1344 + 54,
excadrill: 1344 + 55,
sawk: 1344 + 56,
lilligant: 1344 + 57,
garbodor: 1344 + 58,
solosis: 1344 + 59,
vanilluxe: 1344 + 60,
amoonguss: 1344 + 61,
klink: 1344 + 62,
klang: 1344 + 63,
klinklang: 1344 + 64,
litwick: 1344 + 65,
golett: 1344 + 66,
golurk: 1344 + 67,
kyuremblack: 1344 + 68,
kyuremwhite: 1344 + 69,
kyurem: 1344 + 70,
keldeoresolute: 1344 + 71,
meloetta: 1344 + 72,
greninja: 1344 + 73,
greninjaash: 1344 + 74,
furfroudebutante: 1344 + 75,
barbaracle: 1344 + 76,
clauncher: 1344 + 77,
clawitzer: 1344 + 78,
sylveon: 1344 + 79,
klefki: 1344 + 80,
zygarde: 1344 + 81,
zygarde10: 1344 + 82,
zygardecomplete: 1344 + 83,
dartrix: 1344 + 84,
steenee: 1344 + 85,
tsareena: 1344 + 86,
comfey: 1344 + 87,
miniormeteor: 1344 + 88,
minior: 1344 + 89,
miniororange: 1344 + 90,
minioryellow: 1344 + 91,
miniorgreen: 1344 + 92,
miniorblue: 1344 + 93,
miniorviolet: 1344 + 94,
miniorindigo: 1344 + 95,
dhelmise: 1344 + 96,
necrozma: 1344 + 97,
marshadow: 1344 + 98,
pikachuoriginal: 1344 + 99,
pikachupartner: 1344 + 100,
necrozmaduskmane: 1344 + 101,
necrozmadawnwings: 1344 + 102,
necrozmaultra: 1344 + 103,
stakataka: 1344 + 104,
blacephalon: 1344 + 105,
};
const entries = [];
let errors = [];
// Need to figure out how to remove this readdir; tup doesn't like it
for (const name of fs.readdirSync(spritesDir)) {
const parsed = path.parse(name);
const sn = spritedata.parseFilename(parsed.name);
let entry;
if (!sn.extension) {
entry = spritedata.get(sn.id);
}
let id = toPSID(entry ? entry.base + entry.forme : sn.name);
if (sn.extra.has("f")) id += 'f';
if (sn.extra.has("g")) id += 'gmax';
let index;
if (sn.extra.has("a")) {
index = BattlePokemonIconIndexesLeft[id];
BattlePokemonIconIndexesLeft[id] = 'found';
} else {
index = BattlePokemonIconIndexes[id];
BattlePokemonIconIndexes[id] = 'found';
}
if (index === undefined) {
if (entry) {
index = entry.num;
} else {
errors.push(`can't find ${name}`);
continue;
}
}
entries[index] = path.join(spritesDir, name);
}
for (const [id, num] of Object.entries(BattlePokemonIconIndexes)) {
if (num !== 'found') {
errors.push(`didn't find ${id}`);
}
}
for (const [id, num] of Object.entries(BattlePokemonIconIndexesLeft)) {
if (num !== 'found') {
errors.push(`didn't find left ${id}`);
}
}
if (errors.length) {
for (let error of errors) {
console.error(error);
}
process.exit(1);
}
for (let i = 0; i < entries.length; i++) {
if (entries[i] === undefined)
entries[i] = null;
}
export default {
width: 40,
height: 30,
tile: 12,
entries
};