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
81
82
83
84
85
86
|
const fs = require('fs');
var zlib = require('zlib');
module.exports = {
export(file, obj) {
fs.writeFileSync(file, zlib.deflateSync(Buffer.from(Buffer.from(JSON.stringify(obj)).toString("base64")).toString("base64")))
},
load(file) {
data = fs.readFileSync(file)
uncomp = zlib.inflateSync(data);
b1 = Buffer.from(uncomp, "base64").toString("utf-8");
b2 = Buffer.from(b1, "base64").toString("utf-8");
item = Buffer.from(b2, "base64").toString("utf-8");
decoded = JSON.parse(item);
return decoded;
},
async generate(file) {
o = {
"_version": "<unknown>",
"stats": {
"times": {
"single": 0,
"local": 0,
"online": 0
},
"results": {
"wins": 0,
"loses": 0
},
"ingame": {
"walls": 0,
"laps": 0,
"turns": 0
}
},
"auth": null,
"config": {
"lang": null,
"music": true,
"online": true,
"voice": false
}
}
slpm = require('os-locale');
slpw = await slpm();
slpo = slpw.substr(0, 2);
slng = require('../lang/languages.json');
if (Object.keys(slng).includes(slpo)) {
dlp = slpo;
} else {
dlp = "en";
}
o.config.lang = dlp;
this.export(file, o);
},
convert(file, dotkartik) {
if (fs.existsSync(dotkartik + "/authentication.json")) {
auth = JSON.parse(fs.readFileSync(dotkartik + "/authentication.json"));
} else {
auth = null;
}
o = {
"_version": "<unknown>",
"stats": JSON.parse(fs.readFileSync(dotkartik + "/stats.json").toString()),
"auth": auth,
"config": {
"lang": fs.readFileSync(dotkartik + "/config/lang.txt").toString().trim(),
"music": fs.readFileSync(dotkartik + "/config/music.txt").toString().trim() === "1",
"online": fs.readFileSync(dotkartik + "/config/online.txt").toString().trim() === "1",
"voice": fs.readFileSync(dotkartik + "/config/voice.txt").toString().trim() === "1"
}
}
this.export(file, o);
}
}
|