diff options
author | Minteck <46352972+Minteck@users.noreply.github.com> | 2021-07-14 01:12:14 +0200 |
---|---|---|
committer | Minteck <46352972+Minteck@users.noreply.github.com> | 2021-07-14 01:12:14 +0200 |
commit | 0f0e3de9353c06dfaabc00682b4c2fd9c5f48924 (patch) | |
tree | aef2474d205aea7865f7c9a4f17ffee474bbe7bc /nest | |
parent | c3b756f987ffd8ca981c1e6f23435c74aad36aea (diff) | |
download | kartik-client-0f0e3de9353c06dfaabc00682b4c2fd9c5f48924.tar.gz kartik-client-0f0e3de9353c06dfaabc00682b4c2fd9c5f48924.tar.bz2 kartik-client-0f0e3de9353c06dfaabc00682b4c2fd9c5f48924.zip |
Kartik Fox Nest!
Diffstat (limited to 'nest')
-rw-r--r-- | nest/abi.js | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/nest/abi.js b/nest/abi.js new file mode 100644 index 0000000..b72f964 --- /dev/null +++ b/nest/abi.js @@ -0,0 +1,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); + } +}
\ No newline at end of file |