aboutsummaryrefslogtreecommitdiff
path: root/build/cleaners
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2021-04-13 16:30:27 -0500
committerGitHub <noreply@github.com>2021-04-13 16:30:27 -0500
commitac79dfbc6ad6eb56bc814471d49b95f014d3eb5f (patch)
tree600846dd4804c487d16d33dd99ad4073d815e8f3 /build/cleaners
parentc0d03a8d0c1e75967f48cb27d9c55bc4707af22c (diff)
downloadskyblock-api-ac79dfbc6ad6eb56bc814471d49b95f014d3eb5f.tar.gz
skyblock-api-ac79dfbc6ad6eb56bc814471d49b95f014d3eb5f.tar.bz2
skyblock-api-ac79dfbc6ad6eb56bc814471d49b95f014d3eb5f.zip
Slayer leaderboard (#4)
* add slayers to constants * Compiled TS into JS * change units to also show up when only changing one constant item * Compiled TS into JS * add slayer leaderboards * remove debugging stuff
Diffstat (limited to 'build/cleaners')
-rw-r--r--build/cleaners/skyblock/slayers.js30
-rw-r--r--build/cleaners/skyblock/stats.js1
2 files changed, 22 insertions, 9 deletions
diff --git a/build/cleaners/skyblock/slayers.js b/build/cleaners/skyblock/slayers.js
index d2b9dbe..dbc20fc 100644
--- a/build/cleaners/skyblock/slayers.js
+++ b/build/cleaners/skyblock/slayers.js
@@ -1,52 +1,64 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
-exports.cleanSlayers = void 0;
-const slayerLevels = 4; // number of slayer levels, this might be 5 soon
+exports.cleanSlayers = exports.slayerLevels = void 0;
+exports.slayerLevels = 4; // number of slayer levels, this might be 5 soon
const SLAYER_NAMES = {
spider: 'tarantula',
zombie: 'revenant',
wolf: 'sven'
};
function cleanSlayers(data) {
+ var _a, _b;
const slayers = [];
const slayersDataRaw = data === null || data === void 0 ? void 0 : data.slayer_bosses;
let totalXp = 0;
+ let totalKills = 0;
for (const slayerNameRaw in slayersDataRaw) {
const slayerDataRaw = slayersDataRaw[slayerNameRaw];
// convert name provided by api (spider) to the real name (tarantula)
- const slayerName = SLAYER_NAMES[slayerDataRaw];
- const slayerXp = slayerDataRaw.xp;
+ const slayerName = SLAYER_NAMES[slayerNameRaw];
+ const slayerXp = (_a = slayerDataRaw.xp) !== null && _a !== void 0 ? _a : 0;
+ let slayerKills = 0;
const slayerTiers = [];
for (const slayerDataKey in slayerDataRaw) {
// if a key starts with boss_kills_tier_ (boss_kills_tier_1), get the last number
if (slayerDataKey.startsWith('boss_kills_tier_')) {
const slayerTierRaw = parseInt(slayerDataKey.substr('boss_kills_tier_'.length));
- const slayerTierKills = slayerDataRaw[slayerDataKey];
+ const slayerTierKills = (_b = slayerDataRaw[slayerDataKey]) !== null && _b !== void 0 ? _b : 0;
// add 1 since hypixel is using 0 indexed tiers
const slayerTier = slayerTierRaw + 1;
slayerTiers.push({
kills: slayerTierKills,
tier: slayerTier
});
+ // count up the total number of kills for this slayer
+ if (slayerTierKills)
+ slayerKills += slayerTierKills;
}
}
// if the slayer tier length is less than the max, add more empty ones
- while (slayerTiers.length < slayerLevels)
+ while (slayerTiers.length < exports.slayerLevels)
slayerTiers.push({
tier: slayerTiers.length + 1,
kills: 0
});
const slayer = {
name: slayerName,
+ raw_name: slayerNameRaw,
tiers: slayerTiers,
- xp: slayerXp
+ xp: slayerXp !== null && slayerXp !== void 0 ? slayerXp : 0,
+ kills: slayerKills
};
slayers.push(slayer);
- // add the xp from this slayer to the total xp
- totalXp += slayerXp;
+ // add the xp and kills from this slayer to the total xp
+ if (slayerXp)
+ totalXp += slayerXp;
+ if (slayerKills)
+ totalKills += slayerKills;
}
return {
xp: totalXp,
+ kills: totalKills,
bosses: slayers
};
}
diff --git a/build/cleaners/skyblock/stats.js b/build/cleaners/skyblock/stats.js
index 5673d99..0eb94c7 100644
--- a/build/cleaners/skyblock/stats.js
+++ b/build/cleaners/skyblock/stats.js
@@ -10,6 +10,7 @@ const statCategories = {
'mythos': ['mythos_burrows_', 'mythos_kills'],
'collection': ['collection_'],
'skills': ['skill_'],
+ 'slayer': ['slayer_'],
'misc': null // everything else goes here
};
function categorizeStat(statNameRaw) {