aboutsummaryrefslogtreecommitdiff
path: root/build/cleaners/skyblock/slayers.js
diff options
context:
space:
mode:
authormat-1 <github@matdoes.dev>2021-02-15 01:35:32 +0000
committermat-1 <github@matdoes.dev>2021-02-15 01:35:32 +0000
commit84778bb94747390fbcc83a3d6a5bd69286208f61 (patch)
treecd515d0a8c51b0f343611fd78db7d08f34456c0b /build/cleaners/skyblock/slayers.js
parent342d11858b4db9981a23a27dfb28e18d18a4c2fa (diff)
downloadskyblock-api-84778bb94747390fbcc83a3d6a5bd69286208f61.tar.gz
skyblock-api-84778bb94747390fbcc83a3d6a5bd69286208f61.tar.bz2
skyblock-api-84778bb94747390fbcc83a3d6a5bd69286208f61.zip
Compiled TS into JS
Diffstat (limited to 'build/cleaners/skyblock/slayers.js')
-rw-r--r--build/cleaners/skyblock/slayers.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/build/cleaners/skyblock/slayers.js b/build/cleaners/skyblock/slayers.js
new file mode 100644
index 0000000..d2b9dbe
--- /dev/null
+++ b/build/cleaners/skyblock/slayers.js
@@ -0,0 +1,53 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.cleanSlayers = void 0;
+const slayerLevels = 4; // number of slayer levels, this might be 5 soon
+const SLAYER_NAMES = {
+ spider: 'tarantula',
+ zombie: 'revenant',
+ wolf: 'sven'
+};
+function cleanSlayers(data) {
+ const slayers = [];
+ const slayersDataRaw = data === null || data === void 0 ? void 0 : data.slayer_bosses;
+ let totalXp = 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 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];
+ // add 1 since hypixel is using 0 indexed tiers
+ const slayerTier = slayerTierRaw + 1;
+ slayerTiers.push({
+ kills: slayerTierKills,
+ tier: slayerTier
+ });
+ }
+ }
+ // if the slayer tier length is less than the max, add more empty ones
+ while (slayerTiers.length < slayerLevels)
+ slayerTiers.push({
+ tier: slayerTiers.length + 1,
+ kills: 0
+ });
+ const slayer = {
+ name: slayerName,
+ tiers: slayerTiers,
+ xp: slayerXp
+ };
+ slayers.push(slayer);
+ // add the xp from this slayer to the total xp
+ totalXp += slayerXp;
+ }
+ return {
+ xp: totalXp,
+ bosses: slayers
+ };
+}
+exports.cleanSlayers = cleanSlayers;