From 35976a074b92f78662f81da7aa0e8a27f1a36a04 Mon Sep 17 00:00:00 2001 From: DuckySoLucky Date: Tue, 28 Mar 2023 19:33:10 +0200 Subject: [PATCH 01/12] feat: add sacks (not done) --- public/resources/ts/stats-defer.ts | 1 + src/constants.js | 1 + src/constants/sacks.js | 337 +++++++++++++++++++++++++++++ src/lib.js | 128 ++++++++++- views/stats.ejs | 6 + 5 files changed, 472 insertions(+), 1 deletion(-) create mode 100644 src/constants/sacks.js diff --git a/public/resources/ts/stats-defer.ts b/public/resources/ts/stats-defer.ts index deb2a7013a..79e4a582dd 100644 --- a/public/resources/ts/stats-defer.ts +++ b/public/resources/ts/stats-defer.ts @@ -124,6 +124,7 @@ export const ALL_ITEMS = new Map( items.wardrobe_inventory, items.storage, items.hotm, + items.sacks, ] .flat() .flatMap((item) => { diff --git a/src/constants.js b/src/constants.js index 33f20d9dcf..6e68f1128e 100644 --- a/src/constants.js +++ b/src/constants.js @@ -19,3 +19,4 @@ export * from "./constants/skills.js"; export * from "./constants/skins-animations.js"; export * from "./constants/tags.js"; export * from "./constants/accessories.js"; +export * from "./constants/sacks.js"; diff --git a/src/constants/sacks.js b/src/constants/sacks.js new file mode 100644 index 0000000000..0dee349b6b --- /dev/null +++ b/src/constants/sacks.js @@ -0,0 +1,337 @@ +export const SACKS = { + AGRONOMY_SACK: { + items: [ + "WHEAT", + "SEEDS", + "CARROT_ITEM", + "POTATO_ITEM", + "PUMPKIN", + "MELON", + "RED_MUSHROOM", + "BROWN_MUSHROOM", + "INK_SACK:3", + "CACTUS", + "SUGAR_CANE", + "NETHER_STALK", + ], + texture: "ef835b8941fe319931749b87fe8e84c5d1f4a271b5fbce5e700a60004d881f79", + }, + ENCHANTED_AGRONOMY_SACK: { + items: [ + "ENCHANTED_BREAD", + "ENCHANTED_BROWN_MUSHROOM", + "ENCHANTED_CACTUS", + "ENCHANTED_CARROT", + "ENCHANTED_COCOA", + "ENCHANTED_MELON", + "ENCHANTED_NETHER_STALK", + "ENCHANTED_POTATO", + "ENCHANTED_PUMPKIN", + "ENCHANTED_RED_MUSHROOM", + "ENCHANTED_SEEDS", + "ENCHANTED_SUGAR", + ], + texture: "184d2ff1e177357574f9f71e19397fff3a210a94e78c0d2a4360cc5df1eb807b", + }, + HUSBANDRY_SACK: { + items: ["FEATHER", "LEATHER", "PORK", "RAW_CHICKEN", "MUTTON", "RABBIT", "RAW_BEEF", "RABBIT_HIDE", "RABBIT_FOOT"], + texture: "c73087f1e654b1682733584a44097587fb942e1f343aae8307bd7dac84e843ab", + }, + ENCHANTED_HUSBANDRY_SACK: { + items: [ + "ENCHANTED_FEATHER", + "ENCHANTED_LEATHER", + "ENCHANTED_PORK", + "ENCHANTED_RAW_CHICKEN", + "ENCHANTED_EGG", + "ENCHANTED_MUTTON", + "ENCHANTED_RABBIT", + "ENCHANTED_RAW_BEEF", + "ENCHANTED_RABBIT_HIDE", + "ENCHANTED_RABBIT_FOOT", + ], + texture: "746a6063263ba7208a2a06cef73234791c92d5f67080a365508b02483eefaf9a", + }, + MINING_SACK: { + items: [ + "COBBLESTONE", + "COAL", + "IRON_INGOT", + "GOLD_INGOT", + "DIAMOND", + "INK_SACK:4", + "EMERALD", + "REDSTONE", + "QUARTZ", + "OBSIDIAN", + "GLOWSTONE_DUST", + "GRAVEL", + "ICE", + "NETHERRACK", + "SAND", + "ENDER_STONE", + "MITHRIL_ORE", + "HARD_STONE", + "TITANIUM_ORE", + "TREASURITE", + "STARFALL", + ], + texture: "915fcebbbe02fdb72acd2095d9edfcea095e604b3682db88963b5b83b2939b67", + }, + ENCHANTED_MINING_SACK: { + items: [ + "ENCHANTED_COAL", + "ENCHANTED_COBBLESTONE", + "ENCHANTED_DIAMOND", + "ENCHANTED_EMERALD", + "ENCHANTED_ENDSTONE", + "ENCHANTED_FLINT", + "ENCHANTED_GLOWSTONE_DUST", + "ENCHANTED_GOLD", + "ENCHANTED_HARD_STONE", + "ENCHANTED_IRON", + "ENCHANTED_LAPIS_LAZULI", + "ENCHANTED_MITHRIL", + "ENCHANTED_NETHERRACK", + "ENCHANTED_OBSIDIAN", + "ENCHANTED_QUARTZ", + "ENCHANTED_REDSTONE", + "ENCHANTED_SAND", + "ENCHANTED_TITANIUM", + ], + texture: "eedc69fefad184ee8c9186928da982addfd783bed98d95083408bf419e0cccd0", + }, + GEMSTONE_SACK: { + items: [ + "ROUGH_AMBER_GEM", + "FLAWED_AMBER_GEM", + "FINE_AMBER_GEM", + "FLAWLESS_AMBER_GEM", + "PERFECT_AMBER_GEM", + "ROUGH_TOPAZ_GEM", + "FLAWED_TOPAZ_GEM", + "FINE_TOPAZ_GEM", + "FLAWLESS_TOPAZ_GEM", + "PERFECT_TOPAZ_GEM", + "ROUGH_SAPPHIRE_GEM", + "FLAWED_SAPPHIRE_GEM", + "FINE_SAPPHIRE_GEM", + "FLAWLESS_SAPPHIRE_GEM", + "PERFECT_SAPPHIRE_GEM", + "ROUGH_AMETHYST_GEM", + "FLAWED_AMETHYST_GEM", + "FINE_AMETHYST_GEM", + "FLAWLESS_AMETHYST_GEM", + "PERFECT_AMETHYST_GEM", + "ROUGH_JASPER_GEM", + "FLAWED_JASPER_GEM", + "FINE_JASPER_GEM", + "FLAWLESS_JASPER_GEM", + "PERFECT_JASPER_GEM", + "ROUGH_RUBY_GEM", + "FLAWED_RUBY_GEM", + "FINE_RUBY_GEM", + "FLAWLESS_RUBY_GEM", + "PERFECT_RUBY_GEM", + "ROUGH_JADE_GEM", + "FLAWED_JADE_GEM", + "FINE_JADE_GEM", + "FLAWLESS_JADE_GEM", + "PERFECT_JADE_GEM", + "ROUGH_OPAL_GEM", + "FLAWED_OPAL_GEM", + "FINE_OPAL_GEM", + "FLAWLESS_OPAL_GEM", + "PERFECT_OPAL_GEM", + ], + texture: "95ba804b7ae92c65b2f41d18be899a3bd139772e3e3c81c2fc8addbb27536952", + }, + COMBAT_SACK: { + items: [ + "ROTTEN_FLESH", + "BONE", + "STRING", + "SPIDER_EYE", + "SULPHUR", + "ENDER_PEARL", + "GHAST_TEAR", + "SLIME_BALL", + "BLAZE_ROD", + "MAGMA_CREAM", + ], + texture: "1c13c4774c82c07071e6d1408717b1e3eac56186042a5803fc174452e32a254a", + }, + ENCHANTED_COMBAT_SACK: { + items: [ + "ENCHANTED_BLAZE_POWDER", + "ENCHANTED_BONE", + "ENCHANTED_ENDER_PEARL", + "ENCHANTED_GHAST_TEAR", + "ENCHANTED_GUNPOWDER", + "ENCHANTED_MAGMA_CREAM", + "ENCHANTED_ROTTEN_FLESH", + "ENCHANTED_SLIME_BALL", + "ENCHANTED_SPIDER_EYE", + "ENCHANTED_STRING", + ], + texture: "c2a3420697256517d5361b3463019647c0689725b3489f9dd24a22ddd40bd41f", + }, + FORAGING_SACK: { + items: [ + "LOG", + "LOG:1", + "LOG:2", + "LOG_2:1", + "LOG_2", + "LOG:3", + "SAPLING", + "SAPLING:1", + "SAPLING:2", + "SAPLING:5", + "SAPLING:4", + "SAPLING:3", + "APPLE", + ], + texture: "2c6e24df498ba4a589c259d9fc0d3db348f93cdf26a5fe461571c1da706efaf3", + }, + ENCHANTED_FORAGING_SACK: { + items: [ + "ENCHANTED_OAK_LOG", + "ENCHANTED_SPRUCE_LOG", + "ENCHANTED_BIRCH_LOG", + "ENCHANTED_DARK_OAK_LOG", + "ENCHANTED_ACACIA_LOG", + "ENCHANTED_JUNGLE_LOG", + ], + texture: "35326464c6a79362730d79fe4611b911353c1b3c5144177773591357f1cd5ca1", + }, + FISHING_SACK: { + items: [ + "RAW_FISH", + "RAW_FISH:1", + "RAW_FISH:2", + "RAW_FISH:3", + "PRISMARINE_SHARD", + "PRISMARINE_CRYSTALS", + "CLAY", + "WATER_LILY", + "INK_SACK", + "SPONGE", + ], + texture: "f8f68669351a6fc7156ecfe3300ba94efe0766e24bed8785cf64a9f95435134b", + }, + ENCHANTED_FISHING_SACK: { + items: [ + "ENCHANTED_CLAY_BALL", + "ENCHANTED_CLOWNFISH", + "ENCHANTED_INK_SACK", + "ENCHANTED_PUFFERFISH", + "ENCHANTED_RAW_FISH", + "ENCHANTED_RAW_SALMON", + "ENCHANTED_SPONGE", + "ENCHANTED_WATER_LILY", + "ENCHANTED_PRISMARINE_CRYSTALS", + "ENCHANTED_PRISMARINE_SHARD", + ], + texture: "ee2469de7f75d2e0a8b3b0c734a2b470782b604d1feb0172b4a72a77cb5bbda2", + }, + LAVA_FISHING_SACK: { + items: [ + "MAGMA_FISH", + "MAGMA_CREAM", + "COAL", + "BLAZE_POWDER", + "NETHERRACK", + "MOOGMA_PELT", + "PYROCLASTIC_SCALE", + "FLAMING_HEART", + "LUMP_OF_MAGMA", + "CUP_OF_BLOOD", + "ORB_OF_ENERGY", + "HORN_OF_TAURUS", + ], + texture: "da2a951592cc26cf5b6d9f66ae034916f9d2e97216d43b3fa11c979afd7df1ad", + }, + NETHER_SACK: { + items: [ + "SULPHUR_ORE", + "SAND:1", + "MYCEL", + "ECTOPLASM", + "NETHERRACK", + "MAGMA_CREAM", + "BLAZE_ROD", + "GHAST_TEAR", + "QUARTZ", + "GLOWSTONE_DUST", + "NETHER_STALK", + "SPECTRE_DUST", + "BLAZE_ASHES", + "MUTATED_BLAZE_ASHES", + "WITHER_SOUL", + "MAGMA_CHUNK", + "BEZOS", + "BURNING_EYE", + "TENTACLE_MEAT", + "DIGESTED_MUSHROOMS", + "KADA_LEAD", + "MAGMAG", + "GAZING_PEARL", + "LEATHER_CLOTH", + "SPELL_POWDER", + "COMPACT_OOZE", + "LUMINO_FIBER", + "HALLOWED_SKULL", + "CORRUPTED_FRAGMENT", + ], + texture: "e345875e921a145f92038858aeecc3c2f083441ebc5c8265d31a281d268e365b", + }, + DUNGEON_SACK: { + items: ["SPIRIT_LEAP", "DUNGEON_TRAP", "INFLATABLE_JERRY", "DUNGEON_DECOY"], + texture: "fb96c585ccd35f073da38d165cb9bb18ff136f1a184eee3f44725354640ebbd4", + }, + RUNE_SACK: { + items: ["RUNE"], + texture: "e91eb4ee3ecce3447483a1f151c11facc9de25577ab7b51fbf3d9c2b2a4b69fc", + }, + SLAYER_SACK: { + items: [ + "TARANTULA_WEB", + "SPIDER_CATALYST", + "UNDEAD_CATALYST", + "REVENANT_CATALYST", + "NULL_SPHERE", + "RAW_SOULFLOW", + "SOULFLOW", + "DERELICT_ASHE", + "CRUDE_GABAGOOL", + ], + texture: "c0ccbd15d76a748e08926ef6d21dc3e54d9adec766cc25019531a493b1fd4b44", + }, + SPOOKY_SACK: { + items: ["GREEN_CANDY", "PURPLE_CANDY", "PUMPKIN_GUTS", "ECTOPLASM", "WEREWOLF_SKIN"], + texture: "12ef39437d7d43a034c5a40b974e8d2c6734a218c76485d04910f507bdc2e809", + }, + WINTER_SACK: { + items: [ + "WHITE_GIFT", + "GREEN_GIFT", + "RED_GIFT", + "SNOW_BLOCK", + "ENCHANTED_SNOW_BLOCK", + "SNOW_BALL", + "ICE", + "ENCHANTED_ICE", + "PACKED_ICE", + "ENCHANTED_PACKED_ICE", + "HUNK_OF_ICE", + "HUNK_OF_BLUE_ICE", + ], + texture: "ab339b1cd40053defd7d3528e01fea876d41b42f9d9268461da79f5f66771236", + }, +}; + +export const ITEM_SACKS = { + HUNK_OF_BLUE_ICE: "BLUE_ICE_HUNK", + HUNK_OF_ICE: "ICE_HUNK", +}; diff --git a/src/lib.js b/src/lib.js index b999fa6cc7..5b7bf26079 100644 --- a/src/lib.js +++ b/src/lib.js @@ -974,6 +974,21 @@ export const getItems = async ( output.storage = storage; output.hotm = hotm; output.candy_bag = candy_bag; + + const sacks = "sacks_counts" in profile ? await getSacks(profile.sacks_counts, armor.concat( + equipment, + inventory, + enderchest, + accessory_bag, + fishing_bag, + quiver, + potion_bag, + personal_vault, + wardrobe_inventory, + storage, + hotm, + )) : []; + output.sacks = sacks; const allItems = armor.concat( equipment, @@ -986,7 +1001,8 @@ export const getItems = async ( personal_vault, wardrobe_inventory, storage, - hotm + hotm, + sacks ); for (const [index, item] of allItems.entries()) { @@ -2932,6 +2948,116 @@ export async function getCollections(uuid, profile, cacheOnly = false) { return output; } +const BASE_SACK = { + Count: 1, + Damage: 3, + id: 397, + rarity: "epic", +}; + +// eslint-disable-next-line @typescript-eslint/naming-convention +async function getSacks(sacks_counts, items) { + const sacks = []; + + const timeNow = Date.now(); + for (const sackId in constants.SACKS) { + const sack = constants.SACKS[sackId]; + + if (sack.items.filter((a) => Object.keys(sacks_counts).includes(a)).length == 0) { + continue; + } + + const sackItem = Object.assign({}, BASE_SACK); + + sackItem.texture_path = `/head/${sack.texture}`; + sackItem.display_name = _.startCase(sackId.toLowerCase()); + sackItem.tag = { + display: { + Lore: [], + Name: `§5${sackItem.display_name}`, + }, + }; + + + if (sackId == "GEMSTONE_SACK") { + /*let line = ''; + + for (const tier in gem_tiers) { + line += constants.RARITY_COLORS[gem_tiers[tier]]; + line += _.startCase(tier.toLowerCase()); + + if (tier != 'PERFECT') { + line += '§8 / '; + } + } + + sackItem.tag.display.Lore.push(line, ''); + + for (const gem in constants.gem_types) { + let line = constants.gem_types[gem]; + line += `${_.startCase(gem.toLowerCase())}§8: `; + + for (const tier in gem_tiers) { + line += constants.RARITY_COLORS[gem_tiers[tier]]; + line += (sacks_counts[`${tier}_${gem}_GEM`] ?? 0).toLocaleString(); + + if (tier != 'PERFECT') { + line += '§8 / '; + } + } + + sackItem.tag.display.Lore.push(line); + }*/ + } else { + sackItem.containsItems = []; + + for (const [index, item] of sack.items.entries()) { + const hypixelItem = await db.collection("items").findOne({ id: constants.ITEM_SACKS[item] ?? item }); + + const itemName = hypixelItem?.name ?? "Unknown"; + + const itemDescription = items.find((itemm) => { + if (itemm.tag?.ExtraAttributes?.id === sackId) { + console.log(itemm) + return itemm + } + }) + + const sackContent = { + Count: 1, + sack_count: sacks_counts[item] ?? 0, + Damage: hypixelItem?.damage ?? 3, + id: hypixelItem?.item_id ?? 397, + itemIndex: index, + display_name: itemName, + tag: { + display: { + Name: `§a${itemName}`, + Lore: [`§8Stored: §e${(sacks_counts[item] ?? 0).toLocaleString()}`], + }, + }, + categories: [], + }; + + if (hypixelItem?.glowing === true) { + sackContent.tag.ench = []; + } + + if (sackContent.id == 397 && hypixelItem?.texture) { + sackContent.texture_path = `/head/${hypixelItem.texture}`; + } + + sackItem.containsItems.push(sackContent); + } + } + + sacks.push(sackItem); + } + + console.log("Parsed sacks in " + Date.now() - timeNow + "ms") + return sacks; +} + export function getBestiary(uuid, profile) { const output = {}; diff --git a/views/stats.ejs b/views/stats.ejs index 685ecc32fe..fbfe12e69a 100644 --- a/views/stats.ejs +++ b/views/stats.ejs @@ -1448,6 +1448,12 @@ const metaDescription = getMetaDescription()
Quiver
<% } %> + <% if(items.sacks.length > 0){ %> +
+
+
Sacks
+
+ <% } %> From 4efe29e7a355497a3fed6acf312ad8169a7fdce6 Mon Sep 17 00:00:00 2001 From: DuckySoLucky Date: Thu, 30 Mar 2023 10:52:20 +0200 Subject: [PATCH 02/12] style: `pnpm run prettier:fix` --- public/resources/scss/stats.scss | 2 +- src/constants/sacks.js | 464 ++++++++++++++++++++++++++++++- src/lib.js | 96 +++---- views/stats.ejs | 9 +- 4 files changed, 513 insertions(+), 58 deletions(-) diff --git a/public/resources/scss/stats.scss b/public/resources/scss/stats.scss index f51d6842b1..5f46bbce34 100644 --- a/public/resources/scss/stats.scss +++ b/public/resources/scss/stats.scss @@ -1665,7 +1665,7 @@ a.additional-player-stat:hover { inventory-view { display: grid; place-content: center center; - --inventory-width: clamp(300px, calc(100vw - 40px), 700px); + --inventory-width: clamp(300px, calc(100vw - 40px), 760px); gap: calc(var(--inventory-width) * 0.01); padding: calc(var(--inventory-width) * 0.01); grid-template-columns: repeat(9, calc(var(--inventory-width) * 0.1)); diff --git a/src/constants/sacks.js b/src/constants/sacks.js index 0dee349b6b..1138fee8a8 100644 --- a/src/constants/sacks.js +++ b/src/constants/sacks.js @@ -291,7 +291,468 @@ export const SACKS = { texture: "fb96c585ccd35f073da38d165cb9bb18ff136f1a184eee3f44725354640ebbd4", }, RUNE_SACK: { - items: ["RUNE"], + items: { + "???": { + display_name: "§7◆ ??? Rune ?", + texture: "82b8207a5fe192cd477e921466197c8af749af18dd1ef389e2733a2f74d0928b", + tier: "common", + }, + RUNE_BITE_1: { + display_name: "◆ Bite Rune I", + texture: "43a1ad4fcc42fb63c681328e42d63c83ca193b333af2a426728a25a8cc600692", + tier: "epic", + }, + RUNE_BITE_2: { + display_name: "◆ Bite Rune II", + texture: "43a1ad4fcc42fb63c681328e42d63c83ca193b333af2a426728a25a8cc600692", + tier: "epic", + }, + RUNE_BITE_3: { + display_name: "◆ Bite Rune III", + texture: "43a1ad4fcc42fb63c681328e42d63c83ca193b333af2a426728a25a8cc600692", + tier: "epic", + }, + RUNE_BLOOD_2_1: { + display_name: "◆ Blood Rune I", + texture: "e02677053dc54245dac4b399d14aae21ee71a010bd9c336c8ecee1a0dbe8f58b", + tier: "common", + }, + RUNE_BLOOD_2_2: { + display_name: "◆ Blood Rune II", + texture: "e02677053dc54245dac4b399d14aae21ee71a010bd9c336c8ecee1a0dbe8f58b", + tier: "common", + }, + RUNE_BLOOD_2_3: { + display_name: "◆ Blood Rune III", + texture: "e02677053dc54245dac4b399d14aae21ee71a010bd9c336c8ecee1a0dbe8f58b", + tier: "common", + }, + RUNE_COUTURE_1: { + display_name: "◆ Couture Rune II", + texture: "734fb3203233efbae82628bd4fca7348cd071e5b7b52407f1d1d2794e31799ff", + tier: "legendary", + }, + RUNE_COUTURE_3: { + display_name: "◆ Couture Rune III", + texture: "734fb3203233efbae82628bd4fca7348cd071e5b7b52407f1d1d2794e31799ff", + tier: "legendary", + }, + RUNE_DRAGON_1: { + display_name: "◆ End Rune I", + texture: "3b11fb90db7f57beb435954013b1c7ef776c6bd96cbf3308aa8ebac29591ebbd", + tier: "epic", + }, + RUNE_DRAGON_2: { + display_name: "◆ End Rune II", + texture: "3b11fb90db7f57beb435954013b1c7ef776c6bd96cbf3308aa8ebac29591ebbd", + tier: "epic", + }, + RUNE_DRAGON_3: { + display_name: "◆ End Rune III", + texture: "3b11fb90db7f57beb435954013b1c7ef776c6bd96cbf3308aa8ebac29591ebbd", + tier: "epic", + }, + RUNE_ENCHANT_1: { + display_name: "◆ Enchant Rune I", + texture: "59ffacec6ee5a23d9cb24a2fe9dc15b24488f5f71006924560bf12148421ae6d", + tier: "legendary", + }, + RUNE_ENCHANT_2: { + display_name: "◆ Enchant Rune II", + texture: "59ffacec6ee5a23d9cb24a2fe9dc15b24488f5f71006924560bf12148421ae6d", + tier: "legendary", + }, + RUNE_ENCHANT_3: { + display_name: "◆ Enchant Rune III", + texture: "59ffacec6ee5a23d9cb24a2fe9dc15b24488f5f71006924560bf12148421ae6d", + tier: "legendary", + }, + RUNE_ENDERSNAKE_1: { + display_name: "◆ Endersnake Rune I", + texture: "c3a9acbb7d3d49b1d54d26111104d0da57d8b4ab37885b4bbd240ac71074cad2", + tier: "legendary", + }, + RUNE_ENDERSNAKE_2: { + display_name: "◆ Endersnake Rune II", + texture: "c3a9acbb7d3d49b1d54d26111104d0da57d8b4ab37885b4bbd240ac71074cad2", + tier: "legendary", + }, + RUNE_ENDERSNAKE_3: { + display_name: "◆ Endersnake Rune III", + texture: "c3a9acbb7d3d49b1d54d26111104d0da57d8b4ab37885b4bbd240ac71074cad2", + tier: "legendary", + }, + RUNE_FIERY_BURST_1: { + display_name: "◆ Fiery Burst Rune I", + texture: "8d620e4e3d3abfed6ad81a58a56bcd085d9e9efc803cabb21fa6c9e3969e2d2e", + tier: "legendary", + }, + RUNE_FIERY_BURST_2: { + display_name: "◆ Fiery Burst Rune II", + texture: "8d620e4e3d3abfed6ad81a58a56bcd085d9e9efc803cabb21fa6c9e3969e2d2e", + tier: "legendary", + }, + RUNE_FIERY_BURST_3: { + display_name: "◆ Fiery Burst Rune III", + texture: "8d620e4e3d3abfed6ad81a58a56bcd085d9e9efc803cabb21fa6c9e3969e2d2e", + tier: "legendary", + }, + RUNE_FIRE_SPIRAL_1: { + display_name: "◆ Fire Spiral Rune I", + texture: "8301aa86cafd4b2d732a9b4894cfcfc65edc828e8571b45dbf0a3ba96575cccf", + tier: "rare", + }, + RUNE_FIRE_SPIRAL_2: { + display_name: "◆ Fire Spiral Rune II", + texture: "8301aa86cafd4b2d732a9b4894cfcfc65edc828e8571b45dbf0a3ba96575cccf", + tier: "rare", + }, + RUNE_FIRE_SPIRAL_3: { + display_name: "◆ Fire Spiral Rune III", + texture: "8301aa86cafd4b2d732a9b4894cfcfc65edc828e8571b45dbf0a3ba96575cccf", + tier: "rare", + }, + RUNE_GEM_1: { + display_name: "◆ Gem Rune I", + texture: "43a1ad4fcc42fb63c681328e42d63c83ca193b333af2a426728a25a8cc600692", + tier: "common", + }, + RUNE_GEM_2: { + display_name: "◆ Gem Rune II", + texture: "43a1ad4fcc42fb63c681328e42d63c83ca193b333af2a426728a25a8cc600692", + tier: "common", + }, + RUNE_GEM_3: { + display_name: "◆ Gem Rune III", + texture: "43a1ad4fcc42fb63c681328e42d63c83ca193b333af2a426728a25a8cc600692", + tier: "common", + }, + RUNE_GOLDEN_1: { + display_name: "◆ Golden Rune I", + texture: "35f4861aa5b22ee28a90e75dab45d221efd14c0b1ecc8ee998fb67e43bb8f3de", + tier: "epic", + }, + RUNE_GOLDEN_2: { + display_name: "◆ Golden Rune II", + texture: "35f4861aa5b22ee28a90e75dab45d221efd14c0b1ecc8ee998fb67e43bb8f3de", + tier: "epic", + }, + RUNE_GOLDEN_3: { + display_name: "◆ Golden Rune III", + texture: "35f4861aa5b22ee28a90e75dab45d221efd14c0b1ecc8ee998fb67e43bb8f3de", + tier: "epic", + }, + RUNE_GRAND_SEARING_3: { + display_name: "◆ Grand Searing Rune III", + texture: "87217a791685cf4fbb78674756a4f9793ae5fd0525dae362b491cc7a472ec64b", + tier: "legendary", + }, + RUNE_HEARTS_1: { + display_name: "◆ Hearts Rune I", + texture: "2c1c179ad51955f1522c48ea9931f09c162741b45e22e9d3feb682c7e5ed8274", + tier: "rare", + }, + RUNE_HEARTS_2: { + display_name: "◆ Hearts Rune II", + texture: "2c1c179ad51955f1522c48ea9931f09c162741b45e22e9d3feb682c7e5ed8274", + tier: "rare", + }, + RUNE_HEARTS_3: { + display_name: "◆ Hearts Rune III", + texture: "2c1c179ad51955f1522c48ea9931f09c162741b45e22e9d3feb682c7e5ed8274", + tier: "rare", + }, + RUNE_HOT_1: { + display_name: "◆ Hot Rune I", + texture: "26660b016d05645fffd1f48b792d1abe5d8f30dc96567569ae1d982d250b693c", + tier: "uncommon", + }, + RUNE_HOT_2: { + display_name: "◆ Hot Rune II", + texture: "26660b016d05645fffd1f48b792d1abe5d8f30dc96567569ae1d982d250b693c", + tier: "uncommon", + }, + RUNE_HOT_3: { + display_name: "◆ Hot Rune III", + texture: "26660b016d05645fffd1f48b792d1abe5d8f30dc96567569ae1d982d250b693c", + tier: "uncommon", + }, + RUNE_ICE_1: { + display_name: "◆ Ice Rune I", + texture: "cdc57c75adf39ec6f0e0916049dd9671e98a8a1e600104e84e645c988950bd7", + tier: "rare", + }, + RUNE_ICE_2: { + display_name: "◆ Ice Rune II", + texture: "cdc57c75adf39ec6f0e0916049dd9671e98a8a1e600104e84e645c988950bd7", + tier: "rare", + }, + RUNE_ICE_3: { + display_name: "◆ Ice Rune III", + texture: "cdc57c75adf39ec6f0e0916049dd9671e98a8a1e600104e84e645c988950bd7", + tier: "rare", + }, + RUNE_JERRY_3: { + display_name: "◆ Jerry Rune III", + texture: "a1353ba65b6521f922b6464d17af39bddd43c984b8a227d99161594eba7a14c4", + tier: "common", + }, + RUNE_LAVATEARS_1: { + display_name: "◆ Lavatears Rune I", + texture: "8c8ccd5f863d82bb097b926bc5f4cca97b19f46e11b3a3a59d001adb89886773", + tier: "legendary", + }, + RUNE_LAVATEARS_2: { + display_name: "◆ Lavatears Rune II", + texture: "8c8ccd5f863d82bb097b926bc5f4cca97b19f46e11b3a3a59d001adb89886773", + tier: "legendary", + }, + RUNE_LAVATEARS_3: { + display_name: "◆ Lavatears Rune III", + texture: "8c8ccd5f863d82bb097b926bc5f4cca97b19f46e11b3a3a59d001adb89886773", + tier: "legendary", + }, + RUNE_LAVA_1: { + display_name: "◆ Lava Rune I", + texture: "b13d903f601034ac3400d2625fef104e9b0940746c554193f6d9e85a84a966a1", + tier: "common", + }, + RUNE_LAVA_2: { + display_name: "◆ Lava Rune II", + texture: "b13d903f601034ac3400d2625fef104e9b0940746c554193f6d9e85a84a966a1", + tier: "common", + }, + RUNE_LAVA_3: { + display_name: "◆ Lava Rune III", + texture: "b13d903f601034ac3400d2625fef104e9b0940746c554193f6d9e85a84a966a1", + tier: "common", + }, + RUNE_LIGHTNING_1: { + display_name: "◆ Lightning Rune I", + texture: "b85bcf7f82d34db89a95addf8e53253e2d9554c6fd2f2e39e24362d243a0ccf7", + tier: "legendary", + }, + RUNE_LIGHTNING_2: { + display_name: "◆ Lightning Rune II", + texture: "b85bcf7f82d34db89a95addf8e53253e2d9554c6fd2f2e39e24362d243a0ccf7", + tier: "legendary", + }, + RUNE_LIGHTNING_3: { + display_name: "◆ Lightning Rune III", + texture: "b85bcf7f82d34db89a95addf8e53253e2d9554c6fd2f2e39e24362d243a0ccf7", + tier: "legendary", + }, + RUNE_MAGIC_1: { + display_name: "◆ Magical Rune I", + texture: "24480e39ea63e347d268de83090d09984bf34394118848348bf4eb57490ce9d2", + tier: "rare", + }, + RUNE_MAGIC_2: { + display_name: "◆ Magical Rune II", + texture: "24480e39ea63e347d268de83090d09984bf34394118848348bf4eb57490ce9d2", + tier: "rare", + }, + RUNE_MAGIC_3: { + display_name: "◆ Magical Rune III", + texture: "24480e39ea63e347d268de83090d09984bf34394118848348bf4eb57490ce9d2", + tier: "rare", + }, + RUNE_MUSIC_1: { + display_name: "◆ Music Rune I", + texture: "3b481c31dc683bdcb7d375a7c5db7ac7adf9e9fe8b6c04a64931613e29fe470e", + tier: "epic", + }, + RUNE_MUSIC_2: { + display_name: "◆ Music Rune II", + texture: "3b481c31dc683bdcb7d375a7c5db7ac7adf9e9fe8b6c04a64931613e29fe470e", + tier: "epic", + }, + RUNE_MUSIC_3: { + display_name: "◆ Music Rune III", + texture: "3b481c31dc683bdcb7d375a7c5db7ac7adf9e9fe8b6c04a64931613e29fe470e", + tier: "epic", + }, + RUNE_RAINBOW_1: { + display_name: "◆ Rainbow Rune I", + texture: "72114a80357463fe2f59e397aab9fc66d482a65d524f8870d21c724c18ecf757", + tier: "legendary", + }, + RUNE_RAINBOW_2: { + display_name: "◆ Rainbow Rune II", + texture: "72114a80357463fe2f59e397aab9fc66d482a65d524f8870d21c724c18ecf757", + tier: "legendary", + }, + RUNE_RAINBOW_3: { + display_name: "◆ Rainbow Rune III", + texture: "72114a80357463fe2f59e397aab9fc66d482a65d524f8870d21c724c18ecf757", + tier: "legendary", + }, + RUNE_REDSTONE_1: { + display_name: "◆ Redstone Rune I", + texture: "87a7a894057d4a1ff22a161d76600f719da57916633f683808cf4d358bb73a21", + tier: "rare", + }, + RUNE_REDSTONE_2: { + display_name: "◆ Redstone Rune II", + texture: "87a7a894057d4a1ff22a161d76600f719da57916633f683808cf4d358bb73a21", + tier: "rare", + }, + RUNE_REDSTONE_3: { + display_name: "◆ Redstone Rune III", + texture: "87a7a894057d4a1ff22a161d76600f719da57916633f683808cf4d358bb73a21", + tier: "rare", + }, + RUNE_SMOKEY_1: { + display_name: "◆ Smokey Rune I", + texture: "e4d8a8d527f65a4f434f894f7ee42eb843015bda7927c63c6ea8a754afe9bb1b", + tier: "common", + }, + RUNE_SMOKEY_2: { + display_name: "◆ Smokey Rune II", + texture: "e4d8a8d527f65a4f434f894f7ee42eb843015bda7927c63c6ea8a754afe9bb1b", + tier: "common", + }, + RUNE_SMOKEY_3: { + display_name: "◆ Smokey Rune III", + texture: "e4d8a8d527f65a4f434f894f7ee42eb843015bda7927c63c6ea8a754afe9bb1b", + tier: "common", + }, + RUNE_SNAKE_1: { + display_name: "◆ Snake Rune I", + texture: "2c4a65c689b2d36409100a60c2ab8d3d0a67ce94eea3c1f7ac974fd893568b5d", + tier: "legendary", + }, + RUNE_SNAKE_2: { + display_name: "◆ Snake Rune II", + texture: "2c4a65c689b2d36409100a60c2ab8d3d0a67ce94eea3c1f7ac974fd893568b5d", + tier: "legendary", + }, + RUNE_SNAKE_3: { + display_name: "◆ Snake Rune III", + texture: "2c4a65c689b2d36409100a60c2ab8d3d0a67ce94eea3c1f7ac974fd893568b5d", + tier: "legendary", + }, + RUNE_SNOW_1: { + display_name: "◆ Snow Rune I", + texture: "cdc57c75adf39ec6f0e0916049dd9671e98a8a1e600104e84e645c988950bd7", + tier: "common", + }, + RUNE_SNOW_2: { + display_name: "◆ Snow Rune II", + texture: "cdc57c75adf39ec6f0e0916049dd9671e98a8a1e600104e84e645c988950bd7", + tier: "common", + }, + RUNE_SNOW_3: { + display_name: "◆ Snow Rune III", + texture: "cdc57c75adf39ec6f0e0916049dd9671e98a8a1e600104e84e645c988950bd7", + tier: "common", + }, + RUNE_SPARKLING_1: { + display_name: "◆ Sparkling Rune I", + texture: "f1e2428cb359988f4c4ff0e61de21385c62269de19a69762d773223b75dd1666", + tier: "rare", + }, + RUNE_SPARKLING_2: { + display_name: "◆ Sparkling Rune II", + texture: "f1e2428cb359988f4c4ff0e61de21385c62269de19a69762d773223b75dd1666", + tier: "rare", + }, + RUNE_SPARKLING_3: { + display_name: "◆ Sparkling Rune III", + texture: "f1e2428cb359988f4c4ff0e61de21385c62269de19a69762d773223b75dd1666", + tier: "rare", + }, + RUNE_SPIRIT_1: { + display_name: "◆ Spirit Rune I", + texture: "c738b8af8d7ce1a26dc6d40180b3589403e11ef36a66d7c4590037732829542e", + tier: "rare", + }, + RUNE_SPIRIT_2: { + display_name: "◆ Spirit Rune II", + texture: "c738b8af8d7ce1a26dc6d40180b3589403e11ef36a66d7c4590037732829542e", + tier: "rare", + }, + RUNE_SPIRIT_3: { + display_name: "◆ Spirit Rune III", + texture: "c738b8af8d7ce1a26dc6d40180b3589403e11ef36a66d7c4590037732829542e", + tier: "rare", + }, + RUNE_TIDAL_1: { + display_name: "◆ Tidal Rune I", + texture: "69671047c6ade8a9c4d6a581bc26d284a54ae32e85c34ce69d81f92799bf3fbb", + tier: "legendary", + }, + RUNE_TIDAL_2: { + display_name: "◆ Tidal Rune II", + texture: "69671047c6ade8a9c4d6a581bc26d284a54ae32e85c34ce69d81f92799bf3fbb", + tier: "legendary", + }, + RUNE_TIDAL_3: { + display_name: "◆ Tidal Rune III", + texture: "69671047c6ade8a9c4d6a581bc26d284a54ae32e85c34ce69d81f92799bf3fbb", + tier: "legendary", + }, + RUNE_WAKE_1: { + display_name: "◆ Wake Rune I", + texture: "977c1fc93216e96d435cf962e1173de8d1a249b644894d72676eba732fcd56e7", + tier: "legendary", + }, + RUNE_WAKE_2: { + display_name: "◆ Wake Rune II", + texture: "977c1fc93216e96d435cf962e1173de8d1a249b644894d72676eba732fcd56e7", + tier: "legendary", + }, + RUNE_WAKE_3: { + display_name: "◆ Wake Rune III", + texture: "977c1fc93216e96d435cf962e1173de8d1a249b644894d72676eba732fcd56e7", + tier: "legendary", + }, + RUNE_WHITE_SPIRAL_1: { + display_name: "◆ White Spiral Rune I", + texture: "3ef2432ef305361384d4318df5bda5bd1ac2d9bea06d1f5cfead6dd87e37ddf5", + tier: "uncommon", + }, + RUNE_WHITE_SPIRAL_2: { + display_name: "◆ White Spiral Rune II", + texture: "3ef2432ef305361384d4318df5bda5bd1ac2d9bea06d1f5cfead6dd87e37ddf5", + tier: "uncommon", + }, + RUNE_WHITE_SPIRAL_3: { + display_name: "◆ White Spiral Rune III", + texture: "3ef2432ef305361384d4318df5bda5bd1ac2d9bea06d1f5cfead6dd87e37ddf5", + tier: "uncommon", + }, + RUNE_ZAP_1: { + display_name: "◆ Zap Rune I", + texture: "ed0947c40de6789f6cfa2370add2a04c9855e45fde9483d655101e9510288ee8", + tier: "uncommon", + }, + RUNE_ZAP_2: { + display_name: "◆ Zap Rune II", + texture: "ed0947c40de6789f6cfa2370add2a04c9855e45fde9483d655101e9510288ee8", + tier: "uncommon", + }, + RUNE_ZAP_3: { + display_name: "◆ Zap Rune III", + texture: "ed0947c40de6789f6cfa2370add2a04c9855e45fde9483d655101e9510288ee8", + tier: "uncommon", + }, + RUNE_ZOMBIE_SLAYER_1: { + display_name: "◆ Pestilence Rune I", + texture: "a8c4811395fbf7f620f05cc3175cef1515aaf775ba04a01045027f0693a90147", + tier: "rare", + }, + RUNE_ZOMBIE_SLAYER_2: { + display_name: "◆ Pestilence Rune II", + texture: "a8c4811395fbf7f620f05cc3175cef1515aaf775ba04a01045027f0693a90147", + tier: "rare", + }, + RUNE_ZOMBIE_SLAYER_3: { + display_name: "◆ Pestilence Rune III", + texture: "a8c4811395fbf7f620f05cc3175cef1515aaf775ba04a01045027f0693a90147", + tier: "rare", + }, + }, texture: "e91eb4ee3ecce3447483a1f151c11facc9de25577ab7b51fbf3d9c2b2a4b69fc", }, SLAYER_SACK: { @@ -334,4 +795,5 @@ export const SACKS = { export const ITEM_SACKS = { HUNK_OF_BLUE_ICE: "BLUE_ICE_HUNK", HUNK_OF_ICE: "ICE_HUNK", + CLAY: "CLAY_BALL", }; diff --git a/src/lib.js b/src/lib.js index 5b7bf26079..497fa4e68d 100644 --- a/src/lib.js +++ b/src/lib.js @@ -974,20 +974,26 @@ export const getItems = async ( output.storage = storage; output.hotm = hotm; output.candy_bag = candy_bag; - - const sacks = "sacks_counts" in profile ? await getSacks(profile.sacks_counts, armor.concat( - equipment, - inventory, - enderchest, - accessory_bag, - fishing_bag, - quiver, - potion_bag, - personal_vault, - wardrobe_inventory, - storage, - hotm, - )) : []; + + const sacks = + "sacks_counts" in profile + ? await getSacks( + profile.sacks_counts, + armor.concat( + equipment, + inventory, + enderchest, + accessory_bag, + fishing_bag, + quiver, + potion_bag, + personal_vault, + wardrobe_inventory, + storage, + hotm + ) + ) + : []; output.sacks = sacks; const allItems = armor.concat( @@ -2959,11 +2965,10 @@ const BASE_SACK = { async function getSacks(sacks_counts, items) { const sacks = []; - const timeNow = Date.now(); for (const sackId in constants.SACKS) { const sack = constants.SACKS[sackId]; - if (sack.items.filter((a) => Object.keys(sacks_counts).includes(a)).length == 0) { + if (sackId !== "RUNE_SACK" && sack.items.filter((a) => Object.keys(sacks_counts).includes(a)).length == 0) { continue; } @@ -2978,36 +2983,33 @@ async function getSacks(sacks_counts, items) { }, }; + if (sackId === "RUNE_SACK") { + sackItem.containsItems = []; + for (const ID in sack.items) { + if (ID === "???") continue; - if (sackId == "GEMSTONE_SACK") { - /*let line = ''; - - for (const tier in gem_tiers) { - line += constants.RARITY_COLORS[gem_tiers[tier]]; - line += _.startCase(tier.toLowerCase()); - - if (tier != 'PERFECT') { - line += '§8 / '; - } - } - - sackItem.tag.display.Lore.push(line, ''); - - for (const gem in constants.gem_types) { - let line = constants.gem_types[gem]; - line += `${_.startCase(gem.toLowerCase())}§8: `; - - for (const tier in gem_tiers) { - line += constants.RARITY_COLORS[gem_tiers[tier]]; - line += (sacks_counts[`${tier}_${gem}_GEM`] ?? 0).toLocaleString(); + const item = sack.items[ID] ?? sack.items["???"]; - if (tier != 'PERFECT') { - line += '§8 / '; - } - } + const sackContent = { + Count: 1, + sack_count: sacks_counts[ID] ?? 0, + Damage: 3, + id: 397, + itemIndex: sackItem.containsItems.length, + display_name: item.display_name, + rarity: item.tier, + texture_path: `/head/${item.texture}`, + tag: { + display: { + Name: `§a${item.item}`, + Lore: [`§8Stored: §e${(sacks_counts[ID] ?? 0).toLocaleString()}`], + }, + }, + categories: [], + }; - sackItem.tag.display.Lore.push(line); - }*/ + sackItem.containsItems.push(sackContent); + } } else { sackItem.containsItems = []; @@ -3016,13 +3018,6 @@ async function getSacks(sacks_counts, items) { const itemName = hypixelItem?.name ?? "Unknown"; - const itemDescription = items.find((itemm) => { - if (itemm.tag?.ExtraAttributes?.id === sackId) { - console.log(itemm) - return itemm - } - }) - const sackContent = { Count: 1, sack_count: sacks_counts[item] ?? 0, @@ -3054,7 +3049,6 @@ async function getSacks(sacks_counts, items) { sacks.push(sackItem); } - console.log("Parsed sacks in " + Date.now() - timeNow + "ms") return sacks; } diff --git a/views/stats.ejs b/views/stats.ejs index fbfe12e69a..5ed459a6f5 100644 --- a/views/stats.ejs +++ b/views/stats.ejs @@ -1441,7 +1441,6 @@ const metaDescription = getMetaDescription()
Fish
<% } %> - <% if(items.quiver.length > 0){ %> <% } %> <% if(items.sacks.length > 0){ %> -
-
-
Sacks
-
+ <% } %> From 51937e8e214e5439861545b7e7ea19429a553272 Mon Sep 17 00:00:00 2001 From: DuckySoLucky Date: Thu, 30 Mar 2023 11:08:46 +0200 Subject: [PATCH 03/12] refactor: move `BASE_SACK` to constants --- src/constants/sacks.js | 7 +++++++ src/lib.js | 22 +++++++--------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/constants/sacks.js b/src/constants/sacks.js index 1138fee8a8..22f7c226bc 100644 --- a/src/constants/sacks.js +++ b/src/constants/sacks.js @@ -792,6 +792,13 @@ export const SACKS = { }, }; +export const BASE_SACK = { + Count: 1, + Damage: 3, + id: 397, + rarity: "epic", +}; + export const ITEM_SACKS = { HUNK_OF_BLUE_ICE: "BLUE_ICE_HUNK", HUNK_OF_ICE: "ICE_HUNK", diff --git a/src/lib.js b/src/lib.js index 497fa4e68d..ca6a06f035 100644 --- a/src/lib.js +++ b/src/lib.js @@ -2954,25 +2954,17 @@ export async function getCollections(uuid, profile, cacheOnly = false) { return output; } -const BASE_SACK = { - Count: 1, - Damage: 3, - id: 397, - rarity: "epic", -}; - -// eslint-disable-next-line @typescript-eslint/naming-convention -async function getSacks(sacks_counts, items) { +async function getSacks(sacksCounts) { const sacks = []; for (const sackId in constants.SACKS) { const sack = constants.SACKS[sackId]; - if (sackId !== "RUNE_SACK" && sack.items.filter((a) => Object.keys(sacks_counts).includes(a)).length == 0) { + if (sackId !== "RUNE_SACK" && sack.items.filter((a) => Object.keys(sacksCounts).includes(a)).length == 0) { continue; } - const sackItem = Object.assign({}, BASE_SACK); + const sackItem = Object.assign({}, constants.BASE_SACK); sackItem.texture_path = `/head/${sack.texture}`; sackItem.display_name = _.startCase(sackId.toLowerCase()); @@ -2992,7 +2984,7 @@ async function getSacks(sacks_counts, items) { const sackContent = { Count: 1, - sack_count: sacks_counts[ID] ?? 0, + sack_count: sacksCounts[ID] ?? 0, Damage: 3, id: 397, itemIndex: sackItem.containsItems.length, @@ -3002,7 +2994,7 @@ async function getSacks(sacks_counts, items) { tag: { display: { Name: `§a${item.item}`, - Lore: [`§8Stored: §e${(sacks_counts[ID] ?? 0).toLocaleString()}`], + Lore: [`§8Stored: §e${(sacksCounts[ID] ?? 0).toLocaleString()}`], }, }, categories: [], @@ -3020,7 +3012,7 @@ async function getSacks(sacks_counts, items) { const sackContent = { Count: 1, - sack_count: sacks_counts[item] ?? 0, + sack_count: sacksCounts[item] ?? 0, Damage: hypixelItem?.damage ?? 3, id: hypixelItem?.item_id ?? 397, itemIndex: index, @@ -3028,7 +3020,7 @@ async function getSacks(sacks_counts, items) { tag: { display: { Name: `§a${itemName}`, - Lore: [`§8Stored: §e${(sacks_counts[item] ?? 0).toLocaleString()}`], + Lore: [`§8Stored: §e${(sacksCounts[item] ?? 0).toLocaleString()}`], }, }, categories: [], From 1f771b66cec85b9f3425e4866712b4e644721bcf Mon Sep 17 00:00:00 2001 From: DuckySoLucky Date: Sun, 2 Apr 2023 15:07:46 +0200 Subject: [PATCH 04/12] feat: add `Count` value to sack items --- public/resources/ts/elements/rich-item.ts | 3 ++- src/lib.js | 25 +++-------------------- 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/public/resources/ts/elements/rich-item.ts b/public/resources/ts/elements/rich-item.ts index 0527ba8ea8..76c36e63cb 100644 --- a/public/resources/ts/elements/rich-item.ts +++ b/public/resources/ts/elements/rich-item.ts @@ -12,6 +12,7 @@ import { mousemoveLoreListener, showBackpack, } from "../stats-defer"; +import { formatNumber } from "../../../../common/formatting"; @customElement("rich-item") export class InventoryView extends LitElement { @@ -55,7 +56,7 @@ export class InventoryView extends LitElement { } return html`
- ${this.item.Count != 1 ? html`
${this.item.Count}
` : undefined} + ${this.item.Count != 1 ? html`
${formatNumber(this.item.Count, false, 10)}
` : undefined} `; } diff --git a/src/lib.js b/src/lib.js index ca6a06f035..24125a4b1f 100644 --- a/src/lib.js +++ b/src/lib.js @@ -978,20 +978,7 @@ export const getItems = async ( const sacks = "sacks_counts" in profile ? await getSacks( - profile.sacks_counts, - armor.concat( - equipment, - inventory, - enderchest, - accessory_bag, - fishing_bag, - quiver, - potion_bag, - personal_vault, - wardrobe_inventory, - storage, - hotm - ) + profile.sacks_counts ) : []; output.sacks = sacks; @@ -2968,12 +2955,6 @@ async function getSacks(sacksCounts) { sackItem.texture_path = `/head/${sack.texture}`; sackItem.display_name = _.startCase(sackId.toLowerCase()); - sackItem.tag = { - display: { - Lore: [], - Name: `§5${sackItem.display_name}`, - }, - }; if (sackId === "RUNE_SACK") { sackItem.containsItems = []; @@ -2983,7 +2964,7 @@ async function getSacks(sacksCounts) { const item = sack.items[ID] ?? sack.items["???"]; const sackContent = { - Count: 1, + Count: sacksCounts[ID] ?? 0, sack_count: sacksCounts[ID] ?? 0, Damage: 3, id: 397, @@ -3011,7 +2992,7 @@ async function getSacks(sacksCounts) { const itemName = hypixelItem?.name ?? "Unknown"; const sackContent = { - Count: 1, + Count: sacksCounts[item] ?? 0, sack_count: sacksCounts[item] ?? 0, Damage: hypixelItem?.damage ?? 3, id: hypixelItem?.item_id ?? 397, From b4d0b78f84907b4bab1cbdb0b31e658831208ea6 Mon Sep 17 00:00:00 2001 From: DuckySoLucky Date: Sun, 2 Apr 2023 15:12:12 +0200 Subject: [PATCH 05/12] style: `pnpm run prettier:fix` --- public/resources/ts/elements/rich-item.ts | 4 +++- src/lib.js | 7 +------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/public/resources/ts/elements/rich-item.ts b/public/resources/ts/elements/rich-item.ts index 76c36e63cb..446abfad53 100644 --- a/public/resources/ts/elements/rich-item.ts +++ b/public/resources/ts/elements/rich-item.ts @@ -56,7 +56,9 @@ export class InventoryView extends LitElement { } return html`
- ${this.item.Count != 1 ? html`
${formatNumber(this.item.Count, false, 10)}
` : undefined} + ${this.item.Count != 1 + ? html`
${formatNumber(this.item.Count, false, 10)}
` + : undefined} `; } diff --git a/src/lib.js b/src/lib.js index 24125a4b1f..041535b128 100644 --- a/src/lib.js +++ b/src/lib.js @@ -975,12 +975,7 @@ export const getItems = async ( output.hotm = hotm; output.candy_bag = candy_bag; - const sacks = - "sacks_counts" in profile - ? await getSacks( - profile.sacks_counts - ) - : []; + const sacks = "sacks_counts" in profile ? await getSacks(profile.sacks_counts) : []; output.sacks = sacks; const allItems = armor.concat( From 78c46ccf9b87009e6fbbab557f53bf5ecc46b2fe Mon Sep 17 00:00:00 2001 From: DuckySoLucky Date: Sun, 2 Apr 2023 15:24:12 +0200 Subject: [PATCH 06/12] refactor: set `Count` to 1 instead of 0 --- src/lib.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib.js b/src/lib.js index 041535b128..9408c3fb33 100644 --- a/src/lib.js +++ b/src/lib.js @@ -2959,7 +2959,7 @@ async function getSacks(sacksCounts) { const item = sack.items[ID] ?? sack.items["???"]; const sackContent = { - Count: sacksCounts[ID] ?? 0, + Count: sacksCounts[ID] ?? 1, sack_count: sacksCounts[ID] ?? 0, Damage: 3, id: 397, @@ -2984,10 +2984,12 @@ async function getSacks(sacksCounts) { for (const [index, item] of sack.items.entries()) { const hypixelItem = await db.collection("items").findOne({ id: constants.ITEM_SACKS[item] ?? item }); - const itemName = hypixelItem?.name ?? "Unknown"; + const itemName = hypixelItem?.name ?? _.startCase(item.toLowerCase()); + + const count = sacksCounts[item] === 0 ? 1 : sacksCounts[item]; const sackContent = { - Count: sacksCounts[item] ?? 0, + Count: count ?? 1, sack_count: sacksCounts[item] ?? 0, Damage: hypixelItem?.damage ?? 3, id: hypixelItem?.item_id ?? 397, From 16ee3e03d8d4135340fccb0166399f8639cea6ea Mon Sep 17 00:00:00 2001 From: Zickles <76439587+Zickles@users.noreply.github.com> Date: Sun, 23 Apr 2023 09:17:16 -0400 Subject: [PATCH 07/12] add new sacks and update old sacks --- src/constants/sacks.js | 331 +++++++++++++++++++++++++++++------------ 1 file changed, 238 insertions(+), 93 deletions(-) diff --git a/src/constants/sacks.js b/src/constants/sacks.js index 22f7c226bc..7e5e394653 100644 --- a/src/constants/sacks.js +++ b/src/constants/sacks.js @@ -1,18 +1,23 @@ export const SACKS = { AGRONOMY_SACK: { items: [ - "WHEAT", - "SEEDS", + "BROWN_MUSHROOM", + "CACTUS", + "INK_SACK:2", "CARROT_ITEM", + "INK_SACK:3", + "CROPIE", + "HAY_BLOCK", + "MELON", + "NETHER_STALK", + "POISONOUS_POTATO", "POTATO_ITEM", "PUMPKIN", - "MELON", "RED_MUSHROOM", - "BROWN_MUSHROOM", - "INK_SACK:3", - "CACTUS", + "SEEDS", + "SQUASH", "SUGAR_CANE", - "NETHER_STALK", + "WHEAT", ], texture: "ef835b8941fe319931749b87fe8e84c5d1f4a271b5fbce5e700a60004d881f79", }, @@ -21,10 +26,13 @@ export const SACKS = { "ENCHANTED_BREAD", "ENCHANTED_BROWN_MUSHROOM", "ENCHANTED_CACTUS", + "ENCHANTED_CACTUS_GREEN", "ENCHANTED_CARROT", "ENCHANTED_COCOA", + "ENCHANTED_HAY_BLOCK", "ENCHANTED_MELON", "ENCHANTED_NETHER_STALK", + "ENCHANTED_POISONOUS_POTATO", "ENCHANTED_POTATO", "ENCHANTED_PUMPKIN", "ENCHANTED_RED_MUSHROOM", @@ -34,47 +42,64 @@ export const SACKS = { texture: "184d2ff1e177357574f9f71e19397fff3a210a94e78c0d2a4360cc5df1eb807b", }, HUSBANDRY_SACK: { - items: ["FEATHER", "LEATHER", "PORK", "RAW_CHICKEN", "MUTTON", "RABBIT", "RAW_BEEF", "RABBIT_HIDE", "RABBIT_FOOT"], + items: [ + "FEATHER", + "LEATHER", + "PORK", + "RAW_CHICKEN", + "EGG", + "MUTTON", + "RABBIT", + "RAW_BEEF", + "RABBIT_HIDE", + "RABBIT_FOOT", + "WOOL" + ], texture: "c73087f1e654b1682733584a44097587fb942e1f343aae8307bd7dac84e843ab", }, ENCHANTED_HUSBANDRY_SACK: { items: [ + "ENCHANTED_EGG", "ENCHANTED_FEATHER", "ENCHANTED_LEATHER", + "ENCHANTED_MUTTON", "ENCHANTED_PORK", + "ENCHANTED_RABBIT_FOOT", + "ENCHANTED_RABBIT_HIDE", + "ENCHANTED_RAW_BEEF", "ENCHANTED_RAW_CHICKEN", - "ENCHANTED_EGG", - "ENCHANTED_MUTTON", "ENCHANTED_RABBIT", - "ENCHANTED_RAW_BEEF", - "ENCHANTED_RABBIT_HIDE", - "ENCHANTED_RABBIT_FOOT", + "ENCHANTED_WOOL" ], texture: "746a6063263ba7208a2a06cef73234791c92d5f67080a365508b02483eefaf9a", }, MINING_SACK: { items: [ - "COBBLESTONE", "COAL", - "IRON_INGOT", - "GOLD_INGOT", + "COBBLESTONE", "DIAMOND", - "INK_SACK:4", "EMERALD", - "REDSTONE", - "QUARTZ", - "OBSIDIAN", + "ENDER_STONE", + "FLINT", "GLOWSTONE_DUST", + "GOLD_INGOT", "GRAVEL", - "ICE", + "HARD_STONE", + "IRON_INGOT", + "INK_SACK:4", + "MITHRIL_ORE", + "QUARTZ", "NETHERRACK", + "OBSIDIAN", + "OIL_BARREL", + "PLASMA", + "REDSTONE", "SAND", - "ENDER_STONE", - "MITHRIL_ORE", - "HARD_STONE", + "STARFALL", + "STONE", "TITANIUM_ORE", "TREASURITE", - "STARFALL", + "VOLTA" ], texture: "915fcebbbe02fdb72acd2095d9edfcea095e604b3682db88963b5b83b2939b67", }, @@ -92,11 +117,14 @@ export const SACKS = { "ENCHANTED_IRON", "ENCHANTED_LAPIS_LAZULI", "ENCHANTED_MITHRIL", + "ENCHANTED_MYCELIUM", "ENCHANTED_NETHERRACK", "ENCHANTED_OBSIDIAN", "ENCHANTED_QUARTZ", + "ENCHANTED_RED_SAND", "ENCHANTED_REDSTONE", "ENCHANTED_SAND", + "ENCHANTED_SULPHUR", "ENCHANTED_TITANIUM", ], texture: "eedc69fefad184ee8c9186928da982addfd783bed98d95083408bf419e0cccd0", @@ -146,18 +174,50 @@ export const SACKS = { ], texture: "95ba804b7ae92c65b2f41d18be899a3bd139772e3e3c81c2fc8addbb27536952", }, + DWARVEN_SACK: { + items: [ + "PLASMA", + "VOLTA", + "SORROW", + "GLACITE_JEWEL", + "GOBLIN_EGG", + "GOBLIN_EGG_GREEN", + "GOBLIN_EGG_YELLOW", + "GOBLIN_EGG_RED", + "GOBLIN_EGG_BLUE", + ], + texture: "915fcebbbe02fdb72acd2095d9edfcea095e604b3682db88963b5b83b2939b67", + }, + CRYSTAL_HOLLOWS_SACK: { + items: [ + "ROBOTRON_REFLECTOR", + "FTX_3070", + "CONTROL_SWITCH", + "ELECTRON_TRANSMITTER", + "SYNTHETIC_HEART", + "SUPERLITE_MOTOR", + "BOB_OMB", + "JUNGLE_KEY", + "YOGGIE", + "SLUDGE_JUICE", + "CORLEONITE", + "OIL_BARREL", + ], + texture: "a6b46beeb5f6e0006163eda4a50703a40e6591080b0e67779312adcfec46152", + }, COMBAT_SACK: { items: [ - "ROTTEN_FLESH", + "BLAZE_ROD", "BONE", - "STRING", - "SPIDER_EYE", - "SULPHUR", + "CHILI_PEPPER", "ENDER_PEARL", "GHAST_TEAR", - "SLIME_BALL", - "BLAZE_ROD", + "SULPHUR", "MAGMA_CREAM", + "ROTTEN_FLESH", + "SLIME_BALL", + "SPIDER_EYE", + "STRING", ], texture: "1c13c4774c82c07071e6d1408717b1e3eac56186042a5803fc174452e32a254a", }, @@ -176,47 +236,69 @@ export const SACKS = { ], texture: "c2a3420697256517d5361b3463019647c0689725b3489f9dd24a22ddd40bd41f", }, + DRAGON_SACK: { + items: [ + "PROTECTOR_FRAGMENT", + "OLD_FRAGMENT", + "UNSTABLE_FRAGMENT", + "STRONG_FRAGMENT", + "YOUNG_FRAGMENT", + "WISE_FRAGMENT", + "SUPERIOR_FRAGMENT", + "HOLY_FRAGMENT", + "MITE_GEL", + "RITUAL_RESIDUE", + "CRYSTAL_FRAGMENT", + ], + texture: "5739492be78c572fb4c6bfaf8f10bd528553b43af575ba073acbd2c4bf77c40b", + }, FORAGING_SACK: { items: [ - "LOG", + "LOG_2", "LOG:1", + "LOG:3", "LOG:2", + "LOG", "LOG_2:1", - "LOG_2", - "LOG:3", - "SAPLING", + "APPLE", + "SAPLING:4", "SAPLING:1", + "SAPLING:3", "SAPLING:2", + "SAPLING", "SAPLING:5", - "SAPLING:4", - "SAPLING:3", - "APPLE", ], texture: "2c6e24df498ba4a589c259d9fc0d3db348f93cdf26a5fe461571c1da706efaf3", }, ENCHANTED_FORAGING_SACK: { items: [ - "ENCHANTED_OAK_LOG", - "ENCHANTED_SPRUCE_LOG", + "ENCHANTED_ACACIA_LOG", "ENCHANTED_BIRCH_LOG", "ENCHANTED_DARK_OAK_LOG", - "ENCHANTED_ACACIA_LOG", "ENCHANTED_JUNGLE_LOG", + "ENCHANTED_OAK_LOG", + "ENCHANTED_SPRUCE_LOG", ], texture: "35326464c6a79362730d79fe4611b911353c1b3c5144177773591357f1cd5ca1", }, FISHING_SACK: { items: [ - "RAW_FISH", - "RAW_FISH:1", - "RAW_FISH:2", - "RAW_FISH:3", - "PRISMARINE_SHARD", - "PRISMARINE_CRYSTALS", + "BLUE_SHARK_TOOTH", + "CHUM", "CLAY", - "WATER_LILY", + "RAW_FISH:2", + "GLOWING_MUSHROOM", "INK_SACK", + "WATER_LILY", + "NURSE_SHARK_TOOTH", + "PRISMARINE_CRYSTALS", + "PRISMARINE_SHARD", + "RAW_FISH:3", + "RAW_FISH", + "RAW_FISH:1", + "SHARK_FIN", "SPONGE", + "TIGER_SHARK_TOOTH", ], texture: "f8f68669351a6fc7156ecfe3300ba94efe0766e24bed8785cf64a9f95435134b", }, @@ -225,69 +307,98 @@ export const SACKS = { "ENCHANTED_CLAY_BALL", "ENCHANTED_CLOWNFISH", "ENCHANTED_INK_SACK", + "ENCHANTED_WATER_LILY", + "ENCHANTED_PRISMARINE_CRYSTALS", + "ENCHANTED_PRISMARINE_SHARD", "ENCHANTED_PUFFERFISH", "ENCHANTED_RAW_FISH", "ENCHANTED_RAW_SALMON", + "ENCHANTED_SHARK_FIN", "ENCHANTED_SPONGE", - "ENCHANTED_WATER_LILY", - "ENCHANTED_PRISMARINE_CRYSTALS", - "ENCHANTED_PRISMARINE_SHARD", ], texture: "ee2469de7f75d2e0a8b3b0c734a2b470782b604d1feb0172b4a72a77cb5bbda2", }, LAVA_FISHING_SACK: { items: [ "MAGMA_FISH", + "MAGMA_FISH_SILVER", + "MAGMA_FISH_GOLD", "MAGMA_CREAM", "COAL", "BLAZE_POWDER", "NETHERRACK", + "LUMP_OF_MAGMA", "MOOGMA_PELT", "PYROCLASTIC_SCALE", - "FLAMING_HEART", - "LUMP_OF_MAGMA", "CUP_OF_BLOOD", + "FLAMING_HEART", "ORB_OF_ENERGY", "HORN_OF_TAURUS", + "LAVA_SHELL", + "THUNDER_SHARDS" ], texture: "da2a951592cc26cf5b6d9f66ae034916f9d2e97216d43b3fa11c979afd7df1ad", }, NETHER_SACK: { items: [ - "SULPHUR_ORE", - "SAND:1", - "MYCEL", - "ECTOPLASM", - "NETHERRACK", - "MAGMA_CREAM", - "BLAZE_ROD", - "GHAST_TEAR", - "QUARTZ", - "GLOWSTONE_DUST", - "NETHER_STALK", - "SPECTRE_DUST", - "BLAZE_ASHES", - "MUTATED_BLAZE_ASHES", - "WITHER_SOUL", - "MAGMA_CHUNK", "BEZOS", + "BLAZE_ASHES", + "BLAZE_ROD", "BURNING_EYE", - "TENTACLE_MEAT", + "COMPACT_OOZE", + "CORRUPTED_FRAGMENT", "DIGESTED_MUSHROOMS", - "KADA_LEAD", - "MAGMAG", + "FLAMES", "GAZING_PEARL", + "GHAST_TEAR", + "GLOWSTONE_DUST", + "HALLOWED_SKULL", + "HEAVY_PEARL", + "KADA_LEAD", + "KUUDRA_TEETH", "LEATHER_CLOTH", - "SPELL_POWDER", - "COMPACT_OOZE", "LUMINO_FIBER", - "HALLOWED_SKULL", - "CORRUPTED_FRAGMENT", + "MAGMA_CHUNK", + "MAGMA_CREAM", + "MAGMAG", + "MILLENIA_OLD_BLAZE_ASHES", + "MUTATED_BLAZE_ASHES", + "MYCEL", + "QUARTZ", + "NETHER_STAR", + "NETHER_STALK", + "NETHERRACK", + "SAND:1", + "REKINDLED_EMBER_FRAGMENT", + "SPECTRE_DUST", + "SPELL_POWDER", + "SULPHUR_ORE", + "TENTACLE_MEAT", + "WITHER_SOUL", + "X", + "Y", + "Z" ], texture: "e345875e921a145f92038858aeecc3c2f083441ebc5c8265d31a281d268e365b", }, DUNGEON_SACK: { - items: ["SPIRIT_LEAP", "DUNGEON_TRAP", "INFLATABLE_JERRY", "DUNGEON_DECOY"], + items: [ + "SPIRIT_LEAP", + "DUNGEON_TRAP", + "INFLATABLE_JERRY", + "DUNGEON_DECOY", + "SUPERBOOM_TNT", + "BONZO_FRAGMENT", + "SCARF_FRAGMENT", + "LIVID_FRAGMENT", + "MIMIC_FRAGMENT", + "HEALING_TISSUE", + "GIANT_FRAGMENT_BOULDER", + "GIANT_FRAGMENT_LASER", + "WITHER_CATALYST", + "GOLEM_POPPY", + "FEL_PEARL" + ], texture: "fb96c585ccd35f073da38d165cb9bb18ff136f1a184eee3f44725354640ebbd4", }, RUNE_SACK: { @@ -757,39 +868,73 @@ export const SACKS = { }, SLAYER_SACK: { items: [ - "TARANTULA_WEB", - "SPIDER_CATALYST", - "UNDEAD_CATALYST", - "REVENANT_CATALYST", + "CRUDE_GABAGOOL", + "DERELICT_ASHE", + "NULL_ATOM", "NULL_SPHERE", "RAW_SOULFLOW", + "REVENANT_CATALYST", + "REVENANT_FLESH", "SOULFLOW", - "DERELICT_ASHE", - "CRUDE_GABAGOOL", + "SPIDER_CATALYST", + "TARANTULA_WEB", + "UNDEAD_CATALYST", + "WOLF_TOOTH" ], texture: "c0ccbd15d76a748e08926ef6d21dc3e54d9adec766cc25019531a493b1fd4b44", }, SPOOKY_SACK: { - items: ["GREEN_CANDY", "PURPLE_CANDY", "PUMPKIN_GUTS", "ECTOPLASM", "WEREWOLF_SKIN"], + items: [ + "GREEN_CANDY", + "PURPLE_CANDY", + "PUMPKIN_GUTS", + "ECTOPLASM", + "WEREWOLF_SKIN", + "SPOOKY_SHARD" + ], texture: "12ef39437d7d43a034c5a40b974e8d2c6734a218c76485d04910f507bdc2e809", }, WINTER_SACK: { items: [ - "WHITE_GIFT", - "GREEN_GIFT", - "RED_GIFT", - "SNOW_BLOCK", - "ENCHANTED_SNOW_BLOCK", - "SNOW_BALL", - "ICE", "ENCHANTED_ICE", - "PACKED_ICE", "ENCHANTED_PACKED_ICE", - "HUNK_OF_ICE", + "ENCHANTED_SNOW_BLOCK", + "GLACIAL_FRAGMENT", + "GREEN_GIFT", "HUNK_OF_BLUE_ICE", + "HUNK_OF_ICE", + "ICE", + "PACKED_ICE", + "SNOW_BLOCK", + "SNOW_BALL", + "WALNUT", + "WHITE_GIFT", + "RED_GIFT", ], texture: "ab339b1cd40053defd7d3528e01fea876d41b42f9d9268461da79f5f66771236", }, + FLOWER_SACK: { + items: [ + "RED_ROSE", + "YELLOW_FLOWER", + "RED_ROSE:1", + "RED_ROSE:2", + "RED_ROSE:3", + "RED_ROSE:4", + "RED_ROSE:5", + "RED_ROSE:6", + "RED_ROSE:7", + "RED_ROSE:8", + "DOUBLE_PLANT", + "DOUBLE_PLANT:1", + "DOUBLE_PLANT:4", + "DOUBLE_PLANT:5", + "ENDSTONE_ROSE", + "ENCHANTED_DANDELION", + "ENCHANTED_POPPY" + ], + texture: "afc3b5db9bd99cd12161ed2ea4623795f28e793c6dab67cd3e803ccfaaad7cfd", + }, }; export const BASE_SACK = { From df91e094ec35e6541b7ab5bc9962e3ed8a63f712 Mon Sep 17 00:00:00 2001 From: DuckySoLucky Date: Sun, 23 Apr 2023 15:27:13 +0200 Subject: [PATCH 08/12] style: `npm run prettier:fix` --- src/constants/sacks.js | 73 +++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 40 deletions(-) diff --git a/src/constants/sacks.js b/src/constants/sacks.js index 7e5e394653..9d797bd4dc 100644 --- a/src/constants/sacks.js +++ b/src/constants/sacks.js @@ -43,17 +43,17 @@ export const SACKS = { }, HUSBANDRY_SACK: { items: [ - "FEATHER", - "LEATHER", - "PORK", - "RAW_CHICKEN", - "EGG", - "MUTTON", - "RABBIT", - "RAW_BEEF", - "RABBIT_HIDE", - "RABBIT_FOOT", - "WOOL" + "FEATHER", + "LEATHER", + "PORK", + "RAW_CHICKEN", + "EGG", + "MUTTON", + "RABBIT", + "RAW_BEEF", + "RABBIT_HIDE", + "RABBIT_FOOT", + "WOOL", ], texture: "c73087f1e654b1682733584a44097587fb942e1f343aae8307bd7dac84e843ab", }, @@ -69,7 +69,7 @@ export const SACKS = { "ENCHANTED_RAW_BEEF", "ENCHANTED_RAW_CHICKEN", "ENCHANTED_RABBIT", - "ENCHANTED_WOOL" + "ENCHANTED_WOOL", ], texture: "746a6063263ba7208a2a06cef73234791c92d5f67080a365508b02483eefaf9a", }, @@ -99,7 +99,7 @@ export const SACKS = { "STONE", "TITANIUM_ORE", "TREASURITE", - "VOLTA" + "VOLTA", ], texture: "915fcebbbe02fdb72acd2095d9edfcea095e604b3682db88963b5b83b2939b67", }, @@ -335,7 +335,7 @@ export const SACKS = { "ORB_OF_ENERGY", "HORN_OF_TAURUS", "LAVA_SHELL", - "THUNDER_SHARDS" + "THUNDER_SHARDS", ], texture: "da2a951592cc26cf5b6d9f66ae034916f9d2e97216d43b3fa11c979afd7df1ad", }, @@ -377,27 +377,27 @@ export const SACKS = { "WITHER_SOUL", "X", "Y", - "Z" + "Z", ], texture: "e345875e921a145f92038858aeecc3c2f083441ebc5c8265d31a281d268e365b", }, DUNGEON_SACK: { items: [ - "SPIRIT_LEAP", - "DUNGEON_TRAP", - "INFLATABLE_JERRY", - "DUNGEON_DECOY", - "SUPERBOOM_TNT", - "BONZO_FRAGMENT", - "SCARF_FRAGMENT", - "LIVID_FRAGMENT", - "MIMIC_FRAGMENT", - "HEALING_TISSUE", - "GIANT_FRAGMENT_BOULDER", - "GIANT_FRAGMENT_LASER", - "WITHER_CATALYST", - "GOLEM_POPPY", - "FEL_PEARL" + "SPIRIT_LEAP", + "DUNGEON_TRAP", + "INFLATABLE_JERRY", + "DUNGEON_DECOY", + "SUPERBOOM_TNT", + "BONZO_FRAGMENT", + "SCARF_FRAGMENT", + "LIVID_FRAGMENT", + "MIMIC_FRAGMENT", + "HEALING_TISSUE", + "GIANT_FRAGMENT_BOULDER", + "GIANT_FRAGMENT_LASER", + "WITHER_CATALYST", + "GOLEM_POPPY", + "FEL_PEARL", ], texture: "fb96c585ccd35f073da38d165cb9bb18ff136f1a184eee3f44725354640ebbd4", }, @@ -879,19 +879,12 @@ export const SACKS = { "SPIDER_CATALYST", "TARANTULA_WEB", "UNDEAD_CATALYST", - "WOLF_TOOTH" + "WOLF_TOOTH", ], texture: "c0ccbd15d76a748e08926ef6d21dc3e54d9adec766cc25019531a493b1fd4b44", }, SPOOKY_SACK: { - items: [ - "GREEN_CANDY", - "PURPLE_CANDY", - "PUMPKIN_GUTS", - "ECTOPLASM", - "WEREWOLF_SKIN", - "SPOOKY_SHARD" - ], + items: ["GREEN_CANDY", "PURPLE_CANDY", "PUMPKIN_GUTS", "ECTOPLASM", "WEREWOLF_SKIN", "SPOOKY_SHARD"], texture: "12ef39437d7d43a034c5a40b974e8d2c6734a218c76485d04910f507bdc2e809", }, WINTER_SACK: { @@ -931,7 +924,7 @@ export const SACKS = { "DOUBLE_PLANT:5", "ENDSTONE_ROSE", "ENCHANTED_DANDELION", - "ENCHANTED_POPPY" + "ENCHANTED_POPPY", ], texture: "afc3b5db9bd99cd12161ed2ea4623795f28e793c6dab67cd3e803ccfaaad7cfd", }, From 38727a28b041a8ce9c22a5df2b9c4a0c1fcaf064 Mon Sep 17 00:00:00 2001 From: DuckySoLucky Date: Sun, 6 Aug 2023 15:00:58 +0200 Subject: [PATCH 09/12] refactor: clean code --- public/resources/ts/elements/rich-item.ts | 2 +- src/constants/sacks.js | 536 ++++++---------------- src/lib.js | 90 +--- src/stats.js | 1 + src/stats/sacks.js | 92 ++++ 5 files changed, 237 insertions(+), 484 deletions(-) create mode 100644 src/stats.js create mode 100644 src/stats/sacks.js diff --git a/public/resources/ts/elements/rich-item.ts b/public/resources/ts/elements/rich-item.ts index 446abfad53..3c9ae32bd5 100644 --- a/public/resources/ts/elements/rich-item.ts +++ b/public/resources/ts/elements/rich-item.ts @@ -57,7 +57,7 @@ export class InventoryView extends LitElement { return html`
${this.item.Count != 1 - ? html`
${formatNumber(this.item.Count, false, 10)}
` + ? html`
${formatNumber(this.item.Count, false, 0)}
` : undefined} `; } diff --git a/src/constants/sacks.js b/src/constants/sacks.js index 9d797bd4dc..64d7b535a6 100644 --- a/src/constants/sacks.js +++ b/src/constants/sacks.js @@ -402,468 +402,212 @@ export const SACKS = { texture: "fb96c585ccd35f073da38d165cb9bb18ff136f1a184eee3f44725354640ebbd4", }, RUNE_SACK: { - items: { - "???": { - display_name: "§7◆ ??? Rune ?", - texture: "82b8207a5fe192cd477e921466197c8af749af18dd1ef389e2733a2f74d0928b", - tier: "common", - }, - RUNE_BITE_1: { - display_name: "◆ Bite Rune I", - texture: "43a1ad4fcc42fb63c681328e42d63c83ca193b333af2a426728a25a8cc600692", - tier: "epic", - }, - RUNE_BITE_2: { - display_name: "◆ Bite Rune II", - texture: "43a1ad4fcc42fb63c681328e42d63c83ca193b333af2a426728a25a8cc600692", - tier: "epic", - }, - RUNE_BITE_3: { - display_name: "◆ Bite Rune III", + items: [ + { + name: "◆ Bite Rune", texture: "43a1ad4fcc42fb63c681328e42d63c83ca193b333af2a426728a25a8cc600692", - tier: "epic", - }, - RUNE_BLOOD_2_1: { - display_name: "◆ Blood Rune I", - texture: "e02677053dc54245dac4b399d14aae21ee71a010bd9c336c8ecee1a0dbe8f58b", - tier: "common", + rarity: "epic", + items: ["RUNE_BITE_1", "RUNE_BITE_2", "RUNE_BITE_3"], }, - RUNE_BLOOD_2_2: { - display_name: "◆ Blood Rune II", + { + name: "◆ Blood Rune", texture: "e02677053dc54245dac4b399d14aae21ee71a010bd9c336c8ecee1a0dbe8f58b", - tier: "common", + rarity: "common", + items: ["RUNE_BLOOD_2_1", "RUNE_BLOOD_2_2", "RUNE_BLOOD_2_3"], }, - RUNE_BLOOD_2_3: { - display_name: "◆ Blood Rune III", - texture: "e02677053dc54245dac4b399d14aae21ee71a010bd9c336c8ecee1a0dbe8f58b", - tier: "common", + { + name: "◆ Clouds Rune", + texture: "2273740d454de962484712f9835e35119b37ab867fa6982d5cc1f333c2334e59", + rarity: "epic", + items: ["RUNE_CLOUDS_1", "RUNE_CLOUDS_2", "RUNE_CLOUDS_3"], }, - RUNE_COUTURE_1: { - display_name: "◆ Couture Rune II", + { + name: "◆ Couture Rune", texture: "734fb3203233efbae82628bd4fca7348cd071e5b7b52407f1d1d2794e31799ff", - tier: "legendary", + rarity: "legendary", + items: ["RUNE_COUTURE_1", "RUNE_COUTURE_2", "RUNE_COUTURE_3"], }, - RUNE_COUTURE_3: { - display_name: "◆ Couture Rune III", - texture: "734fb3203233efbae82628bd4fca7348cd071e5b7b52407f1d1d2794e31799ff", - tier: "legendary", - }, - RUNE_DRAGON_1: { - display_name: "◆ End Rune I", - texture: "3b11fb90db7f57beb435954013b1c7ef776c6bd96cbf3308aa8ebac29591ebbd", - tier: "epic", - }, - RUNE_DRAGON_2: { - display_name: "◆ End Rune II", + { + name: "◆ End Rune", texture: "3b11fb90db7f57beb435954013b1c7ef776c6bd96cbf3308aa8ebac29591ebbd", - tier: "epic", - }, - RUNE_DRAGON_3: { - display_name: "◆ End Rune III", - texture: "3b11fb90db7f57beb435954013b1c7ef776c6bd96cbf3308aa8ebac29591ebbd", - tier: "epic", - }, - RUNE_ENCHANT_1: { - display_name: "◆ Enchant Rune I", - texture: "59ffacec6ee5a23d9cb24a2fe9dc15b24488f5f71006924560bf12148421ae6d", - tier: "legendary", - }, - RUNE_ENCHANT_2: { - display_name: "◆ Enchant Rune II", - texture: "59ffacec6ee5a23d9cb24a2fe9dc15b24488f5f71006924560bf12148421ae6d", - tier: "legendary", + rarity: "epic", + items: ["RUNE_DRAGON_1", "RUNE_DRAGON_2", "RUNE_DRAGON_3"], }, - RUNE_ENCHANT_3: { - display_name: "◆ Enchant Rune III", + { + name: "◆ Enchant Rune", texture: "59ffacec6ee5a23d9cb24a2fe9dc15b24488f5f71006924560bf12148421ae6d", - tier: "legendary", - }, - RUNE_ENDERSNAKE_1: { - display_name: "◆ Endersnake Rune I", - texture: "c3a9acbb7d3d49b1d54d26111104d0da57d8b4ab37885b4bbd240ac71074cad2", - tier: "legendary", - }, - RUNE_ENDERSNAKE_2: { - display_name: "◆ Endersnake Rune II", - texture: "c3a9acbb7d3d49b1d54d26111104d0da57d8b4ab37885b4bbd240ac71074cad2", - tier: "legendary", + rarity: "legendary", + items: ["RUNE_ENCHANT_1", "RUNE_ENCHANT_2", "RUNE_ENCHANT_3"], }, - RUNE_ENDERSNAKE_3: { - display_name: "◆ Endersnake Rune III", + { + name: "◆ Endersnake Rune", texture: "c3a9acbb7d3d49b1d54d26111104d0da57d8b4ab37885b4bbd240ac71074cad2", - tier: "legendary", + rarity: "legendary", + items: ["RUNE_ENDERSNAKE_1", "RUNE_ENDERSNAKE_2", "RUNE_ENDERSNAKE_3"], }, - RUNE_FIERY_BURST_1: { - display_name: "◆ Fiery Burst Rune I", + { + name: "◆ Fiery Burst Rune", texture: "8d620e4e3d3abfed6ad81a58a56bcd085d9e9efc803cabb21fa6c9e3969e2d2e", - tier: "legendary", - }, - RUNE_FIERY_BURST_2: { - display_name: "◆ Fiery Burst Rune II", - texture: "8d620e4e3d3abfed6ad81a58a56bcd085d9e9efc803cabb21fa6c9e3969e2d2e", - tier: "legendary", - }, - RUNE_FIERY_BURST_3: { - display_name: "◆ Fiery Burst Rune III", - texture: "8d620e4e3d3abfed6ad81a58a56bcd085d9e9efc803cabb21fa6c9e3969e2d2e", - tier: "legendary", - }, - RUNE_FIRE_SPIRAL_1: { - display_name: "◆ Fire Spiral Rune I", - texture: "8301aa86cafd4b2d732a9b4894cfcfc65edc828e8571b45dbf0a3ba96575cccf", - tier: "rare", - }, - RUNE_FIRE_SPIRAL_2: { - display_name: "◆ Fire Spiral Rune II", - texture: "8301aa86cafd4b2d732a9b4894cfcfc65edc828e8571b45dbf0a3ba96575cccf", - tier: "rare", + rarity: "legendary", + items: ["RUNE_FIERY_BURST_1", "RUNE_FIERY_BURST_2", "RUNE_FIERY_BURST_3"], }, - RUNE_FIRE_SPIRAL_3: { - display_name: "◆ Fire Spiral Rune III", + { + name: "◆ Fire Spiral Rune", texture: "8301aa86cafd4b2d732a9b4894cfcfc65edc828e8571b45dbf0a3ba96575cccf", - tier: "rare", + rarity: "rare", + items: ["RUNE_FIRE_SPIRAL_1", "RUNE_FIRE_SPIRAL_2", "RUNE_FIRE_SPIRAL_3"], }, - RUNE_GEM_1: { - display_name: "◆ Gem Rune I", + { + name: "◆ Gem Rune", texture: "43a1ad4fcc42fb63c681328e42d63c83ca193b333af2a426728a25a8cc600692", - tier: "common", + rarity: "common", + items: ["RUNE_GEM_1", "RUNE_GEM_2", "RUNE_GEM_3"], }, - RUNE_GEM_2: { - display_name: "◆ Gem Rune II", - texture: "43a1ad4fcc42fb63c681328e42d63c83ca193b333af2a426728a25a8cc600692", - tier: "common", - }, - RUNE_GEM_3: { - display_name: "◆ Gem Rune III", - texture: "43a1ad4fcc42fb63c681328e42d63c83ca193b333af2a426728a25a8cc600692", - tier: "common", - }, - RUNE_GOLDEN_1: { - display_name: "◆ Golden Rune I", - texture: "35f4861aa5b22ee28a90e75dab45d221efd14c0b1ecc8ee998fb67e43bb8f3de", - tier: "epic", - }, - RUNE_GOLDEN_2: { - display_name: "◆ Golden Rune II", - texture: "35f4861aa5b22ee28a90e75dab45d221efd14c0b1ecc8ee998fb67e43bb8f3de", - tier: "epic", - }, - RUNE_GOLDEN_3: { - display_name: "◆ Golden Rune III", + { + name: "◆ Golden Rune", texture: "35f4861aa5b22ee28a90e75dab45d221efd14c0b1ecc8ee998fb67e43bb8f3de", - tier: "epic", + rarity: "epic", + items: ["RUNE_GOLDEN_1", "RUNE_GOLDEN_2", "RUNE_GOLDEN_3"], }, - RUNE_GRAND_SEARING_3: { - display_name: "◆ Grand Searing Rune III", + { + name: "◆ Grand Searing Rune", texture: "87217a791685cf4fbb78674756a4f9793ae5fd0525dae362b491cc7a472ec64b", - tier: "legendary", + rarity: "legendary", + items: ["RUNE_GRAND_SEARING_3"], }, - RUNE_HEARTS_1: { - display_name: "◆ Hearts Rune I", + { + name: "◆ Hearts Rune", texture: "2c1c179ad51955f1522c48ea9931f09c162741b45e22e9d3feb682c7e5ed8274", - tier: "rare", + rarity: "rare", + items: ["RUNE_HEARTS_1", "RUNE_HEARTS_2", "RUNE_HEARTS_3"], }, - RUNE_HEARTS_2: { - display_name: "◆ Hearts Rune II", - texture: "2c1c179ad51955f1522c48ea9931f09c162741b45e22e9d3feb682c7e5ed8274", - tier: "rare", - }, - RUNE_HEARTS_3: { - display_name: "◆ Hearts Rune III", - texture: "2c1c179ad51955f1522c48ea9931f09c162741b45e22e9d3feb682c7e5ed8274", - tier: "rare", - }, - RUNE_HOT_1: { - display_name: "◆ Hot Rune I", + { + name: "◆ Hot Rune", texture: "26660b016d05645fffd1f48b792d1abe5d8f30dc96567569ae1d982d250b693c", - tier: "uncommon", + rarity: "uncommon", + items: ["RUNE_HOT_1", "RUNE_HOT_2", "RUNE_HOT_3"], }, - RUNE_HOT_2: { - display_name: "◆ Hot Rune II", - texture: "26660b016d05645fffd1f48b792d1abe5d8f30dc96567569ae1d982d250b693c", - tier: "uncommon", - }, - RUNE_HOT_3: { - display_name: "◆ Hot Rune III", - texture: "26660b016d05645fffd1f48b792d1abe5d8f30dc96567569ae1d982d250b693c", - tier: "uncommon", - }, - RUNE_ICE_1: { - display_name: "◆ Ice Rune I", - texture: "cdc57c75adf39ec6f0e0916049dd9671e98a8a1e600104e84e645c988950bd7", - tier: "rare", - }, - RUNE_ICE_2: { - display_name: "◆ Ice Rune II", + { + name: "◆ Ice Rune", texture: "cdc57c75adf39ec6f0e0916049dd9671e98a8a1e600104e84e645c988950bd7", - tier: "rare", + rarity: "rare", + items: ["RUNE_ICE_1", "RUNE_ICE_2", "RUNE_ICE_3"], }, - RUNE_ICE_3: { - display_name: "◆ Ice Rune III", - texture: "cdc57c75adf39ec6f0e0916049dd9671e98a8a1e600104e84e645c988950bd7", - tier: "rare", - }, - RUNE_JERRY_3: { - display_name: "◆ Jerry Rune III", + { + name: "◆ Jerry Rune", texture: "a1353ba65b6521f922b6464d17af39bddd43c984b8a227d99161594eba7a14c4", - tier: "common", - }, - RUNE_LAVATEARS_1: { - display_name: "◆ Lavatears Rune I", - texture: "8c8ccd5f863d82bb097b926bc5f4cca97b19f46e11b3a3a59d001adb89886773", - tier: "legendary", + rarity: "common", + items: ["RUNE_JERRY_3"], }, - RUNE_LAVATEARS_2: { - display_name: "◆ Lavatears Rune II", + { + name: "◆ Lavatears Rune", texture: "8c8ccd5f863d82bb097b926bc5f4cca97b19f46e11b3a3a59d001adb89886773", - tier: "legendary", + rarity: "legendary", + items: ["RUNE_LAVATEARS_1", "RUNE_LAVATEARS_2", "RUNE_LAVATEARS_3"], }, - RUNE_LAVATEARS_3: { - display_name: "◆ Lavatears Rune III", - texture: "8c8ccd5f863d82bb097b926bc5f4cca97b19f46e11b3a3a59d001adb89886773", - tier: "legendary", - }, - RUNE_LAVA_1: { - display_name: "◆ Lava Rune I", - texture: "b13d903f601034ac3400d2625fef104e9b0940746c554193f6d9e85a84a966a1", - tier: "common", - }, - RUNE_LAVA_2: { - display_name: "◆ Lava Rune II", + { + name: "◆ Lava Rune", texture: "b13d903f601034ac3400d2625fef104e9b0940746c554193f6d9e85a84a966a1", - tier: "common", - }, - RUNE_LAVA_3: { - display_name: "◆ Lava Rune III", - texture: "b13d903f601034ac3400d2625fef104e9b0940746c554193f6d9e85a84a966a1", - tier: "common", - }, - RUNE_LIGHTNING_1: { - display_name: "◆ Lightning Rune I", - texture: "b85bcf7f82d34db89a95addf8e53253e2d9554c6fd2f2e39e24362d243a0ccf7", - tier: "legendary", - }, - RUNE_LIGHTNING_2: { - display_name: "◆ Lightning Rune II", - texture: "b85bcf7f82d34db89a95addf8e53253e2d9554c6fd2f2e39e24362d243a0ccf7", - tier: "legendary", + rarity: "common", + items: ["RUNE_LAVA_1", "RUNE_LAVA_2", "RUNE_LAVA_3"], }, - RUNE_LIGHTNING_3: { - display_name: "◆ Lightning Rune III", + { + name: "◆ Lightning Rune", texture: "b85bcf7f82d34db89a95addf8e53253e2d9554c6fd2f2e39e24362d243a0ccf7", - tier: "legendary", - }, - RUNE_MAGIC_1: { - display_name: "◆ Magical Rune I", - texture: "24480e39ea63e347d268de83090d09984bf34394118848348bf4eb57490ce9d2", - tier: "rare", - }, - RUNE_MAGIC_2: { - display_name: "◆ Magical Rune II", - texture: "24480e39ea63e347d268de83090d09984bf34394118848348bf4eb57490ce9d2", - tier: "rare", + rarity: "legendary", + items: ["RUNE_LIGHTNING_1", "RUNE_LIGHTNING_2", "RUNE_LIGHTNING_3"], }, - RUNE_MAGIC_3: { - display_name: "◆ Magical Rune III", + { + name: "◆ Magical Rune", texture: "24480e39ea63e347d268de83090d09984bf34394118848348bf4eb57490ce9d2", - tier: "rare", + rarity: "rare", + items: ["RUNE_MAGIC_1", "RUNE_MAGIC_2", "RUNE_MAGIC_3"], }, - RUNE_MUSIC_1: { - display_name: "◆ Music Rune I", + { + name: "◆ Music Rune", texture: "3b481c31dc683bdcb7d375a7c5db7ac7adf9e9fe8b6c04a64931613e29fe470e", - tier: "epic", - }, - RUNE_MUSIC_2: { - display_name: "◆ Music Rune II", - texture: "3b481c31dc683bdcb7d375a7c5db7ac7adf9e9fe8b6c04a64931613e29fe470e", - tier: "epic", - }, - RUNE_MUSIC_3: { - display_name: "◆ Music Rune III", - texture: "3b481c31dc683bdcb7d375a7c5db7ac7adf9e9fe8b6c04a64931613e29fe470e", - tier: "epic", - }, - RUNE_RAINBOW_1: { - display_name: "◆ Rainbow Rune I", - texture: "72114a80357463fe2f59e397aab9fc66d482a65d524f8870d21c724c18ecf757", - tier: "legendary", - }, - RUNE_RAINBOW_2: { - display_name: "◆ Rainbow Rune II", - texture: "72114a80357463fe2f59e397aab9fc66d482a65d524f8870d21c724c18ecf757", - tier: "legendary", + rarity: "epic", + items: ["RUNE_MUSIC_1", "RUNE_MUSIC_2", "RUNE_MUSIC_3"], }, - RUNE_RAINBOW_3: { - display_name: "◆ Rainbow Rune III", + { + name: "◆ Rainbow Rune", texture: "72114a80357463fe2f59e397aab9fc66d482a65d524f8870d21c724c18ecf757", - tier: "legendary", + rarity: "legendary", + items: ["RUNE_RAINBOW_1", "RUNE_RAINBOW_2", "RUNE_RAINBOW_3"], }, - RUNE_REDSTONE_1: { - display_name: "◆ Redstone Rune I", + { + name: "◆ Redstone Rune", texture: "87a7a894057d4a1ff22a161d76600f719da57916633f683808cf4d358bb73a21", - tier: "rare", + rarity: "rare", + items: ["RUNE_REDSTONE_1", "RUNE_REDSTONE_2", "RUNE_REDSTONE_3"], }, - RUNE_REDSTONE_2: { - display_name: "◆ Redstone Rune II", - texture: "87a7a894057d4a1ff22a161d76600f719da57916633f683808cf4d358bb73a21", - tier: "rare", - }, - RUNE_REDSTONE_3: { - display_name: "◆ Redstone Rune III", - texture: "87a7a894057d4a1ff22a161d76600f719da57916633f683808cf4d358bb73a21", - tier: "rare", - }, - RUNE_SMOKEY_1: { - display_name: "◆ Smokey Rune I", - texture: "e4d8a8d527f65a4f434f894f7ee42eb843015bda7927c63c6ea8a754afe9bb1b", - tier: "common", - }, - RUNE_SMOKEY_2: { - display_name: "◆ Smokey Rune II", - texture: "e4d8a8d527f65a4f434f894f7ee42eb843015bda7927c63c6ea8a754afe9bb1b", - tier: "common", - }, - RUNE_SMOKEY_3: { - display_name: "◆ Smokey Rune III", + { + name: "◆ Smokey Rune", texture: "e4d8a8d527f65a4f434f894f7ee42eb843015bda7927c63c6ea8a754afe9bb1b", - tier: "common", + rarity: "common", + items: ["RUNE_SMOKEY_1", "RUNE_SMOKEY_2", "RUNE_SMOKEY_3"], }, - RUNE_SNAKE_1: { - display_name: "◆ Snake Rune I", + { + name: "◆ Snake Rune", texture: "2c4a65c689b2d36409100a60c2ab8d3d0a67ce94eea3c1f7ac974fd893568b5d", - tier: "legendary", + rarity: "legendary", + items: ["RUNE_SNAKE_1", "RUNE_SNAKE_2", "RUNE_SNAKE_3"], }, - RUNE_SNAKE_2: { - display_name: "◆ Snake Rune II", - texture: "2c4a65c689b2d36409100a60c2ab8d3d0a67ce94eea3c1f7ac974fd893568b5d", - tier: "legendary", - }, - RUNE_SNAKE_3: { - display_name: "◆ Snake Rune III", - texture: "2c4a65c689b2d36409100a60c2ab8d3d0a67ce94eea3c1f7ac974fd893568b5d", - tier: "legendary", - }, - RUNE_SNOW_1: { - display_name: "◆ Snow Rune I", + { + name: "◆ Snow Rune", texture: "cdc57c75adf39ec6f0e0916049dd9671e98a8a1e600104e84e645c988950bd7", - tier: "common", + rarity: "common", + items: ["RUNE_SNOW_1", "RUNE_SNOW_2", "RUNE_SNOW_3"], }, - RUNE_SNOW_2: { - display_name: "◆ Snow Rune II", - texture: "cdc57c75adf39ec6f0e0916049dd9671e98a8a1e600104e84e645c988950bd7", - tier: "common", - }, - RUNE_SNOW_3: { - display_name: "◆ Snow Rune III", - texture: "cdc57c75adf39ec6f0e0916049dd9671e98a8a1e600104e84e645c988950bd7", - tier: "common", + { + name: "◆ Soultwist Rune", + texture: "f5ffdfbd490fc7310d61a1c4c35a4e0cd2f9fccc1239c6a4bcd7dec05e25ea67", + rarity: "epic", + items: ["RUNE_SOULTWIST_1", "RUNE_SOULTWIST_2", "RUNE_SOULTWIST_3"], }, - RUNE_SPARKLING_1: { - display_name: "◆ Sparkling Rune I", + { + name: "◆ Sparkling Rune", texture: "f1e2428cb359988f4c4ff0e61de21385c62269de19a69762d773223b75dd1666", - tier: "rare", + rarity: "rare", + items: ["RUNE_SPARKLING_1", "RUNE_SPARKLING_2", "RUNE_SPARKLING_3"], }, - RUNE_SPARKLING_2: { - display_name: "◆ Sparkling Rune II", - texture: "f1e2428cb359988f4c4ff0e61de21385c62269de19a69762d773223b75dd1666", - tier: "rare", - }, - RUNE_SPARKLING_3: { - display_name: "◆ Sparkling Rune III", - texture: "f1e2428cb359988f4c4ff0e61de21385c62269de19a69762d773223b75dd1666", - tier: "rare", - }, - RUNE_SPIRIT_1: { - display_name: "◆ Spirit Rune I", - texture: "c738b8af8d7ce1a26dc6d40180b3589403e11ef36a66d7c4590037732829542e", - tier: "rare", - }, - RUNE_SPIRIT_2: { - display_name: "◆ Spirit Rune II", - texture: "c738b8af8d7ce1a26dc6d40180b3589403e11ef36a66d7c4590037732829542e", - tier: "rare", - }, - RUNE_SPIRIT_3: { - display_name: "◆ Spirit Rune III", + { + name: "◆ Spirit Rune", texture: "c738b8af8d7ce1a26dc6d40180b3589403e11ef36a66d7c4590037732829542e", - tier: "rare", + rarity: "rare", + items: ["RUNE_SPIRIT_1", "RUNE_SPIRIT_2", "RUNE_SPIRIT_3"], }, - RUNE_TIDAL_1: { - display_name: "◆ Tidal Rune I", + { + name: "◆ Tidal Rune", texture: "69671047c6ade8a9c4d6a581bc26d284a54ae32e85c34ce69d81f92799bf3fbb", - tier: "legendary", + rarity: "legendary", + items: ["RUNE_TIDAL_1", "RUNE_TIDAL_2", "RUNE_TIDAL_3"], }, - RUNE_TIDAL_2: { - display_name: "◆ Tidal Rune II", - texture: "69671047c6ade8a9c4d6a581bc26d284a54ae32e85c34ce69d81f92799bf3fbb", - tier: "legendary", - }, - RUNE_TIDAL_3: { - display_name: "◆ Tidal Rune III", - texture: "69671047c6ade8a9c4d6a581bc26d284a54ae32e85c34ce69d81f92799bf3fbb", - tier: "legendary", - }, - RUNE_WAKE_1: { - display_name: "◆ Wake Rune I", + { + name: "◆ Wake Rune", texture: "977c1fc93216e96d435cf962e1173de8d1a249b644894d72676eba732fcd56e7", - tier: "legendary", + rarity: "legendary", + items: ["RUNE_WAKE_1", "RUNE_WAKE_2", "RUNE_WAKE_3"], }, - RUNE_WAKE_2: { - display_name: "◆ Wake Rune II", - texture: "977c1fc93216e96d435cf962e1173de8d1a249b644894d72676eba732fcd56e7", - tier: "legendary", - }, - RUNE_WAKE_3: { - display_name: "◆ Wake Rune III", - texture: "977c1fc93216e96d435cf962e1173de8d1a249b644894d72676eba732fcd56e7", - tier: "legendary", - }, - RUNE_WHITE_SPIRAL_1: { - display_name: "◆ White Spiral Rune I", - texture: "3ef2432ef305361384d4318df5bda5bd1ac2d9bea06d1f5cfead6dd87e37ddf5", - tier: "uncommon", - }, - RUNE_WHITE_SPIRAL_2: { - display_name: "◆ White Spiral Rune II", + { + name: "◆ White Spiral Rune", texture: "3ef2432ef305361384d4318df5bda5bd1ac2d9bea06d1f5cfead6dd87e37ddf5", - tier: "uncommon", - }, - RUNE_WHITE_SPIRAL_3: { - display_name: "◆ White Spiral Rune III", - texture: "3ef2432ef305361384d4318df5bda5bd1ac2d9bea06d1f5cfead6dd87e37ddf5", - tier: "uncommon", - }, - RUNE_ZAP_1: { - display_name: "◆ Zap Rune I", - texture: "ed0947c40de6789f6cfa2370add2a04c9855e45fde9483d655101e9510288ee8", - tier: "uncommon", + rarity: "uncommon", + items: ["RUNE_WHITE_SPIRAL_1", "RUNE_WHITE_SPIRAL_2", "RUNE_WHITE_SPIRAL_3"], }, - RUNE_ZAP_2: { - display_name: "◆ Zap Rune II", + { + name: "◆ Zap Rune", texture: "ed0947c40de6789f6cfa2370add2a04c9855e45fde9483d655101e9510288ee8", - tier: "uncommon", + rarity: "uncommon", + items: ["RUNE_ZAP_1", "RUNE_ZAP_2", "RUNE_ZAP_3"], }, - RUNE_ZAP_3: { - display_name: "◆ Zap Rune III", - texture: "ed0947c40de6789f6cfa2370add2a04c9855e45fde9483d655101e9510288ee8", - tier: "uncommon", - }, - RUNE_ZOMBIE_SLAYER_1: { - display_name: "◆ Pestilence Rune I", - texture: "a8c4811395fbf7f620f05cc3175cef1515aaf775ba04a01045027f0693a90147", - tier: "rare", - }, - RUNE_ZOMBIE_SLAYER_2: { - display_name: "◆ Pestilence Rune II", + { + name: "◆ Pestilence Rune", texture: "a8c4811395fbf7f620f05cc3175cef1515aaf775ba04a01045027f0693a90147", - tier: "rare", + rarity: "rare", + items: ["RUNE_ZOMBIE_SLAYER_1", "RUNE_ZOMBIE_SLAYER_2", "RUNE_ZOMBIE_SLAYER_3"], }, - RUNE_ZOMBIE_SLAYER_3: { - display_name: "◆ Pestilence Rune III", - texture: "a8c4811395fbf7f620f05cc3175cef1515aaf775ba04a01045027f0693a90147", - tier: "rare", - }, - }, + ], texture: "e91eb4ee3ecce3447483a1f151c11facc9de25577ab7b51fbf3d9c2b2a4b69fc", }, SLAYER_SACK: { diff --git a/src/lib.js b/src/lib.js index f866bc6631..3052c3cf99 100644 --- a/src/lib.js +++ b/src/lib.js @@ -19,6 +19,7 @@ import { db } from "./mongo.js"; import { redisClient } from "./redis.js"; import { calculateLilyWeight } from "./weight/lily-weight.js"; import { calculateSenitherWeight } from "./weight/senither-weight.js"; +import * as stats from "./stats.js"; const mcData = minecraftData("1.8.9"); const __dirname = path.dirname(fileURLToPath(import.meta.url)); @@ -1021,7 +1022,7 @@ export const getItems = async ( output.hotm = hotm; output.candy_bag = candy_bag; - const sacks = "sacks_counts" in profile ? await getSacks(profile.sacks_counts) : []; + const sacks = "sacks_counts" in profile ? await stats.getSacks(profile.sacks_counts) : []; output.sacks = sacks; const allItems = armor.concat( @@ -3024,92 +3025,6 @@ export async function getCollections(uuid, profile, cacheOnly = false) { return output; } -async function getSacks(sacksCounts) { - const sacks = []; - - for (const sackId in constants.SACKS) { - const sack = constants.SACKS[sackId]; - - if (sackId !== "RUNE_SACK" && sack.items.filter((a) => Object.keys(sacksCounts).includes(a)).length == 0) { - continue; - } - - const sackItem = Object.assign({}, constants.BASE_SACK); - - sackItem.texture_path = `/head/${sack.texture}`; - sackItem.display_name = _.startCase(sackId.toLowerCase()); - - if (sackId === "RUNE_SACK") { - sackItem.containsItems = []; - for (const ID in sack.items) { - if (ID === "???") continue; - - const item = sack.items[ID] ?? sack.items["???"]; - - const sackContent = { - Count: sacksCounts[ID] ?? 1, - sack_count: sacksCounts[ID] ?? 0, - Damage: 3, - id: 397, - itemIndex: sackItem.containsItems.length, - display_name: item.display_name, - rarity: item.tier, - texture_path: `/head/${item.texture}`, - tag: { - display: { - Name: `§a${item.item}`, - Lore: [`§8Stored: §e${(sacksCounts[ID] ?? 0).toLocaleString()}`], - }, - }, - categories: [], - }; - - sackItem.containsItems.push(sackContent); - } - } else { - sackItem.containsItems = []; - - for (const [index, item] of sack.items.entries()) { - const hypixelItem = await db.collection("items").findOne({ id: constants.ITEM_SACKS[item] ?? item }); - - const itemName = hypixelItem?.name ?? _.startCase(item.toLowerCase()); - - const count = sacksCounts[item] === 0 ? 1 : sacksCounts[item]; - - const sackContent = { - Count: count ?? 1, - sack_count: sacksCounts[item] ?? 0, - Damage: hypixelItem?.damage ?? 3, - id: hypixelItem?.item_id ?? 397, - itemIndex: index, - display_name: itemName, - tag: { - display: { - Name: `§a${itemName}`, - Lore: [`§8Stored: §e${(sacksCounts[item] ?? 0).toLocaleString()}`], - }, - }, - categories: [], - }; - - if (hypixelItem?.glowing === true) { - sackContent.tag.ench = []; - } - - if (sackContent.id == 397 && hypixelItem?.texture) { - sackContent.texture_path = `/head/${hypixelItem.texture}`; - } - - sackItem.containsItems.push(sackContent); - } - } - - sacks.push(sackItem); - } - - return sacks; -} - export function getTrophyFish(userProfile) { const output = { total_caught: 0, @@ -3235,6 +3150,7 @@ export function getBestiary(uuid, profile) { return result; } + export function getDungeons(userProfile, hypixelProfile) { const output = {}; diff --git a/src/stats.js b/src/stats.js new file mode 100644 index 0000000000..2c6ba7977e --- /dev/null +++ b/src/stats.js @@ -0,0 +1 @@ +export * from "./stats/sacks.js"; diff --git a/src/stats/sacks.js b/src/stats/sacks.js new file mode 100644 index 0000000000..09fb216341 --- /dev/null +++ b/src/stats/sacks.js @@ -0,0 +1,92 @@ +import * as constants from "../constants.js"; +import { db } from "../mongo.js"; +import _ from "lodash"; + +export async function getSacks(sacksCounts) { + try { + const sacks = []; + for (const sackId in constants.SACKS) { + const sack = constants.SACKS[sackId]; + + if (sackId !== "RUNE_SACK" && sack.items.filter((a) => Object.keys(sacksCounts).includes(a)).length == 0) { + continue; + } + + const sackItem = Object.assign({}, constants.BASE_SACK); + + sackItem.containsItems = []; + sackItem.texture_path = `/head/${sack.texture}`; + sackItem.display_name = _.startCase(sackId.toLowerCase()); + + if (sackId === "RUNE_SACK") { + for (const runeData of sack.items) { + const itemCount = runeData.items.map((a) => sacksCounts[a] ?? 0).reduce((a, b) => a + b, 0); + + const lore = runeData.items + .map((a) => { + return [`§e${"I".repeat(runeData.items.indexOf(a) + 1)}§7: §e${(sacksCounts[a] ?? 0).toLocaleString()}`]; + }) + .flat(); + + const count = itemCount === 0 ? 1 : itemCount; + const sackContent = { + Count: count, + Damage: 3, + id: 397, + itemIndex: sackItem.containsItems.length, + display_name: runeData.name, + rarity: runeData.rarity, + texture_path: `/head/${runeData.texture}`, + tag: { + display: { + Name: `§a${runeData.name}`, + Lore: lore, + }, + }, + categories: [], + }; + + sackItem.containsItems.push(sackContent); + } + } else { + for (const item of sack.items) { + const hypixelItem = await db.collection("items").findOne({ id: constants.ITEM_SACKS[item] ?? item }); + const itemName = hypixelItem?.name ?? _.startCase(item.toLowerCase()); + + const count = sacksCounts[item] === 0 ? 1 : sacksCounts[item]; + const sackContent = { + Count: count ?? 1, + Damage: hypixelItem?.damage ?? 3, + id: hypixelItem?.item_id ?? 397, + itemIndex: sackItem.containsItems.length, + display_name: itemName, + tag: { + display: { + Name: `§a${itemName}`, + Lore: [`§8Stored: §e${(sacksCounts[item] ?? 0).toLocaleString()}`], + }, + }, + categories: [], + }; + + if (hypixelItem?.glowing === true) { + sackContent.tag.ench = []; + } + + if (sackContent.id == 397 && hypixelItem?.texture) { + sackContent.texture_path = `/head/${hypixelItem.texture}`; + } + + sackItem.containsItems.push(sackContent); + } + } + + sacks.push(sackItem); + } + + return sacks; + } catch (error) { + console.log(error); + return null; + } +} From 9c41c9808dc089249e757ecb6a2589d5893d7c77 Mon Sep 17 00:00:00 2001 From: DuckySoLucky Date: Sun, 6 Aug 2023 15:06:49 +0200 Subject: [PATCH 10/12] fix: rune sack being shown even if not unlocked --- src/stats/sacks.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/stats/sacks.js b/src/stats/sacks.js index 09fb216341..1629bdee0f 100644 --- a/src/stats/sacks.js +++ b/src/stats/sacks.js @@ -8,7 +8,15 @@ export async function getSacks(sacksCounts) { for (const sackId in constants.SACKS) { const sack = constants.SACKS[sackId]; - if (sackId !== "RUNE_SACK" && sack.items.filter((a) => Object.keys(sacksCounts).includes(a)).length == 0) { + if ( + sack.items.filter((a) => { + if (typeof a === "object") { + return a.items.filter((b) => Object.keys(sacksCounts).includes(b)).length > 0; + } + + return Object.keys(sacksCounts).includes(a); + }).length == 0 + ) { continue; } From 9dc08a66529d8ba933450b0cc7898ef76614b26b Mon Sep 17 00:00:00 2001 From: DuckySoLucky Date: Thu, 31 Aug 2023 16:16:11 +0200 Subject: [PATCH 11/12] refactor: clean code --- src/stats.js | 2 +- src/stats/items.js | 1 + src/stats/{ => items}/sacks.js | 30 +++++++++++++++--------------- 3 files changed, 17 insertions(+), 16 deletions(-) create mode 100644 src/stats/items.js rename src/stats/{ => items}/sacks.js (78%) diff --git a/src/stats.js b/src/stats.js index 2c6ba7977e..5030a78017 100644 --- a/src/stats.js +++ b/src/stats.js @@ -1 +1 @@ -export * from "./stats/sacks.js"; +export * from "./stats/items.js"; diff --git a/src/stats/items.js b/src/stats/items.js new file mode 100644 index 0000000000..59947da5fb --- /dev/null +++ b/src/stats/items.js @@ -0,0 +1 @@ +export * from "./items/sacks.js"; diff --git a/src/stats/sacks.js b/src/stats/items/sacks.js similarity index 78% rename from src/stats/sacks.js rename to src/stats/items/sacks.js index 1629bdee0f..f35a2857f5 100644 --- a/src/stats/sacks.js +++ b/src/stats/items/sacks.js @@ -1,5 +1,5 @@ -import * as constants from "../constants.js"; -import { db } from "../mongo.js"; +import * as constants from "../../constants.js"; +import { db } from "../../mongo.js"; import _ from "lodash"; export async function getSacks(sacksCounts) { @@ -8,15 +8,12 @@ export async function getSacks(sacksCounts) { for (const sackId in constants.SACKS) { const sack = constants.SACKS[sackId]; - if ( - sack.items.filter((a) => { - if (typeof a === "object") { - return a.items.filter((b) => Object.keys(sacksCounts).includes(b)).length > 0; - } + const sackItems = sack.items.filter((a) => { + const items = typeof a === "object" ? a.items : [a]; - return Object.keys(sacksCounts).includes(a); - }).length == 0 - ) { + return items.some((b) => Object.keys(sacksCounts).includes(b)); + }); + if (sackItems.length === 0) { continue; } @@ -59,13 +56,16 @@ export async function getSacks(sacksCounts) { } else { for (const item of sack.items) { const hypixelItem = await db.collection("items").findOne({ id: constants.ITEM_SACKS[item] ?? item }); - const itemName = hypixelItem?.name ?? _.startCase(item.toLowerCase()); + if (hypixelItem === null) { + continue; + } + const itemName = hypixelItem.name ?? _.startCase(item.toLowerCase()); const count = sacksCounts[item] === 0 ? 1 : sacksCounts[item]; const sackContent = { Count: count ?? 1, - Damage: hypixelItem?.damage ?? 3, - id: hypixelItem?.item_id ?? 397, + Damage: hypixelItem.damage ?? 3, + id: hypixelItem.item_id ?? 397, itemIndex: sackItem.containsItems.length, display_name: itemName, tag: { @@ -77,11 +77,11 @@ export async function getSacks(sacksCounts) { categories: [], }; - if (hypixelItem?.glowing === true) { + if (hypixelItem.glowing === true) { sackContent.tag.ench = []; } - if (sackContent.id == 397 && hypixelItem?.texture) { + if (sackContent.id == 397 && hypixelItem.texture) { sackContent.texture_path = `/head/${hypixelItem.texture}`; } From dce5d77410e26dd35e1280df8aff5a22e711520c Mon Sep 17 00:00:00 2001 From: DuckySoLucky Date: Thu, 31 Aug 2023 16:18:03 +0200 Subject: [PATCH 12/12] oops --- src/lib.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib.js b/src/lib.js index d0f4e4f21f..23010ddf65 100644 --- a/src/lib.js +++ b/src/lib.js @@ -11,7 +11,6 @@ import { fileURLToPath } from "url"; import util from "util"; import { v4 } from "uuid"; -import * as stats from "./stats.js"; import * as constants from "./constants.js"; import credentials from "./credentials.js"; import { getTexture } from "./custom-resources.js";