From b3010e565fe7e984f5a913e8a4167a3cb6810090 Mon Sep 17 00:00:00 2001 From: mat Date: Sun, 15 May 2022 14:38:18 -0500 Subject: add accessory bag upgrades --- package-lock.json | 14 ++++---- package.json | 2 +- src/cleaners/skyblock/accessoryBagUpgrades.ts | 52 +++++++++++++++++++++++++++ src/cleaners/skyblock/inventory.ts | 2 +- src/cleaners/skyblock/member.ts | 4 +++ 5 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 src/cleaners/skyblock/accessoryBagUpgrades.ts diff --git a/package-lock.json b/package-lock.json index 19e2fca..1a12587 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "prismarine-nbt": "github:PrismarineJS/prismarine-nbt", "prom-client": "^14.0.1", "queue-promise": "^2.2.1", - "typed-hypixel-api": "^1.3.1", + "typed-hypixel-api": "^1.4.0", "uuid": "^8.3.2" }, "devDependencies": { @@ -2734,9 +2734,9 @@ } }, "node_modules/typed-hypixel-api": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/typed-hypixel-api/-/typed-hypixel-api-1.3.1.tgz", - "integrity": "sha512-sgiAda+DwkzUq1aGMkFYRjBZJ4+WTcAqMrOEH1YdAzUl4SZUB+nH1dir3dEa/Ol+uC3PB6hKW/PS51MyeDxLDQ==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/typed-hypixel-api/-/typed-hypixel-api-1.4.0.tgz", + "integrity": "sha512-XhU8CugljxGqleacjRjP7JBYDuxSuIofy+Fx+lHfn6UIzzXm9lQNBaPzSE5lZNV97l4XQafIU3qzbBG/9Ky79A==", "dependencies": { "typescript": "^4.6.3", "undici": "^4.16.0" @@ -5070,9 +5070,9 @@ } }, "typed-hypixel-api": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/typed-hypixel-api/-/typed-hypixel-api-1.3.1.tgz", - "integrity": "sha512-sgiAda+DwkzUq1aGMkFYRjBZJ4+WTcAqMrOEH1YdAzUl4SZUB+nH1dir3dEa/Ol+uC3PB6hKW/PS51MyeDxLDQ==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/typed-hypixel-api/-/typed-hypixel-api-1.4.0.tgz", + "integrity": "sha512-XhU8CugljxGqleacjRjP7JBYDuxSuIofy+Fx+lHfn6UIzzXm9lQNBaPzSE5lZNV97l4XQafIU3qzbBG/9Ky79A==", "requires": { "typescript": "^4.6.3", "undici": "^4.16.0" diff --git a/package.json b/package.json index 2d9efef..39e6cd8 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "prismarine-nbt": "github:PrismarineJS/prismarine-nbt", "prom-client": "^14.0.1", "queue-promise": "^2.2.1", - "typed-hypixel-api": "^1.3.1", + "typed-hypixel-api": "^1.4.0", "uuid": "^8.3.2" }, "devDependencies": { 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[] + upgrades: { + purchased: number + coinsSpent: number + extraSlots: number + } + powers: { + selected: string | null + list: string[] + } +} + +export function cleanAccessoryBagUpgrades(data: typedHypixelApi.SkyBlockProfileMember): AccessoryBagUpgrades { + const tuningTemplates: Record[] = [] + 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) + } + + 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 ?? [] + } + } +} diff --git a/src/cleaners/skyblock/inventory.ts b/src/cleaners/skyblock/inventory.ts index 6be87c8..447ebdd 100644 --- a/src/cleaners/skyblock/inventory.ts +++ b/src/cleaners/skyblock/inventory.ts @@ -94,7 +94,7 @@ export const INVENTORIES = { armor: 'inv_armor', inventory: 'inv_contents', ender_chest: 'ender_chest_contents', - talisman_bag: 'talisman_bag', + talisman_bag: 'accessory_bag', potion_bag: 'potion_bag', fishing_bag: 'fishing_bag', quiver: 'quiver', diff --git a/src/cleaners/skyblock/member.ts b/src/cleaners/skyblock/member.ts index 6b2f452..f2526d2 100644 --- a/src/cleaners/skyblock/member.ts +++ b/src/cleaners/skyblock/member.ts @@ -19,6 +19,7 @@ import * as constants from '../../constants.js' import { Included } from '../../hypixel.js' import { CleanPlayer } from '../player.js' import { CleanRank } from '../rank.js' +import { AccessoryBagUpgrades, cleanAccessoryBagUpgrades } from './accessoryBagUpgrades.js' export interface CleanBasicMember { uuid: string @@ -45,6 +46,7 @@ export interface CleanMember extends CleanBasicMember { harp: HarpData coopInvitation: CoopInvitation | null farmingContests: FarmingContests + accessoryBagUpgrades: AccessoryBagUpgrades /** Whether the user left the coop */ left: boolean } @@ -110,6 +112,7 @@ export async function cleanSkyBlockProfileMemberResponse(member: typedHypixelApi harp: await harpPromise, coopInvitation: await coopInvitationPromise, farmingContests: await farmingContestsPromise, + accessoryBagUpgrades: cleanAccessoryBagUpgrades(member), left: (player.profiles?.find(profile => profile.uuid === profileId) === undefined) ?? false } @@ -136,6 +139,7 @@ export interface CleanMemberProfilePlayer extends CleanPlayer { harp: HarpData coopInvitation: CoopInvitation | null farmingContests: FarmingContests + accessoryBagUpgrades: AccessoryBagUpgrades left: boolean } -- cgit