diff options
author | mat <github@matdoes.dev> | 2022-05-15 14:38:18 -0500 |
---|---|---|
committer | mat <github@matdoes.dev> | 2022-05-15 14:38:18 -0500 |
commit | b3010e565fe7e984f5a913e8a4167a3cb6810090 (patch) | |
tree | d6bb1aa9c09c3f999de38ba1d223a19f1c844a04 /src/cleaners/skyblock/accessoryBagUpgrades.ts | |
parent | aa42b7d98cbc7707693e564463f3084b282c700c (diff) | |
download | skyblock-api-b3010e565fe7e984f5a913e8a4167a3cb6810090.tar.gz skyblock-api-b3010e565fe7e984f5a913e8a4167a3cb6810090.tar.bz2 skyblock-api-b3010e565fe7e984f5a913e8a4167a3cb6810090.zip |
add accessory bag upgrades
Diffstat (limited to 'src/cleaners/skyblock/accessoryBagUpgrades.ts')
-rw-r--r-- | src/cleaners/skyblock/accessoryBagUpgrades.ts | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/cleaners/skyblock/accessoryBagUpgrades.ts b/src/cleaners/skyblock/accessoryBagUpgrades.ts new file mode 100644 index 0000000..1fcc682 --- /dev/null +++ b/src/cleaners/skyblock/accessoryBagUpgrades.ts @@ -0,0 +1,52 @@ +import typedHypixelApi from 'typed-hypixel-api' + +export interface AccessoryBagUpgrades { + tuningTemplates: Record<string, number>[] + upgrades: { + purchased: number + coinsSpent: number + extraSlots: number + } + powers: { + selected: string | null + list: string[] + } +} + +export function cleanAccessoryBagUpgrades(data: typedHypixelApi.SkyBlockProfileMember): AccessoryBagUpgrades { + const tuningTemplates: Record<string, number>[] = [] + if (data.accessory_bag_storage) + for (const [key, template] of Object.entries(data.accessory_bag_storage?.tuning)) { + if (key.startsWith('slot_')) + tuningTemplates.push(template as Record<string, number>) + } + + let upgradesPurchased = data.accessory_bag_storage?.bag_upgrades_purchased ?? 0 + let upgradesCoinsSpent = 0 + let upgradesExtraSlots = upgradesPurchased * 2 + for (let i = 1; i <= upgradesPurchased; i++) { + if (i == 1) + upgradesCoinsSpent += 1_500_000 + else if (i <= 5) + upgradesCoinsSpent += 5_000_000 + else if (i <= 10) + upgradesCoinsSpent += 8_000_000 + else if (i <= 20) + upgradesCoinsSpent += 12_000_000 + else + upgradesCoinsSpent += 20_000_000 + } + + return { + tuningTemplates, + upgrades: { + purchased: upgradesPurchased, + coinsSpent: upgradesCoinsSpent, + extraSlots: upgradesExtraSlots + }, + powers: { + selected: data.accessory_bag_storage?.selected_power ?? null, + list: data.accessory_bag_storage?.unlocked_powers ?? [] + } + } +} |