aboutsummaryrefslogtreecommitdiff
path: root/src/cleaners
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-04-23 14:10:08 -0500
committermat <github@matdoes.dev>2022-04-23 14:10:08 -0500
commit57cb3e84f9c8f513665e364459c8ff342d9b3d74 (patch)
tree240f7687e69f5d95543e5993036c2165678fbc85 /src/cleaners
parent6a7249c7b46aab070d029e22bee57e1e314001f5 (diff)
downloadskyblock-api-57cb3e84f9c8f513665e364459c8ff342d9b3d74.tar.gz
skyblock-api-57cb3e84f9c8f513665e364459c8ff342d9b3d74.tar.bz2
skyblock-api-57cb3e84f9c8f513665e364459c8ff342d9b3d74.zip
add some missing things to `claimed`
Diffstat (limited to 'src/cleaners')
-rw-r--r--src/cleaners/player.ts5
-rw-r--r--src/cleaners/skyblock/claimed.ts43
2 files changed, 34 insertions, 14 deletions
diff --git a/src/cleaners/player.ts b/src/cleaners/player.ts
index f2df07d..2d819e9 100644
--- a/src/cleaners/player.ts
+++ b/src/cleaners/player.ts
@@ -12,7 +12,12 @@ export interface CleanBasicPlayer {
}
export interface ClaimedSkyBlockItem {
+ /**
+ * name is kept for backwards compatibility, it will be changed to a more
+ * human readable name later
+ */
name: string
+ id: string
timestamp: number
}
diff --git a/src/cleaners/skyblock/claimed.ts b/src/cleaners/skyblock/claimed.ts
index 0873af9..1be0e17 100644
--- a/src/cleaners/skyblock/claimed.ts
+++ b/src/cleaners/skyblock/claimed.ts
@@ -1,49 +1,64 @@
-import { HypixelPlayerStatsSkyBlockProfiles } from '../../hypixelApi.js'
-import {
- CleanBasicProfile,
- CleanFullProfile,
- cleanSkyblockProfileResponse
-} from './profile.js'
import typedHypixelApi from 'typed-hypixel-api'
import { ClaimedSkyBlockItem } from '../player.js'
export function cleanPlayerSkyblockClaimed(data: typedHypixelApi.PlayerDataResponse['player']): ClaimedSkyBlockItem[] {
const claimedItems: ClaimedSkyBlockItem[] = []
+ // `name` is kept for backwards compatibility, it will be changed to a
+ // more human readable name later!
+
if (data.claimed_potato_talisman)
claimedItems.push({
+ id: 'potato_talisman',
name: 'potato_talisman',
timestamp: data.claimed_potato_talisman
})
-
- const centuryCakes = Object.keys(data).filter((key) => key.startsWith('claimed_century_cake'))
- for (const centuryCake of centuryCakes) {
- const centuryCakeYear = centuryCake === 'claimed_century_cake' ? '100' : centuryCake.slice('claimed_century_cake'.length)
+ if (data.claim_potato_war_crown)
claimedItems.push({
- name: `year_${centuryCakeYear}_century_cake`,
- timestamp: data[centuryCake]
+ id: 'potato_crown',
+ name: 'potato_crown',
+ timestamp: data.claim_potato_war_crown
+ })
+ if (data.claimed_potato_basket)
+ claimedItems.push({
+ id: 'potato_basket',
+ name: 'potato_basket',
+ timestamp: data.claimed_potato_basket
})
- }
-
if (data.claimed_year143_cake)
claimedItems.push({
+ id: 'year_143_cake',
name: 'year_143_cake',
timestamp: data.claimed_year143_cake
})
if (data.skyblock_free_cookie)
claimedItems.push({
+ id: 'free_booster_cookie',
name: 'free_booster_cookie',
timestamp: data.skyblock_free_cookie
})
+ const centuryCakes = Object.keys(data).filter((key) => key.startsWith('claimed_century_cake'))
+ for (const centuryCake of centuryCakes) {
+ const centuryCakeYear = centuryCake === 'claimed_century_cake' ? '100' : centuryCake.slice('claimed_century_cake'.length)
+ claimedItems.push({
+ id: `year_${centuryCakeYear}_century_cake`,
+ name: `year_${centuryCakeYear}_century_cake`,
+ timestamp: data[centuryCake]
+ })
+ }
+
const scorpiusBribes = Object.keys(data).filter((key) => key.startsWith('scorpius_bribe_'))
for (const bribe of scorpiusBribes) {
const bribeYear = bribe.slice('scorpius_bribe_'.length)
claimedItems.push({
+ id: `year_${bribeYear}_scorpius_bribe`,
name: `year_${bribeYear}_scorpius_bribe`,
timestamp: data[bribe]
})
}
+ claimedItems.sort((a, b) => a.timestamp - b.timestamp)
+
return claimedItems
}