Skip to content
This repository has been archived by the owner on Oct 27, 2024. It is now read-only.

Commit

Permalink
fix error when accessory_bag_storage doesn't have tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
mat-1 committed Dec 23, 2023
1 parent 8d9f98b commit fc08668
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 24 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@ If you (this is really just here for myself so I don't forget) are adding a new
## Development

First, install the dependencies with `npm i`.
Then to run it, do `tsc -w` in one terminal, `npx nodemon build` in another. This makes it automatically restart when you make a change.
Then to run it, do `npx tsc -w` in one terminal, `npx nodemon build` in another. This makes it automatically restart when you make a change.
If you don't like it auto restarting, then just do `node build` instead of `npx nodemon build`.
It'll be running at [http://localhost:8080](http://localhost:8080)


## Terminology

Here's some words frequently used in the codebase that might potentially get confused:

- Profile: Sometimes known as a co-op, these contain one or more members.
- Member: Someone who is in a profile.
- Player: An individual account, it can be in multiple profiles and each instance of them in the profile is a different member.

6 changes: 2 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 13 additions & 17 deletions src/cleaners/skyblock/accessoryBagUpgrades.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,36 @@ export interface AccessoryBagUpgrades {
}
}

export function cleanAccessoryBagUpgrades(data: typedHypixelApi.SkyBlockProfileMember): AccessoryBagUpgrades {
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>)
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
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
extraSlots: upgradesExtraSlots,
},
powers: {
selected: data.accessory_bag_storage?.selected_power ?? null,
list: data.accessory_bag_storage?.unlocked_powers ?? []
}
list: data.accessory_bag_storage?.unlocked_powers ?? [],
},
}
}

0 comments on commit fc08668

Please sign in to comment.