blob: c0a3e646ed0a41f565b3837259e49c179b13f70b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
import typedHypixelApi from 'typed-hypixel-api'
export interface ItemRequirement {
// idk what these do
// they'll probably be renamed at some point
dungeon: {
type: string
level: number
}
}
// based on Item from inventory.ts
export interface ItemListItem {
id: string
vanillaId: string
tier: string | null
display: {
name: string
glint: boolean
}
npcSellPrice: number | null
requirements: ItemRequirement | null
}
export interface ItemListData {
lastUpdated: number
list: ItemListItem[]
}
function cleanItemRequirements(data: typedHypixelApi.SkyBlockItemsResponse['items'][number]['requirements'] & typedHypixelApi.SkyBlockItemsResponse['items'][number]['catacombs_requirements']): ItemRequirement | null {
if (!data || !data.dungeon) return null
return {
dungeon: {
type: data.dungeon.type,
level: data.dungeon.level
}
}
}
function cleanItemListItem(item: typedHypixelApi.SkyBlockItemsResponse['items'][number]): ItemListItem {
const vanillaId = item.material.toLowerCase()
return {
id: item.id,
vanillaId: item.durability ? `${vanillaId}:${item.durability}` : vanillaId,
tier: item.tier ?? null,
display: {
name: item.name,
glint: item.glowing ?? false
},
npcSellPrice: item.npc_sell_price ?? null,
requirements: cleanItemRequirements(item.catacombs_requirements ?? item.requirements)
}
}
export async function cleanItemListResponse(data: typedHypixelApi.SkyBlockItemsResponse): Promise<ItemListData> {
return {
lastUpdated: data.lastUpdated,
list: data.items.map(cleanItemListItem)
}
}
|