diff options
author | mat <github@matdoes.dev> | 2022-03-19 17:08:17 -0500 |
---|---|---|
committer | mat <github@matdoes.dev> | 2022-03-19 17:08:17 -0500 |
commit | 8843ccf72f076c26970cad5ce3c878f893ec9d54 (patch) | |
tree | d75392cee553dbd491955ff41dda6dda434545ef /src/cleaners | |
parent | cbc8f1580fce6e9f975e206d079b82acc139dd36 (diff) | |
download | skyblock-api-8843ccf72f076c26970cad5ce3c878f893ec9d54.tar.gz skyblock-api-8843ccf72f076c26970cad5ce3c878f893ec9d54.tar.bz2 skyblock-api-8843ccf72f076c26970cad5ce3c878f893ec9d54.zip |
Include slayer level in response
Diffstat (limited to 'src/cleaners')
-rw-r--r-- | src/cleaners/skyblock/slayers.ts | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/cleaners/skyblock/slayers.ts b/src/cleaners/skyblock/slayers.ts index f051852..a47829a 100644 --- a/src/cleaners/skyblock/slayers.ts +++ b/src/cleaners/skyblock/slayers.ts @@ -18,6 +18,7 @@ export interface Slayer { name?: SlayerName raw_name: string xp: number + level: number kills: number tiers: SlayerTier[] } @@ -46,6 +47,13 @@ export function cleanSlayers(data: any): SlayerData { let slayerKills: number = 0 const slayerTiers: SlayerTier[] = [] + // we get the level by finding the biggest number in "level_<number>" + let slayerLevel = Object.keys(slayerDataRaw.claimed_levels) + .filter(k => slayerDataRaw.claimed_levels[k]) + .map(n => parseInt(n.replace(/^level_/, ''))) + .sort((a, b) => b - a)[0] ?? 0 + + 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_')) { @@ -76,6 +84,7 @@ export function cleanSlayers(data: any): SlayerData { raw_name: slayerNameRaw, tiers: slayerTiers, xp: slayerXp ?? 0, + level: slayerLevel, kills: slayerKills } |