-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathexport-learnsets.js
63 lines (56 loc) · 1.72 KB
/
export-learnsets.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
toId = function(text) {
if (text && text.id) text = text.id;
else if (text && text.userid) text = text.userid;
return string(text).toLowerCase().replace(/[^a-z0-9]+/g, '');
};
string = function(str) {
if (typeof str === 'string' || typeof str === 'number') return ''+str;
return '';
}
require("sugar");
fs = require("fs");
fs.exists = require("path").exists;
fs.existsSync = require("path").existsSync;
var LearnsetsG6 = require('./learnsets-g6.js');
var Tools = require('./tools.js');
// A-C, D-I, J-O, P-R, S-Z
var keys = Object.keys(LearnsetsG6).sort();
var buf = '';
var curFile = 'a';
for (var i=0; i<keys.length; i++) {
var key = keys[i];
if (!key) continue;
if (key.charAt(0) === 'd' && curFile === 'a') {
fs.writeFileSync('learnsets-g6/learnsets-g6-A-to-C.txt', buf);
buf = '';
curFile = 'd';
}
if (key.charAt(0) === 'j' && curFile === 'd') {
fs.writeFileSync('learnsets-g6/learnsets-g6-D-to-I.txt', buf);
buf = '';
curFile = 'j';
}
if (key.charAt(0) === 'p' && curFile === 'j') {
fs.writeFileSync('learnsets-g6/learnsets-g6-J-to-O.txt', buf);
buf = '';
curFile = 'p';
}
if (key.charAt(0) === 's' && curFile === 'p') {
fs.writeFileSync('learnsets-g6/learnsets-g6-P-to-R.txt', buf);
buf = '';
curFile = 's';
}
console.log(key.charAt(0)+' '+curFile);
buf += '== '+Tools.getTemplate(key).name+' ==\n\n';
for (var j in LearnsetsG6[key].level) {
buf += 'L? - '+Tools.getMove(LearnsetsG6[key].level[j]).name+'\n';
}
for (var j in LearnsetsG6[key].tm) {
buf += 'TM - '+Tools.getMove(LearnsetsG6[key].tm[j]).name+'\n';
}
for (var j in LearnsetsG6[key].egg) {
buf += 'Egg - '+Tools.getMove(LearnsetsG6[key].egg[j]).name+'\n';
}
buf += '\n';
}
fs.writeFileSync('learnsets-g6/learnsets-g6-S-to-Z.txt', buf);