aboutsummaryrefslogtreecommitdiff
path: root/views/script/global_levelsapi.js
diff options
context:
space:
mode:
authorMinteck <nekostarfan@gmail.com>2021-08-05 17:29:18 +0200
committerGitHub <noreply@github.com>2021-08-05 17:29:18 +0200
commitb865b8f6586ffd4554cdfe45c739030afc882acd (patch)
tree37bcdf6575d8764b7367f34544658886879c0c5e /views/script/global_levelsapi.js
parent79edea37d15f88f086f7775bbbce64a57535b043 (diff)
parent7b541bbf2a8d754d26511895801d90f02cdf99f7 (diff)
downloadkartik-client-b865b8f6586ffd4554cdfe45c739030afc882acd.tar.gz
kartik-client-b865b8f6586ffd4554cdfe45c739030afc882acd.tar.bz2
kartik-client-b865b8f6586ffd4554cdfe45c739030afc882acd.zip
Merge pull request #4 from Minteck-Projects/devel
Branching 21.08
Diffstat (limited to 'views/script/global_levelsapi.js')
-rw-r--r--views/script/global_levelsapi.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/views/script/global_levelsapi.js b/views/script/global_levelsapi.js
new file mode 100644
index 0000000..45a74d2
--- /dev/null
+++ b/views/script/global_levelsapi.js
@@ -0,0 +1,47 @@
+module.exports = class LevelsAPI {
+
+ associates;
+
+ constructor() {
+
+ let assocs_raw;
+ let assocs_lines;
+ let assocs_base;
+ let assocs;
+ let score;
+ let cline;
+ let line;
+ let clvl;
+
+ assocs_raw = require('fs').readFileSync("./online/levels.txt");
+ assocs_lines = assocs_raw.toString().split("\n");
+ assocs_base = {};
+
+ for (line of assocs_lines) {
+ cline = line.split(":");
+ assocs_base[cline[1].trim()] = cline[0].trim() - 1 + 1;
+ }
+
+ assocs = {};
+
+ clvl = 0;
+ for (let c = 0; c <= 5051; c++) {
+ if (assocs_base[c.toString()] !== undefined) {
+ clvl = assocs_base[c.toString()];
+ }
+ assocs[c.toString()] = clvl.toString()
+ }
+
+ this.associates = assocs;
+
+ }
+
+ correspond(score, god) {
+ if (score <= 5051) {
+ return this.associates[score].toString();
+ } else {
+ return god;
+ }
+ }
+
+} \ No newline at end of file