aboutsummaryrefslogtreecommitdiff
path: root/src/cleaners
diff options
context:
space:
mode:
Diffstat (limited to 'src/cleaners')
-rw-r--r--src/cleaners/skyblock/slayers.ts37
-rw-r--r--src/cleaners/skyblock/stats.ts1
2 files changed, 29 insertions, 9 deletions
diff --git a/src/cleaners/skyblock/slayers.ts b/src/cleaners/skyblock/slayers.ts
index dd3881b..2026496 100644
--- a/src/cleaners/skyblock/slayers.ts
+++ b/src/cleaners/skyblock/slayers.ts
@@ -1,5 +1,4 @@
-
-const slayerLevels = 4 // number of slayer levels, this might be 5 soon
+export const slayerLevels = 4 // number of slayer levels, this might be 5 soon
const SLAYER_NAMES = {
spider: 'tarantula',
@@ -17,12 +16,15 @@ interface SlayerTier {
export interface Slayer {
name: SlayerName
+ raw_name: string
xp: number
+ kills: number
tiers: SlayerTier[]
}
export interface SlayerData {
xp: number
+ kills: number
bosses: Slayer[]
}
@@ -31,27 +33,34 @@ export function cleanSlayers(data: any): SlayerData {
const slayersDataRaw = data?.slayer_bosses
- let totalXp = 0
+ let totalXp: number = 0
+ let totalKills: number = 0
for (const slayerNameRaw in slayersDataRaw) {
const slayerDataRaw = slayersDataRaw[slayerNameRaw]
// convert name provided by api (spider) to the real name (tarantula)
- const slayerName: SlayerName = SLAYER_NAMES[slayerDataRaw]
+ const slayerName: SlayerName = SLAYER_NAMES[slayerNameRaw]
- const slayerXp: number = slayerDataRaw.xp
+ const slayerXp: number = slayerDataRaw.xp ?? 0
+ let slayerKills: number = 0
const slayerTiers: SlayerTier[] = []
+
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 = slayerDataRaw[slayerDataKey] ?? 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
}
}
@@ -64,15 +73,25 @@ export function cleanSlayers(data: any): SlayerData {
const slayer: Slayer = {
name: slayerName,
+ raw_name: slayerNameRaw,
tiers: slayerTiers,
- xp: slayerXp
+ xp: 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/src/cleaners/skyblock/stats.ts b/src/cleaners/skyblock/stats.ts
index efb79bd..218e034 100644
--- a/src/cleaners/skyblock/stats.ts
+++ b/src/cleaners/skyblock/stats.ts
@@ -8,6 +8,7 @@ const statCategories: { [ key: string ]: string[] | null } = { // sorted in orde
'collection': ['collection_'],
'skills': ['skill_'],
+ 'slayer': ['slayer_'],
'misc': null // everything else goes here
}