From 39c13003d473a525dc9bd3ff09b36e5fe7e504d3 Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 23 Apr 2022 20:52:37 -0500 Subject: [PATCH] make catacombs_requirements more specific fix catacombs_requirements and requirements.dungeon not being able to be merged --- package.json | 2 +- src/responses/resources/skyblock/items.ts | 8 ++++++-- test/index.js | 19 ++++++++++--------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index d461834..5d4dcd9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "typed-hypixel-api", - "version": "1.3.0", + "version": "1.3.1", "main": "build/index.js", "types": "build/index.d.js", "repository": "https://github.com/skyblockstats/typed-hypixel-api.git", diff --git a/src/responses/resources/skyblock/items.ts b/src/responses/resources/skyblock/items.ts index e300e7f..7d9c005 100644 --- a/src/responses/resources/skyblock/items.ts +++ b/src/responses/resources/skyblock/items.ts @@ -140,9 +140,10 @@ export interface SkyBlockItemsResponse { essence_type: string costs: number[] } + /** I don't know why this is its own field, this can be used as a fallback if requirements.dungeon is missing. */ catacombs_requirements?: { dungeon: { - type: string + type: 'CATACOMBS' level: number } } @@ -168,7 +169,10 @@ export interface SkyBlockItemsResponse { ATTACK_SPEED?: number[] } requirements?: { - /** If present, you need a specific level in a dungeon. */ + /** + * If present, you need a specific level in a dungeon. Note that + * sometimes `catacombs_requirements` is used instead of this field. + */ dungeon?: { type: 'CATACOMBS' level: number diff --git a/test/index.js b/test/index.js index e096af7..581fe33 100644 --- a/test/index.js +++ b/test/index.js @@ -34,6 +34,16 @@ console.log('\x1b[1m%s\x1b[0m', 'Running tests. This will take a few minutes, be const startTime = Date.now(); (async () => { + + // we have to do this otherwise typescript gets mad :( + const itemsResponse = await request('resources/skyblock/items', {}, true) + const originalItems = itemsResponse.data.items + for (let i = 0; i < originalItems.length / 1000; i++) { + itemsResponse.data.items = originalItems.slice(i * 1000, (i + 1) * 1000) + await testData('SkyBlockItemsResponse', itemsResponse) + } + + await testData('SkyBlockPlayerBingoResponse', await request('skyblock/bingo', { key: process.env.API_KEY, uuid: 'e471665f71014891bef337c8d22cf04b' @@ -92,15 +102,6 @@ const startTime = Date.now(); await testData('SkyBlockNewsResponse', await request('skyblock/news', { key: process.env.API_KEY }, true)) await testData('SkyBlockBazaarResponse', await request('skyblock/bazaar', {}, true)) - // we have to do this otherwise typescript gets mad :( - const itemsResponse = await request('resources/skyblock/items', {}, true) - const originalItems = itemsResponse.data.items - for (let i = 0; i < originalItems.length / 1000; i++) { - itemsResponse.data.items = originalItems.slice(i * 1000, (i + 1) * 1000) - await testData('SkyBlockItemsResponse', itemsResponse) - } - - await testData('PlayerDataResponse', await request('player', { uuid: 'ed32a0660fc948378dcf8ed717d1188c', key: process.env.API_KEY