aboutsummaryrefslogtreecommitdiff
path: root/src/cleaners/skyblock/essence.ts
blob: 4af94fb08f657bc6c4acc368aac27dd63801db58 (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
import typedHypixelApi from 'typed-hypixel-api'
import * as constants from '../../constants.js'

interface EssenceType {
	id: string
	value: number
}

export interface Essence {
	types: EssenceType[]
}

export function cleanEssence(data: typedHypixelApi.SkyBlockProfileMember): Essence {
	const essences: EssenceType[] = []

	for (const [id, value] of Object.entries(data ?? {})) {
		if (id.startsWith('essence_')) {
			essences.push({
				id: id.replace(/^essence_/, ''),
				value: value ?? 0,
			})
		}
	}

	return {
		types: essences,
	}
}