aboutsummaryrefslogtreecommitdiff
path: root/src/cleaners
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-04-09 19:38:54 -0500
committermat <github@matdoes.dev>2022-04-09 19:38:54 -0500
commit6d08f7f8c91b31e27ff44162b7837751405ec67d (patch)
treedb9c3918819621c22a4a9b83a12f95586e7aff70 /src/cleaners
parent58e2fa480e127c30a04dc81256f462b7ad206eb9 (diff)
downloadskyblock-api-6d08f7f8c91b31e27ff44162b7837751405ec67d.tar.gz
skyblock-api-6d08f7f8c91b31e27ff44162b7837751405ec67d.tar.bz2
skyblock-api-6d08f7f8c91b31e27ff44162b7837751405ec67d.zip
oops lol i broke everything
Diffstat (limited to 'src/cleaners')
-rw-r--r--src/cleaners/skyblock/bank.ts8
-rw-r--r--src/cleaners/skyblock/gameMode.ts4
-rw-r--r--src/cleaners/skyblock/pets.ts7
3 files changed, 10 insertions, 9 deletions
diff --git a/src/cleaners/skyblock/bank.ts b/src/cleaners/skyblock/bank.ts
index ac46867..50770e7 100644
--- a/src/cleaners/skyblock/bank.ts
+++ b/src/cleaners/skyblock/bank.ts
@@ -15,6 +15,12 @@ export interface BankHistoryItem {
export function cleanBank(data: typedHypixelApi.SkyBlockProfile): Bank {
let history: BankHistoryItem[] = []
+ if (!(data?.banking && 'transactions' in data?.banking)) {
+ return {
+ history: [],
+ balance: undefined
+ }
+ }
if (data?.banking?.transactions) {
let bankBalance = Math.round(data.banking.balance * 10) / 10
@@ -35,7 +41,7 @@ export function cleanBank(data: typedHypixelApi.SkyBlockProfile): Bank {
// history.reverse()
return {
- balance: data?.banking?.balance ? Math.round(data.banking.balance * 10) / 10 : undefined,
+ balance: (data?.banking && 'balance' in data.banking && data.banking.balance) ? Math.round(data.banking.balance * 10) / 10 : undefined,
history
}
} \ No newline at end of file
diff --git a/src/cleaners/skyblock/gameMode.ts b/src/cleaners/skyblock/gameMode.ts
index 635c00a..4c98d10 100644
--- a/src/cleaners/skyblock/gameMode.ts
+++ b/src/cleaners/skyblock/gameMode.ts
@@ -1,8 +1,4 @@
import typedHypixelApi from 'typed-hypixel-api'
-import { fetchItemList } from '../../hypixel.js'
-import { levelFromXpTable } from '../../util.js'
-import { fetchPets } from '../../constants.js'
-import { ItemListItem } from './itemList.js'
export type GameMode = 'normal' | 'stranded' | 'bingo' | 'ironman'
const gameModeMap: Record<NonNullable<typedHypixelApi.SkyBlockProfile['game_mode']>, GameMode> = {
diff --git a/src/cleaners/skyblock/pets.ts b/src/cleaners/skyblock/pets.ts
index 4c0fe4a..ac8d587 100644
--- a/src/cleaners/skyblock/pets.ts
+++ b/src/cleaners/skyblock/pets.ts
@@ -10,20 +10,19 @@ const PET_LEVELS = [
100, 110, 120, 130, 145, 160, 175, 190, 210, 230, 250, 275, 300, 330, 360, 400, 440, 490, 540, 600, 660, 730, 800, 880, 960, 1050, 1150, 1260, 1380, 1510, 1650, 1800, 1960, 2130, 2310, 2500, 2700, 2920, 3160, 3420, 3700, 4000, 4350, 4750, 5200, 5700, 6300, 7000, 7800, 8700, 9700, 10800, 12000, 13300, 14700, 16200, 17800, 19500, 21300, 23200, 25200, 27400, 29800, 32400, 35200, 38200, 41400, 44800, 48400, 52200, 56200, 60400, 64800, 69400, 74200, 79200, 84700, 90700, 97200, 104200, 111700, 119700, 128200, 137200, 146700, 156700, 167700, 179700, 192700, 206700, 221700, 237700, 254700, 272700, 291700, 311700, 333700, 357700, 383700, 411700, 441700, 476700, 516700, 561700, 611700, 666700, 726700, 791700, 861700, 936700, 1016700, 1101700, 1191700, 1286700, 1386700, 1496700, 1616700, 1746700, 1886700
]
-const PET_RARITY_OFFSET: Record<typedHypixelApi.Pet['tier'], number> = {
+const PET_RARITY_OFFSET: Partial<Record<typedHypixelApi.Pet['tier'], number>> = {
COMMON: 0,
UNCOMMON: 6,
RARE: 11,
EPIC: 16,
- LEGENDARY: 20,
- MYTHIC: 20
+ LEGENDARY: 20
}
function calculateXpTable(rarity: keyof typeof PET_RARITY_OFFSET) {
const data = [0]
let current = 0
for (let i = 0; i < 100; i++) {
- current += PET_LEVELS[i + PET_RARITY_OFFSET[rarity]]
+ current += PET_LEVELS[i + ((rarity in PET_RARITY_OFFSET) ? PET_RARITY_OFFSET[rarity] : PET_RARITY_OFFSET['LEGENDARY'])!]
data.push(current)
}
return data