aboutsummaryrefslogtreecommitdiff
path: root/src/cleaners/skyblock/pets.ts
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-03-28 15:30:02 +0000
committermat <github@matdoes.dev>2022-03-28 15:30:21 +0000
commit44a8aebcb40f1d02b93218bcf5ccfa8e87621abb (patch)
tree94a51903caeea25e322676b178d02047bb615ef7 /src/cleaners/skyblock/pets.ts
parent8e86d739ae21d24c148276aa67fd0c19aaf37c1c (diff)
downloadskyblock-api-44a8aebcb40f1d02b93218bcf5ccfa8e87621abb.tar.gz
skyblock-api-44a8aebcb40f1d02b93218bcf5ccfa8e87621abb.tar.bz2
skyblock-api-44a8aebcb40f1d02b93218bcf5ccfa8e87621abb.zip
add item list
Diffstat (limited to 'src/cleaners/skyblock/pets.ts')
-rw-r--r--src/cleaners/skyblock/pets.ts10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/cleaners/skyblock/pets.ts b/src/cleaners/skyblock/pets.ts
index d6265e5..4c0fe4a 100644
--- a/src/cleaners/skyblock/pets.ts
+++ b/src/cleaners/skyblock/pets.ts
@@ -1,6 +1,8 @@
import typedHypixelApi from 'typed-hypixel-api'
-import { fetchPets } from '../../constants.js'
+import { fetchItemList } from '../../hypixel.js'
import { levelFromXpTable } from '../../util.js'
+import { fetchPets } from '../../constants.js'
+import { ItemListItem } from './itemList.js'
// https://hypixel-skyblock.fandom.com/wiki/Module:Pet/LevelingData?action=edit
@@ -43,7 +45,7 @@ export interface Pet {
level: number
tier: typedHypixelApi.Pet['tier']
skin: string | null
- item: string | null
+ item: ItemListItem | null
}
export interface PetsData {
@@ -59,6 +61,8 @@ export async function cleanPets(data: typedHypixelApi.SkyBlockProfileMember): Pr
const allPetIds = await fetchPets()
const obtainedPetIds: string[] = []
+ const itemList = await fetchItemList()
+
for (const petData of data.pets ?? []) {
const xpTable = RARITY_XP_TABLES[petData.tier]
const level = levelFromXpTable(petData.exp, xpTable)
@@ -69,7 +73,7 @@ export async function cleanPets(data: typedHypixelApi.SkyBlockProfileMember): Pr
level,
tier: petData.tier,
skin: petData.skin ?? null,
- item: petData.heldItem
+ item: petData.heldItem ? (itemList.list.find(i => i.id === petData.heldItem) ?? null) : null
}
obtainedPetIds.push(pet.id)
obtainedPets.push(pet)