-
Notifications
You must be signed in to change notification settings - Fork 10
/
combinedetails.js
80 lines (73 loc) · 2.61 KB
/
combinedetails.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
73
74
75
76
77
78
79
80
const fs = require('fs');
function main()
{
var events = JSON.parse(fs.readFileSync("./files/events.min.json"));
fs.readdir("files/temp", function (err, files) {
if (err) {
return console.log('Unable to scan directory: ' + err);
}
files.forEach(f =>
{
var data = JSON.parse(fs.readFileSync("./files/temp/" + f));
events.forEach(e =>
{
if (e.eventID == data.id)
{
// add always generic data as 'generic' block in 'extraData' (available for all possible events)
if (data.type == "generic")
{
if (e.extraData === null) {
e.extraData = {};
}
e.extraData.generic = data.data;
}
// add event specific extra data. Block named as event type name
if (data.type == "research-breakthrough")
{
if (e.extraData === null) {
e.extraData = {};
}
e.extraData.breakthrough = data.data;
}
else if (data.type == "pokemon-spotlight-hour")
{
if (e.extraData === null) {
e.extraData = {};
}
e.extraData.spotlight = data.data
}
else if (data.type == "community-day")
{
if (e.extraData === null) {
e.extraData = {};
}
e.extraData.communityday = data.data
}
else if (data.type == "raid-battles")
{
if (e.extraData === null) {
e.extraData = {};
}
e.extraData.raidbattles = data.data
}
}
});
});
fs.writeFile('files/events.json', JSON.stringify(events, null, 4), err => {
if (err) {
console.error(err);
return;
}
});
fs.writeFile('files/events.min.json', JSON.stringify(events), err => {
if (err) {
console.error(err);
return;
}
});
fs.rm("files/temp", { recursive: true }, (err) => {
if (err) { throw err; }
});
});
}
main();