diff options
Diffstat (limited to 'views/script/global_levelsapi.js')
-rw-r--r-- | views/script/global_levelsapi.js | 47 |
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..ebd969d --- /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 |