From befd2530c6267d507bdbc2f5f9a9538bee9507c7 Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 23 Apr 2022 20:43:32 -0500 Subject: [PATCH] Fully test the items endpoint --- package.json | 2 +- src/responses/resources/skyblock/items.ts | 166 ++++++++++++++++++++-- test/index.js | 10 +- 3 files changed, 159 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 9453883..d461834 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "typed-hypixel-api", - "version": "1.2.0", + "version": "1.3.0", "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 d0f2f67..e300e7f 100644 --- a/src/responses/resources/skyblock/items.ts +++ b/src/responses/resources/skyblock/items.ts @@ -1,28 +1,89 @@ import { SkyBlockSlayerBosses } from '../../skyblock/_profile_member' -type EssenceType = 'DIAMOND' +type EssenceType = + | 'DIAMOND' + | 'WITHER' + | 'GOLD' + | 'CRIMSON' + | 'UNDEAD' + | 'DRAGON' + | 'SPIDER' + | 'ICE' +type GemstoneType = + | 'AMETHYST' + | 'JASPER' + | 'RUBY' + | 'JADE' + | 'AMBER' + | 'SAPPHIRE' + | 'TOPAZ' + | 'OPAL' export interface SkyBlockItemsResponse { success: true lastUpdated: number items: ({ material: string + /** A record of enchantment ids like `counter_strike` to their default level. */ + enchantments?: Record durability?: number + item_durability?: -1 name: string glowing?: boolean furniture?: string category?: string + /** If the item is a floating crystal, this will be present. */ + crystal?: + | 'FISHING' + | 'FARM' + | 'RESOURCE_REGENERATOR' + | 'FOREST_ISLAND' + | 'WHEAT_ISLAND' + | 'WOODCUTTING' + | 'DESERT_ISLAND' + | 'MITHRIL' + | 'NETHER_WART_ISLAND' tier?: string - unstackable?: boolean + /** + * Almost no items have this. Formatting codes here look like + * `%%gray%%`. + */ + description?: string + unstackable?: true + can_have_attributes?: true + salvageable_from_recipe?: true + salvages?: ( + | { + essence_type: EssenceType + amount: number + } + | { + item_id: string + amount: number + } + )[] stats?: { DAMAGE?: number STRENGTH?: number - DEFENSE?: Number + DEFENSE?: number HEALTH?: number MINING_FORTUNE?: number WALK_SPEED?: number MAGIC_FIND?: number + INTELLIGENCE?: number + WEAPON_ABILITY_DAMAGE?: number + CRITICAL_DAMAGE?: number + CRITICAL_CHANCE?: number + SEA_CREATURE_CHANCE?: number + FEROCITY?: number + BREAKING_POWER?: number + MINING_SPEED?: number + PET_LUCK?: number + ABILITY_DAMAGE_PERCENT?: number + TRUE_DEFENSE?: number + ATTACK_SPEED?: number } + ability_damage_scaling?: number /** * The number of coins that the player gets from selling the item to * an NPC. @@ -36,20 +97,41 @@ export interface SkyBlockItemsResponse { essence_type: EssenceType amount: number } - upgrade_costs?: [ - { - essence_type: EssenceType - amount: number - } - ][] + upgrade_costs?: ( + | { + essence_type: EssenceType + amount: number + } + | { + item_id: string + amount: number + } + )[][] + prestige?: { + /** An item id like BURNING_AURORA_LEGGINGS. */ + item_id: string + costs: ( + | { + essence_type: EssenceType + amount: number + } + | { + item_id: string + amount: number + } + )[] + } gemstone_slots?: { - slot_type: 'AMETHYST' | 'COMBAT' + slot_type: GemstoneType | 'UNIVERSAL' | 'MINING' | 'COMBAT' | 'DEFENSIVE' | 'OFFENSIVE' costs?: ( | { coins: number } | { - item_id: `FINE_${string}_GEM` + item_id: + | `FINE_${GemstoneType}_GEM` + | `FLAWLESS_${GemstoneType}_GEM` + | 'GEMSTONE_CHAMBER' amount: number } )[] @@ -65,8 +147,25 @@ export interface SkyBlockItemsResponse { } } tiered_stats?: { - WALK_SPEED: number[] - DEFENSE: number[] + DAMAGE?: number[] + STRENGTH?: number[] + DEFENSE?: number[] + HEALTH?: number[] + MINING_FORTUNE?: number[] + WALK_SPEED?: number[] + MAGIC_FIND?: number[] + INTELLIGENCE?: number[] + WEAPON_ABILITY_DAMAGE?: number[] + CRITICAL_DAMAGE?: number[] + CRITICAL_CHANCE?: number[] + SEA_CREATURE_CHANCE?: number[] + FEROCITY?: number[] + BREAKING_POWER?: number[] + MINING_SPEED?: number[] + PET_LUCK?: number[] + ABILITY_DAMAGE_PERCENT?: number[] + TRUE_DEFENSE?: number[] + ATTACK_SPEED?: number[] } requirements?: { /** If present, you need a specific level in a dungeon. */ @@ -74,6 +173,10 @@ export interface SkyBlockItemsResponse { type: 'CATACOMBS' level: number } + dungeon_completion?: { + type: 'CATACOMBS' + tier: number + } /** * If present, a reputation with one of the factions from * the nether is required. @@ -89,17 +192,50 @@ export interface SkyBlockItemsResponse { slayer_boss_type: SkyBlockSlayerBosses level: number } + skill?: { + /** A skill id in all caps, like "FISHING". */ + type: string + level: number + } + trophy_fishing_reward?: { + reward: 'BRONZE' | 'SILVER' | 'GOLD' | 'DIAMOND' + } + heart_of_the_mountain?: { + tier: number + } + collection?: { + /** A collection id, in all caps. */ + collection_id: string + required_tier: number + } + target_practice?: { + mode: 'I' | 'II' | 'III' + } } dungeon_item?: boolean /** - * If this is 'COOP', that means the item cannot be transferred to anyone outside the coop. + * If this is 'COOP', that means the item cannot be transferred to + * anyone outside the coop. If it's `SOLO`, it can't even be given to + * anyone in the coop. */ - soulbound?: 'COOP' + soulbound?: 'COOP' | 'SOLO' + salvage?: { + item_id: string + amount: number + } /** * Whether the item can be put on display in the museum. * https://hypixel-skyblock.fandom.com/wiki/Museum */ museum?: true + gear_score?: number + /** + * If this is present that means the item is an island spawner, its + * value is the uppercase id of it like `MINING_FOREST`. Note that this + * is *not* the same as the `id` field, for example in this case the + * `id` is `ROOFED_FOREST_ISLAND`. + * */ + private_island?: string id: string } & ( | { diff --git a/test/index.js b/test/index.js index 1cf43c8..e096af7 100644 --- a/test/index.js +++ b/test/index.js @@ -92,10 +92,14 @@ 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)) - let itemsResponse = await request('resources/skyblock/items', {}, true) // we have to do this otherwise typescript gets mad :( - itemsResponse.data.items = itemsResponse.data.items.slice(0, 1000) - await testData('SkyBlockItemsResponse', itemsResponse) + 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',