Add pokedex-mini autoupdate script

This commit is contained in:
Guangcong Luo
2016-11-29 18:21:26 -05:00
parent 4f3656d386
commit d1e2f50e65

50
githooks/build-minidex Executable file
View 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);