aboutsummaryrefslogtreecommitdiff
path: root/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'app.js')
-rw-r--r--app.js24
1 files changed, 18 insertions, 6 deletions
diff --git a/app.js b/app.js
index 8e4ea52..30b2439 100644
--- a/app.js
+++ b/app.js
@@ -269,17 +269,29 @@ const { app, BrowserWindow } = require('electron');
win.webContents.send('setmusic', value);
}
})
- musicIpc.on('prefademusic', (event, value) => {
- win.webContents.send('fademusic', value);
- })
- musicIpc.on('preunfademusic', (event, value) => {
- win.webContents.send('unfademusic', value);
- })
+
+ const LevelsAPI = require('./views/script/global_levelsapi');
+ const lvl = new LevelsAPI();
stats = require(homedir + "/.kartik/stats.json");
musicIpc.on('addstats', (event, value) => {
stats[value.catalog][value.key] = stats[value.catalog][value.key] + value.add;
fs.writeFile(homedir + "/.kartik/stats.json", JSON.stringify(stats), () => {});
+
+ if (value.key === "laps" && fs.existsSync(homedir + "/.kartik/authentication.json")) {
+ auth = JSON.parse(fs.readFileSync(homedir + "/.kartik/authentication.json").toString());
+ level = lvl.correspond(stats["ingame"]["laps"], "256") - 1 + 1;
+
+ if (level !== auth.level) {
+ auth.level = level
+ fs.writeFileSync(homedir + "/.kartik/authentication.json", JSON.stringify(auth));
+ if (level < 200) {
+ win.webContents.send("notification", {title: lang.polymer.levelup[0], message: lang.polymer.levelup[1] + " " + level + " " + lang.polymer.levelup[2]});
+ } else {
+ win.webContents.send("notification", {title: lang.polymer.finished[0], message: lang.polymer.finished[1]});
+ }
+ }
+ }
})
musicIpc.on('addstatsandclose', (event, value) => {
stats[value.catalog][value.key] = stats[value.catalog][value.key] + value.add;