aboutsummaryrefslogtreecommitdiff
path: root/src/cleaners
diff options
context:
space:
mode:
Diffstat (limited to 'src/cleaners')
-rw-r--r--src/cleaners/skyblock/member.ts4
-rw-r--r--src/cleaners/skyblock/slayers.ts36
2 files changed, 32 insertions, 8 deletions
diff --git a/src/cleaners/skyblock/member.ts b/src/cleaners/skyblock/member.ts
index b2dc105..6d419e1 100644
--- a/src/cleaners/skyblock/member.ts
+++ b/src/cleaners/skyblock/member.ts
@@ -11,7 +11,7 @@ import { CleanPlayer } from '../player'
import { Bank } from './bank'
import { cleanVisitedZones, Zone } from './zones'
import { cleanCollections, Collection } from './collections'
-import { cleanSlayers, Slayer } from './slayers'
+import { cleanSlayers, Slayer, SlayerData } from './slayers'
export interface CleanBasicMember {
uuid: string
@@ -30,7 +30,7 @@ export interface CleanMember extends CleanBasicMember {
skills: Skill[]
visited_zones: Zone[]
collections: Collection[]
- slayers: Slayer[]
+ slayers: SlayerData
}
export async function cleanSkyBlockProfileMemberResponseBasic(member, included: Included[] = null): Promise<CleanBasicMember> {
diff --git a/src/cleaners/skyblock/slayers.ts b/src/cleaners/skyblock/slayers.ts
index 0fa1a5e..dd3881b 100644
--- a/src/cleaners/skyblock/slayers.ts
+++ b/src/cleaners/skyblock/slayers.ts
@@ -1,7 +1,14 @@
const slayerLevels = 4 // number of slayer levels, this might be 5 soon
-type SlayerName = 'spider' | 'zombie' | 'wolf'
+const SLAYER_NAMES = {
+ spider: 'tarantula',
+ zombie: 'revenant',
+ wolf: 'sven'
+} as const
+
+type ApiSlayerName = keyof typeof SLAYER_NAMES
+type SlayerName = (typeof SLAYER_NAMES)[ApiSlayerName]
interface SlayerTier {
tier: number,
@@ -14,12 +21,24 @@ export interface Slayer {
tiers: SlayerTier[]
}
-export function cleanSlayers(data: any) {
+export interface SlayerData {
+ xp: number
+ bosses: Slayer[]
+}
+
+export function cleanSlayers(data: any): SlayerData {
const slayers: Slayer[] = []
const slayersDataRaw = data?.slayer_bosses
- for (const slayerName in slayersDataRaw) {
- const slayerDataRaw = slayersDataRaw[slayerName]
+
+ 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: SlayerName = SLAYER_NAMES[slayerDataRaw]
+
const slayerXp: number = slayerDataRaw.xp
const slayerTiers: SlayerTier[] = []
for (const slayerDataKey in slayerDataRaw) {
@@ -44,11 +63,16 @@ export function cleanSlayers(data: any) {
})
const slayer: Slayer = {
- name: slayerName as SlayerName,
+ 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
}
- return slayers
}