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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
import typedHypixelApi from 'typed-hypixel-api'
import { headIdFromBase64 } from './inventory.js'
import { cleanItemId } from './itemId.js'
export interface ItemRequirement {
dungeon?: {
type: string
level: number
}
skill?: {
type: string
level: number
}
slayer?: {
boss: string
level: number
}
}
// based on Item from inventory.ts
export interface ItemListItem {
id: string
headTexture?: string
vanillaId: string
tier: string | null
display: {
name: string
glint: boolean
}
npcSellPrice: number | null
requirements: ItemRequirement
category: string | null
soulbound: boolean
museum: boolean
}
export interface ItemListData {
lastUpdated: number
list: ItemListItem[]
}
function cleanItemRequirements(data: typedHypixelApi.SkyBlockItemsResponse['items'][number]['requirements'], catacombsRequirements: typedHypixelApi.SkyBlockItemsResponse['items'][number]['catacombs_requirements']): ItemRequirement {
if (!data) return {}
let dungeonData = data.dungeon ?? catacombsRequirements?.dungeon
return {
dungeon: dungeonData ? {
type: dungeonData.type.toLowerCase(),
level: dungeonData.level
} : undefined,
skill: data.skill ? {
type: data.skill.type.toLowerCase(),
level: data.skill.level
} : undefined,
slayer: data.slayer ? {
boss: data.slayer.slayer_boss_type,
level: data.slayer.level
} : undefined
}
}
function cleanItemListItem(item: typedHypixelApi.SkyBlockItemsResponse['items'][number]): ItemListItem {
const vanillaId = cleanItemId(item.durability ? `${item.material}:${item.durability}` : item.material)
return {
id: item.id,
headTexture: (item.material === 'SKULL_ITEM' && 'skin' in item) ? headIdFromBase64(item.skin) : undefined,
vanillaId,
tier: item.tier ?? null,
display: {
name: item.name,
glint: item.glowing ?? false
},
npcSellPrice: item.npc_sell_price ?? null,
requirements: cleanItemRequirements(item.requirements, item.catacombs_requirements),
category: item.category?.toLowerCase() ?? null,
soulbound: !!item.soulbound,
museum: item.museum ?? false
}
}
export async function cleanItemListResponse(data: typedHypixelApi.SkyBlockItemsResponse): Promise<ItemListData> {
return {
lastUpdated: data.lastUpdated,
list: data.items.map(cleanItemListItem)
}
}
|