mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-04-26 10:14:50 -05:00
Files meant to be served have been moved into `play.pokemonshowdown.com/` and `pokemonshowdown.com/`. We now have three directories for the three subdomains handled by this repo: - `pokemonshowdown.com/` - `play.pokemonshowdown.com/` - `replay.pokemonshowdown.com/` Naming them after the subdomains will make it much easier to tell where the files for each go. The diff is probably useless; it'll be easier if you just look at the new tree: https://github.com/smogon/pokemon-showdown-client/tree/reorganize
105 lines
2.8 KiB
JavaScript
Executable File
105 lines
2.8 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
'use strict';
|
|
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
process.chdir(path.resolve(__dirname, '../play.pokemonshowdown.com'));
|
|
const imageSize = require('image-size');
|
|
|
|
const Dex = require('./../caches/pokemon-showdown/dist/sim/dex').Dex;
|
|
const toID = Dex.toID;
|
|
|
|
process.stdout.write("Updating animated sprite dimensions... ");
|
|
|
|
let buf = `/*
|
|
DO NOT EDIT
|
|
|
|
THIS FILE IS AUTOGENERATED BY ./build-tools/build-minidex
|
|
*/
|
|
|
|
exports.BattlePokemonSprites = {
|
|
substitute:{exists:false, front:{w:34, h:39}, back:{w:37, h:38}},
|
|
`;
|
|
|
|
|
|
let g5buf = `/*
|
|
DO NOT EDIT
|
|
|
|
THIS FILE IS AUTOGENERATED BY ./build-tools/build-minidex
|
|
*/
|
|
|
|
exports.BattlePokemonSpritesBW = {
|
|
`;
|
|
|
|
function sizeObj(path) {
|
|
try {
|
|
let size = imageSize(path);
|
|
return {
|
|
w: size.width,
|
|
h: size.height,
|
|
};
|
|
} catch (e) {}
|
|
}
|
|
|
|
function updateSizes() {
|
|
for (let baseid in Dex.data.Pokedex) {
|
|
let species = Dex.species.get(baseid);
|
|
for (let formeName of [''].concat(species.cosmeticFormes || [])) {
|
|
let spriteid = species.spriteid;
|
|
if (formeName) spriteid += '-' + toID(formeName).slice(species.id.length);
|
|
let id = toID(spriteid);
|
|
|
|
{
|
|
let row = {num: species.num};
|
|
const frontSize = sizeObj('sprites/ani/' + spriteid + '.gif');
|
|
if (frontSize) row.front = frontSize;
|
|
const frontSizeF = sizeObj('sprites/ani/' + spriteid + '-f.gif');
|
|
if (frontSizeF) row.frontf = frontSizeF;
|
|
const backSize = sizeObj('sprites/ani-back/' + spriteid + '.gif');
|
|
if (backSize) row.back = backSize;
|
|
const backSizeF = sizeObj('sprites/ani-back/' + spriteid + '-f.gif');
|
|
if (backSizeF) row.backf = backSizeF;
|
|
if (row.front || row.back || !row.forme) {
|
|
buf += `\t${id}:` + JSON.stringify(row).replace(/"/g, '') + `,\n`;
|
|
}
|
|
}
|
|
|
|
{
|
|
let g5row = {num: species.num};
|
|
const frontSize = sizeObj('sprites/gen5ani/' + spriteid + '.gif');
|
|
if (frontSize) g5row.front = frontSize;
|
|
const frontSizeF = sizeObj('sprites/gen5ani/' + spriteid + '-f.gif');
|
|
if (frontSizeF) g5row.frontf = frontSizeF;
|
|
const backSize = sizeObj('sprites/gen5ani-back/' + spriteid + '.gif');
|
|
if (backSize) g5row.back = backSize;
|
|
const backSizeF = sizeObj('sprites/gen5ani-back/' + spriteid + '-f.gif');
|
|
if (backSizeF) g5row.backf = backSizeF;
|
|
if (g5row.front || g5row.back || !g5row.forme) {
|
|
g5buf += `\t${id}:` + JSON.stringify(g5row).replace(/"/g, '') + `,\n`;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
buf = buf.slice(0, -2) + `
|
|
};
|
|
`;
|
|
g5buf = g5buf.slice(0, -2) + `
|
|
};
|
|
`;
|
|
|
|
fs.writeFileSync('data/pokedex-mini.js', buf);
|
|
fs.writeFileSync('data/pokedex-mini-bw.js', g5buf);
|
|
}
|
|
|
|
if (fs.existsSync('sprites/ani/')) {
|
|
updateSizes();
|
|
console.log('DONE');
|
|
} else {
|
|
try {
|
|
fs.unlinkSync('data/pokedex-mini.js');
|
|
fs.unlinkSync('data/pokedex-mini-bw.js');
|
|
} catch (e) {}
|
|
console.log('SKIPPED');
|
|
}
|