This repository has been archived by the owner on Mar 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
abilities.js
72 lines (58 loc) · 1.48 KB
/
abilities.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const dmg = require('dmgcalc');
const Dex = require('../Pokemon-Showdown/sim/dex');
var equal = require('deep-equal');
const gen = Number(process.argv[2]) || 7;
const previous = dmg.ABILITIES_BY_ID[gen - 1];
const current = dmg.ABILITIES_BY_ID[gen];
const dex = Dex.forFormat('gen' + gen + 'ou');
const oldDex = Dex.forFormat('gen' + (gen - 1) + 'ou');
const requiredKeys = {
id: 1,
name: 1,
num: 1
//gen: 1
};
const optionalKeys = {
desc: 1,
shortDesc: 1,
isNonstandard: 1,
isUnreleased: 1
};
const result = {};
for (let id in current) {
if (id === 'flashfireactivated') continue;
let old = oldDex.getAbility(id);
let val = dex.getAbility(id);
delete val['gen'];
for (let k in val) {
const required = requiredKeys[k];
const optional = optionalKeys[k];
if (!(required || optional)) {
delete val[k];
} else if (required && !val[k]) {
console.error([val, k]);
} else if (optional && !val[k]) {
delete val[k];
}
}
if (!previous[id]) {
val.gen = gen;
result[id] = val;
} else if (!equal(val, old)) {
let patch = {};
for (let k in requiredKeys) {
if (val[k] && !equal(val[k], old[k])) {
patch[k] = val[k];
}
}
for (let k in optionalKeys) {
if (val[k] && !equal(val[k], old[k])) {
patch[k] = val[k];
}
}
if (!(Object.keys(patch).length === 0 && patch.constructor === Object)) {
result[id] = patch;
}
}
}
console.log(JSON.stringify(result, null, 2));