mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-10-02 07:42:12 -05:00
Add pokedex-mini autoupdate script
This commit is contained in:
50
githooks/build-minidex
Executable file
50
githooks/build-minidex
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
const fs = require("fs");
|
||||
process.chdir(__dirname);
|
||||
const imageSize = require('image-size');
|
||||
|
||||
const Tools = require('./../data/Pokemon-Showdown/tools').includeData();
|
||||
const toId = Tools.getId;
|
||||
|
||||
let buf = `/*
|
||||
DO NOT EDIT
|
||||
|
||||
THIS FILE IS AUTOGENERATED BY ./githooks/build-minidex
|
||||
*/
|
||||
|
||||
exports.BattlePokemonSprites = {
|
||||
substitute:{exists:false, front:{ani:{w:34, h:39}}, back:{ani:{w:37, h:38}}},
|
||||
`;
|
||||
for (let id in Tools.data.Pokedex) {
|
||||
let template = Tools.getTemplate(id);
|
||||
let row = {num: template.num};
|
||||
try {
|
||||
let size = imageSize('../sprites/xyani/' + template.spriteid + '.gif');
|
||||
row.front = {
|
||||
ani: {
|
||||
w: size.width,
|
||||
h: size.height
|
||||
}
|
||||
};
|
||||
} catch (e) {}
|
||||
try {
|
||||
let size = imageSize('../sprites/xyani-back/' + template.spriteid + '.gif');
|
||||
row.back = {
|
||||
ani: {
|
||||
w: size.width,
|
||||
h: size.height
|
||||
}
|
||||
};
|
||||
} catch (e) {}
|
||||
if (row.num <= 0 || row.front || row.back || !row.forme) {
|
||||
buf += `\t${id}:` + JSON.stringify(row).replace(/"/g, '') + `,\n`;
|
||||
}
|
||||
}
|
||||
|
||||
buf = buf.slice(0, -2) + `
|
||||
};
|
||||
`;
|
||||
|
||||
fs.writeFileSync('../data/pokedex-mini.js', buf);
|
||||
Reference in New Issue
Block a user