added leaderboard (closes #29)

This commit is contained in:
Nathan DECHER
2020-04-13 21:58:53 +02:00
parent 1ca8e46461
commit 7b083fda11
20 changed files with 852 additions and 48 deletions
+26 -1
View File
@@ -7,12 +7,37 @@ const get=async filename => {
return cache[filename]=json;
};
const getInfo=(category, id) => {
const cat=levelList[category];
id=''+id;
const displayName=cat.levelDisplay
.replace(/<n>/g, id)
.replace(/<l>/g, id.toLowerCase());
const fileName=cat.levelFilename
.replace(/<n>/g, id)
.replace(/<l>/g, id.toLowerCase());
const levelString=category+'/'+id+'/'+fileName;
return {
displayName,
fileName,
levelString
};
};
const getRules=async (category, id) => {
const {fileName}=getInfo(category, id);
const json=await get(fileName);
return Object.assign({}, window.levelList[category].rules, json.rules);
};
const clearCache=() =>
Object
.keys(cache)
.forEach(key => delete cache[key]);
return module.exports={
get,
get, getRules, getInfo,
clearCache
};