From 7f81943394c6702ac0a7ce7022c66c2044ce9f19 Mon Sep 17 00:00:00 2001 From: John Doe Date: Sun, 17 Apr 2022 01:08:38 +0200 Subject: [PATCH 1/9] initial commit --- src/constants/misc.js | 471 ++++++++++++++++++++++++++++++++++++++++++ src/helper.js | 8 +- src/lib.js | 40 ++++ views/stats.ejs | 53 +++++ 4 files changed, 571 insertions(+), 1 deletion(-) diff --git a/src/constants/misc.js b/src/constants/misc.js index 7de70c0e59..6d873dcf40 100644 --- a/src/constants/misc.js +++ b/src/constants/misc.js @@ -360,3 +360,474 @@ export const fairy_souls = { stranded: 3, }, }; + +export const tieredAchievements = { + skyblock_angler: { + name: "Angler", + description: "Achieve Fishing levels", + tierLevelRequirements: [5, 10, 15, 20, 25], + tierRewards: [5, 5, 10, 10, 15], + }, + skyblock_augmentation: { + name: "Augmentation", + description: "Achieve Enchanting levels", + tierLevelRequirements: [5, 10, 15, 20, 25], + tierRewards: [5, 5, 10, 10, 15], + }, + skyblock_combat: { + name: "Combat!", + description: "Achieve Combat levels", + tierLevelRequirements: [5, 10, 15, 20, 25], + tierRewards: [5, 5, 10, 10, 15], + }, + skyblock_concoctor: { + name: "Concoctor", + description: "Achieve Alchemy levels", + tierLevelRequirements: [5, 10, 15, 20, 25], + tierRewards: [5, 5, 10, 10, 15], + }, + skyblock_crystal_nucleus: { + name: "Crystal Nucleus", + description: "Complete a Crystal Nucleus run by placing all 5 Crystals", + tierLevelRequirements: [5, 10, 15, 20, 25], + tierRewards: [5, 10, 15, 20, 25], + }, + skyblock_divans_treasures: { + name: "Divan's Treasures", + description: "Find treasures in the Mines of Divan", + tierLevelRequirements: [30, 60, 90, 120, 150], + tierRewards: [5, 10, 15, 20, 25], + }, + skyblock_domesticator: { + name: "Domesticator", + description: "Achieve Taming levels", + tierLevelRequirements: [5, 10, 15, 20, 25], + tierRewards: [5, 5, 10, 10, 15], + }, + skyblock_dungeoneer: { + name: "Dungeoneer", + description: "Achieve Dungeoneering levels for any single Dungeon Class", + tierLevelRequirements: [15, 20, 25, 30, 35], + tierRewards: [5, 5, 10, 10, 15], + }, + skyblock_excavator: { + name: "Excavator", + description: "Achieve Mining levels", + tierLevelRequirements: [5, 10, 15, 20, 25], + tierRewards: [5, 5, 10, 10, 15], + }, + skyblock_unique_gifts: { + name: "Festive Altruist", + description: "Give Gifts to different players", + tierLevelRequirements: [5, 10, 25, 50, 100], + tierRewards: [5, 10, 15, 20, 25], + }, + skyblock_gatherer: { + name: "Gatherer", + description: "Achieve Foraging levels", + tierLevelRequirements: [5, 10, 15, 20, 25], + tierRewards: [5, 5, 10, 10, 15], + }, + skyblock_goblin_killer: { + name: "Goblin Killer", + description: "Kill Golden Goblins", + tierLevelRequirements: [5, 10, 25, 50, 100], + tierRewards: [5, 10, 15, 20, 25], + }, + skyblock_hard_working_miner: { + name: "Hard Working Miner", + description: "Complete Commissions", + tierLevelRequirements: [5, 25, 100, 250, 500], + tierRewards: [5, 10, 15, 20, 25], + }, + skyblock_harvester: { + name: "Harvester", + description: "Achieve Farming levels", + tierLevelRequirements: [5, 10, 15, 20, 25], + tierRewards: [5, 5, 10, 10, 15], + }, + skyblock_minion_lover: { + name: "Minion Lover", + description: "[Co-op or you] Craft unique Minions", + tierLevelRequirements: [10, 25, 100, 250, 500], + tierRewards: [5, 10, 15, 20, 25], + }, + skyblock_slayer: { + name: "Slayer", + description: "Get Slayer exp", + tierLevelRequirements: [10, 50, 100, 250, 500], + tierRewards: [5, 10, 15, 20, 25], + }, + skyblock_treasure_hunter: { + name: "Treasure Hunter", + description: "Find Secrets in Dungeons", + tierLevelRequirements: [10, 50, 100, 250, 1000], + tierRewards: [5, 10, 15, 20, 25], + }, + skyblock_treasury: { + name: "Treasury", + description: "Unlock Collections", + tierLevelRequirements: [10, 20, 30, 40, 50], + tierRewards: [5, 10, 15, 20, 25], + }, +}; + +export const oneTimeAchievements = { + skyblock_a_challenging_climb: { name: "A Challenging Climb", description: "Scale the Spider's Den", reward: 5 }, + skyblock_a_good_review: { name: "A Good Review", description: "Feed Don Expresso some Tasty Mithril", reward: 5 }, + skyblock_a_good_spider_is_a_dead_spider: { + name: "A good spider is a dead spider", + description: "Kill the Broodmother", + reward: 10, + }, + skyblock_royal_meeting: { name: "A Royal Meeting", description: "Obtain the King's Talisman", reward: 5 }, + skyblock_absorb_it_all: { name: "Absorb it all!", description: "Wear a full set of Sponge Armor", reward: 10 }, + skyblock_accessories_galore: { + name: "Accessories Galore", + description: "Unlock the Greater Accessory Bag upgrade", + reward: 5, + }, + skyblock_advanced_transportation: { + name: "Advanced Transportation", + description: "Sell an item using the Enchanted Hopper", + reward: 5, + }, + skyblock_agile: { name: "Agile", description: "Drink an Agility Potion", reward: 5 }, + skyblock_animal_fishing: { name: "Animal Fishing", description: "Fish using the Farmer's Rod", reward: 5 }, + skyblock_arcadia: { name: "Arcadia", description: "Place 5 unique Islands on your private world", reward: 5 }, + skyblock_speed_of_light: { name: "At the speed of light", description: "Use a Catalyst", reward: 5 }, + skyblock_baited: { name: "Baited", description: "Obtain the Bait Ring", reward: 5 }, + skyblock_beaconator_two: { name: "Beaconator 2.0", description: "Power a Beacon of any kind", reward: 5 }, + skyblock_big_game_fisher: { + name: "Big Game Fisher", + description: "Kill a Sea Creature that requires fishing level 20 or higher", + reward: 15, + }, + skyblock_bigger_storage_is_seeded: { + name: "Bigger Storage Is Seeded", + description: "Place a Large Storage Chest", + reward: 5, + }, + skyblock_brain_power: { name: "Brain Power", description: "Drink an Adrenaline Potion", reward: 5 }, + skyblock_businessman: { name: "Businessman", description: "Complete a trade with another player", reward: 5 }, + skyblock_caretaker: { name: "Caretaker", description: "Level up a Pet to 80", reward: 10 }, + skyblock_caught_the_grinch: { + name: "Caught the Grinch", + description: "Kill a Grinch on the Jerry Island", + reward: 15, + }, + skyblock_combined_efforts: { name: "Combined efforts", description: "Start a co-op", reward: 5 }, + skyblock_cute_little_cube: { + name: "Cute Little Cube", + description: "Land the final blow on killing a Magma Cube Boss", + reward: 10, + }, + skyblock_death_from_above: { + name: "Death From Above", + description: "Kill a mob using the damage from the Leaping Sword ability", + reward: 5, + }, + skyblock_deep_storage: { name: "Deep Storage", description: "Unlock the level 3 Ender Chest Upgrade", reward: 5 }, + skyblock_defeating_death: { + name: "Defeating Death", + description: "Slay a Deathmite (Secret Achievement)", + reward: 5, + }, + skyblock_didnt_mean_to: { name: "Didn't mean to!", description: "Kill a Kalhuiki Youngling", reward: 5 }, + skyblock_do_you_even_voodoo: { + name: "Do you even Voodoo?", + description: "Kill a mob with the Voodoo Doll ability", + reward: 10, + }, + skyblock_dragon_slayer: { name: "Dragon Slayer", description: "Take down a Dragon (Secret Achievement)", reward: 5 }, + skyblock_dullahan: { name: "Dullahan", description: "Kill a Headless Horseman", reward: 5 }, + skyblock_dungeon_explorer: { + name: "Dungeon Explorer", + description: "Get a score on exploration of 95 or more in a Dungeon.", + reward: 10, + }, + skyblock_empty_flower_pot: { + name: "Empty Flower Pot", + description: + "Why is it there? Why are we all here (Hold a flower and right click the flower pot at  -307, 82, 16 in The Park for 5 minutes) (Secret Achievement)", + reward: 5, + }, + skyblock_every_little_bit_helps: { + name: "Every little bit helps", + description: "Apply a Hot Potato Book to an item", + reward: 5, + }, + skyblock_existential_revelations: { + name: "Existential Revelations", + description: "Find the mushroom dream in the Catacombs (Secret Achievement)", + reward: 5, + }, + skyblock_expensive_brew: { name: "Expensive Brew", description: "Brew a Tier VIII Potion", reward: 10 }, + skyblock_explorer: { name: "Explorer", description: "Discover all Areas on the Hub Island", reward: 5 }, + skyblock_explosive_ending: { + name: "Explosive Ending", + description: "Survive the blast from the Unstable Dragon", + reward: 5, + }, + skyblock_flamin_hot: { name: "Flamin Hot", description: "Consume 200 Magma Creams using the Magma Bow", reward: 5 }, + skyblock_flawless: { name: "Flawless", description: "Beat a Dungeon without anyone dying", reward: 10 }, + skyblock_fortunate: { + name: "Fortunate", + description: "Fish 2 Treasures at once using the blessing enchant", + reward: 5, + }, + skyblock_friar_lawrence: { + name: "Friar Lawrence", + description: "Complete the Romero and Juliette Questline", + reward: 25, + }, + skyblock_friend_for_life: { name: "Friend for Life", description: "Level up a Pet to 100", reward: 20 }, + skyblock_frozen_monster: { name: "Frozen Monster", description: "Kill a Yeti on the Jerry Island", reward: 15 }, + skyblock_fully_evolved: { name: "Fully Evolved", description: "Obtain a legendary Pet", reward: 10 }, + skyblock_ghost_buster: { name: "Ghost Buster", description: "Kill a Ghost", reward: 5 }, + skyblock_glass_cannon: { name: "Glass Cannon", description: "Wear the Elegant Tux", reward: 15 }, + skyblock_goblin_slayer: { + name: "Goblin Slayer", + description: "Get 100 points during the Goblin Raid event", + reward: 5, + }, + skyblock_gotta_go_fast: { name: "Gotta go fast!", description: "Craft a Speed Artifact", reward: 15 }, + skyblock_gottagofast: { name: "Gottagofast", description: "Wear the full Speedster Armor", reward: 5 }, + skyblock_happy_holidays: { + name: "Happy Holidays", + description: "Collect all 20 White Gifts on the Jerry Island", + reward: 5, + }, + skyblock_happy_new_year: { name: "Happy New Year", description: "Obtain a New Year Cake from the Baker", reward: 5 }, + skyblock_heart_of_the_end: { name: "Heart of the End", description: "Reach the Dragon's Nest in the End", reward: 5 }, + skyblock_helpful_hand: { name: "Helpful Hand", description: "Give Fetchur the item he asks for", reward: 5 }, + skyblock_hidden_secrets: { name: "Hidden Secrets", description: "Find a Dark Monolith", reward: 5 }, + skyblock_higher_enchants: { name: "Higher Enchants", description: "Obtain a level 6 Enchantment Book", reward: 10 }, + skyblock_higher_than_a_rabbit: { name: "Higher Than a Rabbit", description: "Wear the Spider Boots", reward: 5 }, + skyblock_how_to_train_your_dragon: { + name: "How to train your dragon?", + description: "Find the Dragon's Lair", + reward: 15, + }, + skyblock_hsssss: { name: "Hsssss", description: "Wear the Creeper Pants", reward: 5 }, + skyblock_i_am_groot: { name: "I Am Groot", description: "Wear a set of Growth Armor with a Bonus 100 hp", reward: 5 }, + skyblock_i_am_superior: { + name: "I am Superior", + description: "Take down a Superior Dragon (Secret Achievement)", + reward: 10, + }, + skyblock_i_believe_i_can_fly: { + name: "I believe I can fly!", + description: "Wear a full set of Bat Person Armor", + reward: 5, + }, + skyblock_i_call_that_mercy: { + name: "I call that.. Mercy", + description: "Place 5 Gemstones in the Gemstone Gauntlet", + reward: 15, + }, + skyblock_i_knew_it: { + name: "I knew it!", + description: "Unlock a secret armor set (Mob Armor) (Secret Achievement)", + reward: 10, + }, + skyblock_im_fast_as_heck_boy: { + name: "I'm fast as heck boy!!", + description: "Obtain the Cheetah Talisman from Guildford", + reward: 10, + }, + skyblock_indiana_bones: { name: "Indiana Bones", description: "Find 10 secrets in a single Dungeon run", reward: 10 }, + skyblock_infinite_darkness: { + name: "Infinite Darkness", + description: "Kill a squid with the Ink Wand Ability", + reward: 5, + }, + skyblock_into_the_deep: { + name: "Into the Deep", + description: "Reach the Obsidian Sanctuary in the Deep Caverns", + reward: 5, + }, + skyblock_it_never_ends: { + name: "It Never Ends", + description: "Kill a zombie using the Zombie Sword or its upgraded versions", + reward: 5, + }, + skyblock_jerry: { name: "Jerry!!", description: "Use an Inflatable Jerry", reward: 5 }, + skyblock_king_of_the_chicks: { name: "King of the chickens", description: "Obtain the Feather Artifact", reward: 5 }, + skyblock_king_of_the_pets: { name: "King of the Pets", description: "Obtain a Pet score of 100 or more", reward: 10 }, + skyblock_king_of_the_sea: { name: "King Of The Sea", description: "Wear the Guardian Chestplate", reward: 5 }, + skyblock_knowledge_is_power: { + name: "Knowledge is Power!", + description: "Equip the Textbook item on a pet", + reward: 5, + }, + skyblock_lapidarist: { name: "Lapidartist", description: "Forge a Perfect Gemstone", reward: 15 }, + skyblock_legendary_rod: { name: "Legendary Rod", description: "Fish using the Rod of Legends", reward: 5 }, + skyblock_librarian: { name: "Librarian", description: "Complete 10 Dungeon Journals", reward: 5 }, + skyblock_lifelong_contract: { name: "Lifelong Contract", description: "Obtain the Seal of the Family", reward: 15 }, + skyblock_lost_soul: { name: "Lost Soul", description: "Find a fairy soul", reward: 5 }, + skyblock_magical_place: { name: "Magical Place", description: "Find the Fairy Grotto", reward: 10 }, + skyblock_mass_production: { name: "Mass Production", description: "Craft a level XI Minion", reward: 15 }, + skyblock_master_enchanter: { name: "Master Enchanter", description: "Enchant something using 64 levels", reward: 5 }, + skyblock_more_space: { name: "More Space", description: "Expand a minion using the Minion Expander", reward: 5 }, + skyblock_mystical: { + name: "Mystical", + description: "Use a Recombobulator 3000 to obtain a Mythic rarity", + reward: 10, + }, + skyblock_next_level: { name: "Next Level", description: "Upgrade an item to a dungeon item", reward: 10 }, + skyblock_night_eyes: { name: "Night Eyes", description: "Obtain the Night Vision Charm", reward: 5 }, + skyblock_nightmare: { + name: "Nightmare", + description: "Complete Bednom's secret quest (Secret Achievement)", + reward: 5, + }, + skyblock_no_enchants_needed: { name: "No Enchants Needed", description: "Drink a Burning Potion", reward: 5 }, + skyblock_oh_shiny: { name: "Oh Shiny", description: "Mine a Glowing Block on the End Island", reward: 5 }, + skyblock_overkill: { name: "Overkill", description: "Drink a Critical 3 Potion", reward: 5 }, + skyblock_peak_of_the_mountain: { + name: "Peak of the Mountain", + description: "Reach tier V of the Heart of the Mountain", + reward: 15, + }, + skyblock_precious_minerals: { name: "Precious Minerals", description: "Wear a full set of Emerald Armor", reward: 5 }, + skyblock_prepare_for_trouble: { name: "Prepare for trouble!", description: "Kill Corleone", reward: 10 }, + skyblock_production_expanded: { name: "Production Expanded", description: "Unlock a new Minion slot", reward: 5 }, + skyblock_promised_fulfilled: { name: "Promise Fulfilled", description: "Max out a Promising Tool", reward: 5 }, + skyblock_quest_complete: { name: "Quest complete!", description: "Complete the Villager Quest", reward: 5 }, + skyblock_rainbow: { name: "Raaaiiinnnnbbooww!", description: "Wear a full set of Fairy Armor", reward: 5 }, + skyblock_rebirth: { + name: "Rebirth", + description: "Kill a Fairy while you are a Ghost (Secret Achievement)", + reward: 5, + }, + skyblock_resourceful: { + name: "Resourceful", + description: "Give Rhys the materials to enter the Dwarven Mines", + reward: 5, + }, + skyblock_rough_deal: { name: "Rough Deal", description: "Buy something from Tomioka", reward: 5 }, + skyblock_royal_resident_dialogue: { + name: "Royal Conversation", + description: "Finish the dialogue with Royal Resident (Secret Achievement)", + reward: 15, + }, + skyblock_s_plus_squad: { name: "S+ Squad", description: "Get an S+ Score in a Dungeon", reward: 15 }, + skyblock_sacrifices_must_be_made: { + name: "Sacrifices must be made", + description: "Salvage an item for Essence", + reward: 5, + }, + skyblock_saddle_up: { name: "Saddle Up!", description: "Craft a Saddle", reward: 5 }, + skyblock_safety_first: { name: "Safety First", description: "Obtain Stonk", reward: 5 }, + skyblock_sea_monster: { name: "Sea Monsters", description: "Obtain the Sea Creature Artifact", reward: 5 }, + skyblock_second_chance: { name: "Second Chance", description: "Consume the Saving Grace", reward: 5 }, + skyblock_seriously: { + name: "Seriously?", + description: "Put a Wood Singularity on an Aspect of the Jerry", + reward: 10, + }, + skyblock_should_have_stayed_cool: { + name: "Should've stayed cool", + description: "Die from maximum  Heat while in the Magma Fields", + reward: 5, + }, + skyblock_shrimp: { name: "Shrimp!?!", description: "Obtain Shrimp the Fish (Secret Achievement)", reward: 5 }, + skyblock_sirius_business: { + name: "Sirius Buisness", + description: "Participate in the Dark Auction (Secret Achievement)", + reward: 10, + }, + skyblock_smell_like_roses: { name: "Smell like roses", description: "Take down an Endstone Protector", reward: 5 }, + skyblock_smells_better: { name: "Smells Better", description: "Wash off the King's Scent with water", reward: 5 }, + skyblock_soul_hunter: { name: "Soul Hunter", description: "Find 20 Fairy Souls", reward: 10 }, + skyblock_speedrunner: { name: "Speedrunner", description: "Beat a Dungeon Boss in under 4 minutes", reward: 10 }, + skyblock_spiky: { name: "Spiky", description: "Craft a Thorns 3 book", reward: 5 }, + skyblock_storage_forever: { name: "Storage Forever", description: "Craft a Greater Backpack", reward: 10 }, + skyblock_stubborn_giver: { name: "Stubborn Gifter", description: "Give 1,000 total gifts", reward: 10 }, + skyblock_super_fuel: { name: "Super Fuel", description: "Upgrade a minion with a Enchanted Lava Bucket", reward: 5 }, + skyblock_supreme_farmer: { name: "Supreme Farmer", description: "Wear a full set of Farm Armor", reward: 5 }, + skyblock_sweet_tooth: { name: "Sweet Tooth", description: "Find a Purple Candy", reward: 5 }, + skyblock_fallen_star_cult: { + name: "The Cult of the Fallen Star", + description: "Wear the Fallen Star Helmet to a Cult of the Fallen Star meeting (Secret Achievement)", + reward: 5, + }, + skyblock_dragons_egg: { + name: "The Dragon's Egg", + description: "Buy a Golden Dragon Egg from the dragon in the Crystal Hollows", + reward: 10, + }, + skyblock_end_race: { name: "The End Race", description: "Complete the End Race in under 42 Seconds", reward: 10 }, + skyblock_the_flash: { name: "The Flash", description: "Reach a Speed of 500%", reward: 5 }, + skyblock_the_flint_bros: { name: "The Flint Bros!", description: "Find both Pat and Rick", reward: 5 }, + skyblock_next_generation: { + name: "The Next Generation", + description: "Find a Golden Goblin by throwing a Goblin Egg", + reward: 5, + }, + skyblock_the_one_bottle: { name: "The One Bottle", description: "Craft a Titanic Experience Bottle", reward: 5 }, + skyblock_the_prodigy: { + name: "The Prodigy", + description: "Complete Through the Campfire song at any score", + reward: 10, + }, + skyblock_the_real_zoo_shady: { + name: "The Real Zoo Shady", + description: "Have 20 different Pets in your pet menu", + reward: 20, + }, + skyblock_eternal_flame_ring: { + name: "The Ring", + description: "Throw the Eternal Flame Ring into a specific pool of lava (Secret Achievement)", + reward: 10, + }, + skyblock_this_is_fair: { name: "This is fair", description: "Kill a pig using the Pigman Sword", reward: 5 }, + skyblock_three_birds_one_arrow: { + name: "Three Birds, One Arrow", + description: "Kill 3 monsters with one shot from Runaan's Bow", + reward: 5, + }, + skyblock_time_to_go_on_vacation: { + name: "Time to go on vacation", + description: "Upgrade a minion with the Super Compactor 3000", + reward: 5, + }, + skyblock_time_to_start_fishing: { name: "Time To Start Fishing", description: "Place the Pond Island", reward: 5 }, + skyblock_to_space_we_go: { + name: "To space we go!", + description: "Use a Launch Pad on your private island", + reward: 5, + }, + skyblock_though_choice: { name: "Tough Choice", description: "Apply an Ultimate Enchantment on an item", reward: 5 }, + skyblock_treasure_fishing: { name: "Treasure Fishing", description: "Fish up a Large Treasure", reward: 10 }, + skyblock_true_adventurer: { name: "True Adventurer", description: "Reach Catacombs level 40", reward: 10 }, + skyblock_true_alchemist: { name: "True Alchemist", description: "Obtain the Potion Affinity Artifact", reward: 5 }, + skyblock_united_in_blood: { name: "United in blood", description: "Obtain a Gilded Midas Sword", reward: 5 }, + skyblock_upgrades_people_upgrades: { + name: "Upgrades people, Upgrades!", + description: "Recombobulate any item", + reward: 10, + }, + skyblock_watch_me_shine: { name: "Watch Me Shine", description: "Wear The Crystal Armor Set", reward: 15 }, + skyblock_water_sword: { name: "Water Blade", description: "Kill a Squid using the Prismarine Blade", reward: 5 }, + skyblock_welcome_to_my_factory: { name: "Welcome to my Factory", description: "Place a Farm Crystal", reward: 5 }, + skyblock_bat_pinata: { name: "WHAM! POW!", description: "Kill a Bat Piñata", reward: 5 }, + skyblock_wonderful_treasures: { name: "Wonderful Treasures", description: "Open an Obsidian Chest", reward: 10 }, + skyblock_worth_it: { + name: "Worth it", + description: "Spend more than 200 levels on a single Sword Enchantment", + reward: 10, + }, + skyblock_your_adventure_begins: { + name: "Your adventure begins...", + description: "Travel to Hub from your island", + reward: 5, + }, + skyblock_your_big_break: { + name: "Your Big break", + description: "Survive an entire SkyBlock year without dying", + reward: 5, + }, + skyblock_zookeeper: { name: "Zookeeper", description: "Buy a pet from Oringo during the Traveling Zoo", reward: 10 }, +}; diff --git a/src/helper.js b/src/helper.js index 46d71e86b5..2f44e9cf85 100644 --- a/src/helper.js +++ b/src/helper.js @@ -557,6 +557,7 @@ export async function updateRank(uuid, db) { plusColor: null, socials: {}, achievements: {}, + achievementsOneTime: {}, claimed_items: {}, }; @@ -582,6 +583,10 @@ export async function updateRank(uuid, db) { rank.achievements = player.achievements; } + if (player?.achievementsOneTime != undefined) { + rank.achievementsOneTime = player.achievementsOneTime; + } + let claimable = { claimed_potato_talisman: "Potato Talisman", claimed_potato_basket: "Potato Basket", @@ -618,6 +623,7 @@ export async function getRank(uuid, db, cacheOnly = false) { let _updateRank; + _updateRank = updateRank(uuid, db); // TODO delete this line if (cacheOnly === false && (hypixelPlayer == undefined || +new Date() - hypixelPlayer.last_updated > 3600 * 1000)) { _updateRank = updateRank(uuid, db); } @@ -626,7 +632,7 @@ export async function getRank(uuid, db, cacheOnly = false) { hypixelPlayer = await _updateRank; } - hypixelPlayer ??= { achievements: {} }; + hypixelPlayer ??= { achievements: {}, achievementsOneTime: {} }; return hypixelPlayer; } diff --git a/src/lib.js b/src/lib.js index 409c40a9d2..e002481f99 100644 --- a/src/lib.js +++ b/src/lib.js @@ -2384,6 +2384,7 @@ export const getStats = async ( misc.auctions_sell = {}; misc.auctions_buy = {}; misc.claimed_items = {}; + misc.achievements = {}; if ("ender_crystals_destroyed" in userProfile.stats) { misc.dragons["ender_crystals_destroyed"] = userProfile.stats["ender_crystals_destroyed"]; @@ -2396,6 +2397,45 @@ export const getStats = async ( misc.claimed_items = hypixelProfile.claimed_items; } + let _tiered = { sum: 0, total: 0, completed: {}, uncompleted: {} }; + for (const key in constants.tieredAchievements) { + const tmp = constants.tieredAchievements[key]; + _tiered.total += tmp.tierRewards.reduce((a, b) => a + b, 0); + let tier = 0; + for (const req in tmp.tierLevelRequirements) { + if (tmp.tierLevelRequirements[req] <= hypixelProfile.achievements[key]) { + tier++; + _tiered.sum += Number(tmp.tierRewards[req]); + } + } + let achievement = { + name: tmp.name, + description: tmp.description, + level: hypixelProfile.achievements[key] || 0, + tier: tier, + }; + if (tier >= 5) { + _tiered.completed[key] = achievement; + } else { + _tiered.uncompleted[key] = achievement; + } + } + misc.achievements.tiered = _tiered; + + let _oneTime = { sum: 0, total: 0, completed: {}, uncompleted: {} }; + for (const key in constants.oneTimeAchievements) { + const tmp = constants.oneTimeAchievements[key]; + _oneTime.total += tmp.reward; + let achievement = { name: tmp.name, description: tmp.description, reward: tmp.reward }; + if (hypixelProfile.achievementsOneTime && hypixelProfile.achievementsOneTime.includes(key)) { + _oneTime.completed[key] = achievement; + _oneTime.sum += Number(tmp.reward); + } else { + _oneTime.uncompleted[key] = achievement; + } + } + misc.achievements.oneTime = _oneTime; + const burrows = [ "mythos_burrows_dug_next", "mythos_burrows_dug_combat", diff --git a/views/stats.ejs b/views/stats.ejs index ed3c5c39c9..ac9193f120 100644 --- a/views/stats.ejs +++ b/views/stats.ejs @@ -2721,6 +2721,59 @@ const metaDescription = getMetaDescription() <% } %>

<% } %> + <% if('achievements' in calculated.misc){ %> + <% let list = calculated.misc.achievements; %> +
achievements
+

+ <% if('tiered' in list){ %> + ">Tiered Achievement Points: "><%= list.tiered.sum %> / <%= list.tiered.total %> (<%= Math.floor(list.tiered.sum / list.tiered.total * 100) %>%)
+ <% } %> + <% if('oneTime' in list){ %> + ">One Time Achievement Points: "><%= list.oneTime.sum %> / <%= list.oneTime.total %> (<%= Math.floor(list.oneTime.sum / list.oneTime.total * 100) %>%)
+ <% } %> + +

+
+
Tiered
+
+ <% if('tiered' in list && 'uncompleted' in list.tiered && 'completed' in list.tiered){ %> + <% for(const key in list.tiered.uncompleted){ %> +
+
<%= list.tiered.uncompleted[key].name %> (<%= list.tiered.uncompleted[key].level %>)
+
<%= helper.renderRaceTier(list.tiered.uncompleted[key].tier) %>
+
+ <% } %> + <% for(const key in list.tiered.completed){ %> +
+
<%= list.tiered.completed[key].name %> (<%= list.tiered.completed[key].level %>)
+
<%= helper.renderRaceTier(list.tiered.completed[key].tier) %>
+
+ <% } %> + <% } %> +
+
+
+
One Time
+
+ <% if('oneTime' in list && 'uncompleted' in list.oneTime && 'completed' in list.oneTime){ %> + <% for(const key in list.oneTime.uncompleted){ %> +
+
<%= list.oneTime.uncompleted[key].name %>
+
 <%= list.oneTime.uncompleted[key].reward %>
+
+ <% } %> + <% for(const key in list.oneTime.completed){ %> +
+
<%= list.oneTime.completed[key].name %>
+
 <%= list.oneTime.completed[key].reward %>
+
+ <% } %> + <% } %> +
+
+
+

+ <% } %> <% } %> From fe05b51a711aa2d0c8f1042a52d549b66d2bd867 Mon Sep 17 00:00:00 2001 From: John Doe Date: Sun, 17 Apr 2022 01:37:38 +0200 Subject: [PATCH 2/9] deleted the chache-update-cooldown workaround --- src/helper.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/helper.js b/src/helper.js index 2f44e9cf85..0e041f5b20 100644 --- a/src/helper.js +++ b/src/helper.js @@ -623,7 +623,6 @@ export async function getRank(uuid, db, cacheOnly = false) { let _updateRank; - _updateRank = updateRank(uuid, db); // TODO delete this line if (cacheOnly === false && (hypixelPlayer == undefined || +new Date() - hypixelPlayer.last_updated > 3600 * 1000)) { _updateRank = updateRank(uuid, db); } From d2bf28628e7bd7fb3bd26c1e7ab7c86b94b06544 Mon Sep 17 00:00:00 2001 From: John Doe Date: Sun, 17 Apr 2022 02:43:30 +0200 Subject: [PATCH 3/9] fixed achievement tiers (5 instead of 4 dots) --- src/helper.js | 10 ++++++++++ views/stats.ejs | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/helper.js b/src/helper.js index 0e041f5b20..67a860cfa5 100644 --- a/src/helper.js +++ b/src/helper.js @@ -403,6 +403,16 @@ export function renderRaceTier(completeTiers) { return "●".repeat(completeTiers) + "○".repeat(incompleteTiers); } +/** + * returns a string with 5 dots "●" for completed tiers and "○" for incomplete tiers + * @param {number} completeTiers + * @returns {string} 5 dots + */ +export function renderAchievementTier(completeTiers) { + const incompleteTiers = Math.max(0, 5 - completeTiers); + return "●".repeat(completeTiers) + "○".repeat(incompleteTiers); +} + /** * checks whether a string should be proceeded by a or by an * @param {string} string diff --git a/views/stats.ejs b/views/stats.ejs index ac9193f120..2672543d62 100644 --- a/views/stats.ejs +++ b/views/stats.ejs @@ -2740,13 +2740,13 @@ const metaDescription = getMetaDescription() <% for(const key in list.tiered.uncompleted){ %>
<%= list.tiered.uncompleted[key].name %> (<%= list.tiered.uncompleted[key].level %>)
-
<%= helper.renderRaceTier(list.tiered.uncompleted[key].tier) %>
+
<%= helper.renderAchievementTier(list.tiered.uncompleted[key].tier) %>
<% } %> <% for(const key in list.tiered.completed){ %>
<%= list.tiered.completed[key].name %> (<%= list.tiered.completed[key].level %>)
-
<%= helper.renderRaceTier(list.tiered.completed[key].tier) %>
+
<%= helper.renderAchievementTier(list.tiered.completed[key].tier) %>
<% } %> <% } %> From 734be7e4d9b21c5df01d284e56ade5d002ee23c0 Mon Sep 17 00:00:00 2001 From: John Doe Date: Sun, 17 Apr 2022 17:42:24 +0200 Subject: [PATCH 4/9] changed the achievement constants to api endpoint --- src/constants/misc.js | 471 ------------------------------------------ src/lib.js | 75 ++++--- 2 files changed, 42 insertions(+), 504 deletions(-) diff --git a/src/constants/misc.js b/src/constants/misc.js index 6d873dcf40..7de70c0e59 100644 --- a/src/constants/misc.js +++ b/src/constants/misc.js @@ -360,474 +360,3 @@ export const fairy_souls = { stranded: 3, }, }; - -export const tieredAchievements = { - skyblock_angler: { - name: "Angler", - description: "Achieve Fishing levels", - tierLevelRequirements: [5, 10, 15, 20, 25], - tierRewards: [5, 5, 10, 10, 15], - }, - skyblock_augmentation: { - name: "Augmentation", - description: "Achieve Enchanting levels", - tierLevelRequirements: [5, 10, 15, 20, 25], - tierRewards: [5, 5, 10, 10, 15], - }, - skyblock_combat: { - name: "Combat!", - description: "Achieve Combat levels", - tierLevelRequirements: [5, 10, 15, 20, 25], - tierRewards: [5, 5, 10, 10, 15], - }, - skyblock_concoctor: { - name: "Concoctor", - description: "Achieve Alchemy levels", - tierLevelRequirements: [5, 10, 15, 20, 25], - tierRewards: [5, 5, 10, 10, 15], - }, - skyblock_crystal_nucleus: { - name: "Crystal Nucleus", - description: "Complete a Crystal Nucleus run by placing all 5 Crystals", - tierLevelRequirements: [5, 10, 15, 20, 25], - tierRewards: [5, 10, 15, 20, 25], - }, - skyblock_divans_treasures: { - name: "Divan's Treasures", - description: "Find treasures in the Mines of Divan", - tierLevelRequirements: [30, 60, 90, 120, 150], - tierRewards: [5, 10, 15, 20, 25], - }, - skyblock_domesticator: { - name: "Domesticator", - description: "Achieve Taming levels", - tierLevelRequirements: [5, 10, 15, 20, 25], - tierRewards: [5, 5, 10, 10, 15], - }, - skyblock_dungeoneer: { - name: "Dungeoneer", - description: "Achieve Dungeoneering levels for any single Dungeon Class", - tierLevelRequirements: [15, 20, 25, 30, 35], - tierRewards: [5, 5, 10, 10, 15], - }, - skyblock_excavator: { - name: "Excavator", - description: "Achieve Mining levels", - tierLevelRequirements: [5, 10, 15, 20, 25], - tierRewards: [5, 5, 10, 10, 15], - }, - skyblock_unique_gifts: { - name: "Festive Altruist", - description: "Give Gifts to different players", - tierLevelRequirements: [5, 10, 25, 50, 100], - tierRewards: [5, 10, 15, 20, 25], - }, - skyblock_gatherer: { - name: "Gatherer", - description: "Achieve Foraging levels", - tierLevelRequirements: [5, 10, 15, 20, 25], - tierRewards: [5, 5, 10, 10, 15], - }, - skyblock_goblin_killer: { - name: "Goblin Killer", - description: "Kill Golden Goblins", - tierLevelRequirements: [5, 10, 25, 50, 100], - tierRewards: [5, 10, 15, 20, 25], - }, - skyblock_hard_working_miner: { - name: "Hard Working Miner", - description: "Complete Commissions", - tierLevelRequirements: [5, 25, 100, 250, 500], - tierRewards: [5, 10, 15, 20, 25], - }, - skyblock_harvester: { - name: "Harvester", - description: "Achieve Farming levels", - tierLevelRequirements: [5, 10, 15, 20, 25], - tierRewards: [5, 5, 10, 10, 15], - }, - skyblock_minion_lover: { - name: "Minion Lover", - description: "[Co-op or you] Craft unique Minions", - tierLevelRequirements: [10, 25, 100, 250, 500], - tierRewards: [5, 10, 15, 20, 25], - }, - skyblock_slayer: { - name: "Slayer", - description: "Get Slayer exp", - tierLevelRequirements: [10, 50, 100, 250, 500], - tierRewards: [5, 10, 15, 20, 25], - }, - skyblock_treasure_hunter: { - name: "Treasure Hunter", - description: "Find Secrets in Dungeons", - tierLevelRequirements: [10, 50, 100, 250, 1000], - tierRewards: [5, 10, 15, 20, 25], - }, - skyblock_treasury: { - name: "Treasury", - description: "Unlock Collections", - tierLevelRequirements: [10, 20, 30, 40, 50], - tierRewards: [5, 10, 15, 20, 25], - }, -}; - -export const oneTimeAchievements = { - skyblock_a_challenging_climb: { name: "A Challenging Climb", description: "Scale the Spider's Den", reward: 5 }, - skyblock_a_good_review: { name: "A Good Review", description: "Feed Don Expresso some Tasty Mithril", reward: 5 }, - skyblock_a_good_spider_is_a_dead_spider: { - name: "A good spider is a dead spider", - description: "Kill the Broodmother", - reward: 10, - }, - skyblock_royal_meeting: { name: "A Royal Meeting", description: "Obtain the King's Talisman", reward: 5 }, - skyblock_absorb_it_all: { name: "Absorb it all!", description: "Wear a full set of Sponge Armor", reward: 10 }, - skyblock_accessories_galore: { - name: "Accessories Galore", - description: "Unlock the Greater Accessory Bag upgrade", - reward: 5, - }, - skyblock_advanced_transportation: { - name: "Advanced Transportation", - description: "Sell an item using the Enchanted Hopper", - reward: 5, - }, - skyblock_agile: { name: "Agile", description: "Drink an Agility Potion", reward: 5 }, - skyblock_animal_fishing: { name: "Animal Fishing", description: "Fish using the Farmer's Rod", reward: 5 }, - skyblock_arcadia: { name: "Arcadia", description: "Place 5 unique Islands on your private world", reward: 5 }, - skyblock_speed_of_light: { name: "At the speed of light", description: "Use a Catalyst", reward: 5 }, - skyblock_baited: { name: "Baited", description: "Obtain the Bait Ring", reward: 5 }, - skyblock_beaconator_two: { name: "Beaconator 2.0", description: "Power a Beacon of any kind", reward: 5 }, - skyblock_big_game_fisher: { - name: "Big Game Fisher", - description: "Kill a Sea Creature that requires fishing level 20 or higher", - reward: 15, - }, - skyblock_bigger_storage_is_seeded: { - name: "Bigger Storage Is Seeded", - description: "Place a Large Storage Chest", - reward: 5, - }, - skyblock_brain_power: { name: "Brain Power", description: "Drink an Adrenaline Potion", reward: 5 }, - skyblock_businessman: { name: "Businessman", description: "Complete a trade with another player", reward: 5 }, - skyblock_caretaker: { name: "Caretaker", description: "Level up a Pet to 80", reward: 10 }, - skyblock_caught_the_grinch: { - name: "Caught the Grinch", - description: "Kill a Grinch on the Jerry Island", - reward: 15, - }, - skyblock_combined_efforts: { name: "Combined efforts", description: "Start a co-op", reward: 5 }, - skyblock_cute_little_cube: { - name: "Cute Little Cube", - description: "Land the final blow on killing a Magma Cube Boss", - reward: 10, - }, - skyblock_death_from_above: { - name: "Death From Above", - description: "Kill a mob using the damage from the Leaping Sword ability", - reward: 5, - }, - skyblock_deep_storage: { name: "Deep Storage", description: "Unlock the level 3 Ender Chest Upgrade", reward: 5 }, - skyblock_defeating_death: { - name: "Defeating Death", - description: "Slay a Deathmite (Secret Achievement)", - reward: 5, - }, - skyblock_didnt_mean_to: { name: "Didn't mean to!", description: "Kill a Kalhuiki Youngling", reward: 5 }, - skyblock_do_you_even_voodoo: { - name: "Do you even Voodoo?", - description: "Kill a mob with the Voodoo Doll ability", - reward: 10, - }, - skyblock_dragon_slayer: { name: "Dragon Slayer", description: "Take down a Dragon (Secret Achievement)", reward: 5 }, - skyblock_dullahan: { name: "Dullahan", description: "Kill a Headless Horseman", reward: 5 }, - skyblock_dungeon_explorer: { - name: "Dungeon Explorer", - description: "Get a score on exploration of 95 or more in a Dungeon.", - reward: 10, - }, - skyblock_empty_flower_pot: { - name: "Empty Flower Pot", - description: - "Why is it there? Why are we all here (Hold a flower and right click the flower pot at  -307, 82, 16 in The Park for 5 minutes) (Secret Achievement)", - reward: 5, - }, - skyblock_every_little_bit_helps: { - name: "Every little bit helps", - description: "Apply a Hot Potato Book to an item", - reward: 5, - }, - skyblock_existential_revelations: { - name: "Existential Revelations", - description: "Find the mushroom dream in the Catacombs (Secret Achievement)", - reward: 5, - }, - skyblock_expensive_brew: { name: "Expensive Brew", description: "Brew a Tier VIII Potion", reward: 10 }, - skyblock_explorer: { name: "Explorer", description: "Discover all Areas on the Hub Island", reward: 5 }, - skyblock_explosive_ending: { - name: "Explosive Ending", - description: "Survive the blast from the Unstable Dragon", - reward: 5, - }, - skyblock_flamin_hot: { name: "Flamin Hot", description: "Consume 200 Magma Creams using the Magma Bow", reward: 5 }, - skyblock_flawless: { name: "Flawless", description: "Beat a Dungeon without anyone dying", reward: 10 }, - skyblock_fortunate: { - name: "Fortunate", - description: "Fish 2 Treasures at once using the blessing enchant", - reward: 5, - }, - skyblock_friar_lawrence: { - name: "Friar Lawrence", - description: "Complete the Romero and Juliette Questline", - reward: 25, - }, - skyblock_friend_for_life: { name: "Friend for Life", description: "Level up a Pet to 100", reward: 20 }, - skyblock_frozen_monster: { name: "Frozen Monster", description: "Kill a Yeti on the Jerry Island", reward: 15 }, - skyblock_fully_evolved: { name: "Fully Evolved", description: "Obtain a legendary Pet", reward: 10 }, - skyblock_ghost_buster: { name: "Ghost Buster", description: "Kill a Ghost", reward: 5 }, - skyblock_glass_cannon: { name: "Glass Cannon", description: "Wear the Elegant Tux", reward: 15 }, - skyblock_goblin_slayer: { - name: "Goblin Slayer", - description: "Get 100 points during the Goblin Raid event", - reward: 5, - }, - skyblock_gotta_go_fast: { name: "Gotta go fast!", description: "Craft a Speed Artifact", reward: 15 }, - skyblock_gottagofast: { name: "Gottagofast", description: "Wear the full Speedster Armor", reward: 5 }, - skyblock_happy_holidays: { - name: "Happy Holidays", - description: "Collect all 20 White Gifts on the Jerry Island", - reward: 5, - }, - skyblock_happy_new_year: { name: "Happy New Year", description: "Obtain a New Year Cake from the Baker", reward: 5 }, - skyblock_heart_of_the_end: { name: "Heart of the End", description: "Reach the Dragon's Nest in the End", reward: 5 }, - skyblock_helpful_hand: { name: "Helpful Hand", description: "Give Fetchur the item he asks for", reward: 5 }, - skyblock_hidden_secrets: { name: "Hidden Secrets", description: "Find a Dark Monolith", reward: 5 }, - skyblock_higher_enchants: { name: "Higher Enchants", description: "Obtain a level 6 Enchantment Book", reward: 10 }, - skyblock_higher_than_a_rabbit: { name: "Higher Than a Rabbit", description: "Wear the Spider Boots", reward: 5 }, - skyblock_how_to_train_your_dragon: { - name: "How to train your dragon?", - description: "Find the Dragon's Lair", - reward: 15, - }, - skyblock_hsssss: { name: "Hsssss", description: "Wear the Creeper Pants", reward: 5 }, - skyblock_i_am_groot: { name: "I Am Groot", description: "Wear a set of Growth Armor with a Bonus 100 hp", reward: 5 }, - skyblock_i_am_superior: { - name: "I am Superior", - description: "Take down a Superior Dragon (Secret Achievement)", - reward: 10, - }, - skyblock_i_believe_i_can_fly: { - name: "I believe I can fly!", - description: "Wear a full set of Bat Person Armor", - reward: 5, - }, - skyblock_i_call_that_mercy: { - name: "I call that.. Mercy", - description: "Place 5 Gemstones in the Gemstone Gauntlet", - reward: 15, - }, - skyblock_i_knew_it: { - name: "I knew it!", - description: "Unlock a secret armor set (Mob Armor) (Secret Achievement)", - reward: 10, - }, - skyblock_im_fast_as_heck_boy: { - name: "I'm fast as heck boy!!", - description: "Obtain the Cheetah Talisman from Guildford", - reward: 10, - }, - skyblock_indiana_bones: { name: "Indiana Bones", description: "Find 10 secrets in a single Dungeon run", reward: 10 }, - skyblock_infinite_darkness: { - name: "Infinite Darkness", - description: "Kill a squid with the Ink Wand Ability", - reward: 5, - }, - skyblock_into_the_deep: { - name: "Into the Deep", - description: "Reach the Obsidian Sanctuary in the Deep Caverns", - reward: 5, - }, - skyblock_it_never_ends: { - name: "It Never Ends", - description: "Kill a zombie using the Zombie Sword or its upgraded versions", - reward: 5, - }, - skyblock_jerry: { name: "Jerry!!", description: "Use an Inflatable Jerry", reward: 5 }, - skyblock_king_of_the_chicks: { name: "King of the chickens", description: "Obtain the Feather Artifact", reward: 5 }, - skyblock_king_of_the_pets: { name: "King of the Pets", description: "Obtain a Pet score of 100 or more", reward: 10 }, - skyblock_king_of_the_sea: { name: "King Of The Sea", description: "Wear the Guardian Chestplate", reward: 5 }, - skyblock_knowledge_is_power: { - name: "Knowledge is Power!", - description: "Equip the Textbook item on a pet", - reward: 5, - }, - skyblock_lapidarist: { name: "Lapidartist", description: "Forge a Perfect Gemstone", reward: 15 }, - skyblock_legendary_rod: { name: "Legendary Rod", description: "Fish using the Rod of Legends", reward: 5 }, - skyblock_librarian: { name: "Librarian", description: "Complete 10 Dungeon Journals", reward: 5 }, - skyblock_lifelong_contract: { name: "Lifelong Contract", description: "Obtain the Seal of the Family", reward: 15 }, - skyblock_lost_soul: { name: "Lost Soul", description: "Find a fairy soul", reward: 5 }, - skyblock_magical_place: { name: "Magical Place", description: "Find the Fairy Grotto", reward: 10 }, - skyblock_mass_production: { name: "Mass Production", description: "Craft a level XI Minion", reward: 15 }, - skyblock_master_enchanter: { name: "Master Enchanter", description: "Enchant something using 64 levels", reward: 5 }, - skyblock_more_space: { name: "More Space", description: "Expand a minion using the Minion Expander", reward: 5 }, - skyblock_mystical: { - name: "Mystical", - description: "Use a Recombobulator 3000 to obtain a Mythic rarity", - reward: 10, - }, - skyblock_next_level: { name: "Next Level", description: "Upgrade an item to a dungeon item", reward: 10 }, - skyblock_night_eyes: { name: "Night Eyes", description: "Obtain the Night Vision Charm", reward: 5 }, - skyblock_nightmare: { - name: "Nightmare", - description: "Complete Bednom's secret quest (Secret Achievement)", - reward: 5, - }, - skyblock_no_enchants_needed: { name: "No Enchants Needed", description: "Drink a Burning Potion", reward: 5 }, - skyblock_oh_shiny: { name: "Oh Shiny", description: "Mine a Glowing Block on the End Island", reward: 5 }, - skyblock_overkill: { name: "Overkill", description: "Drink a Critical 3 Potion", reward: 5 }, - skyblock_peak_of_the_mountain: { - name: "Peak of the Mountain", - description: "Reach tier V of the Heart of the Mountain", - reward: 15, - }, - skyblock_precious_minerals: { name: "Precious Minerals", description: "Wear a full set of Emerald Armor", reward: 5 }, - skyblock_prepare_for_trouble: { name: "Prepare for trouble!", description: "Kill Corleone", reward: 10 }, - skyblock_production_expanded: { name: "Production Expanded", description: "Unlock a new Minion slot", reward: 5 }, - skyblock_promised_fulfilled: { name: "Promise Fulfilled", description: "Max out a Promising Tool", reward: 5 }, - skyblock_quest_complete: { name: "Quest complete!", description: "Complete the Villager Quest", reward: 5 }, - skyblock_rainbow: { name: "Raaaiiinnnnbbooww!", description: "Wear a full set of Fairy Armor", reward: 5 }, - skyblock_rebirth: { - name: "Rebirth", - description: "Kill a Fairy while you are a Ghost (Secret Achievement)", - reward: 5, - }, - skyblock_resourceful: { - name: "Resourceful", - description: "Give Rhys the materials to enter the Dwarven Mines", - reward: 5, - }, - skyblock_rough_deal: { name: "Rough Deal", description: "Buy something from Tomioka", reward: 5 }, - skyblock_royal_resident_dialogue: { - name: "Royal Conversation", - description: "Finish the dialogue with Royal Resident (Secret Achievement)", - reward: 15, - }, - skyblock_s_plus_squad: { name: "S+ Squad", description: "Get an S+ Score in a Dungeon", reward: 15 }, - skyblock_sacrifices_must_be_made: { - name: "Sacrifices must be made", - description: "Salvage an item for Essence", - reward: 5, - }, - skyblock_saddle_up: { name: "Saddle Up!", description: "Craft a Saddle", reward: 5 }, - skyblock_safety_first: { name: "Safety First", description: "Obtain Stonk", reward: 5 }, - skyblock_sea_monster: { name: "Sea Monsters", description: "Obtain the Sea Creature Artifact", reward: 5 }, - skyblock_second_chance: { name: "Second Chance", description: "Consume the Saving Grace", reward: 5 }, - skyblock_seriously: { - name: "Seriously?", - description: "Put a Wood Singularity on an Aspect of the Jerry", - reward: 10, - }, - skyblock_should_have_stayed_cool: { - name: "Should've stayed cool", - description: "Die from maximum  Heat while in the Magma Fields", - reward: 5, - }, - skyblock_shrimp: { name: "Shrimp!?!", description: "Obtain Shrimp the Fish (Secret Achievement)", reward: 5 }, - skyblock_sirius_business: { - name: "Sirius Buisness", - description: "Participate in the Dark Auction (Secret Achievement)", - reward: 10, - }, - skyblock_smell_like_roses: { name: "Smell like roses", description: "Take down an Endstone Protector", reward: 5 }, - skyblock_smells_better: { name: "Smells Better", description: "Wash off the King's Scent with water", reward: 5 }, - skyblock_soul_hunter: { name: "Soul Hunter", description: "Find 20 Fairy Souls", reward: 10 }, - skyblock_speedrunner: { name: "Speedrunner", description: "Beat a Dungeon Boss in under 4 minutes", reward: 10 }, - skyblock_spiky: { name: "Spiky", description: "Craft a Thorns 3 book", reward: 5 }, - skyblock_storage_forever: { name: "Storage Forever", description: "Craft a Greater Backpack", reward: 10 }, - skyblock_stubborn_giver: { name: "Stubborn Gifter", description: "Give 1,000 total gifts", reward: 10 }, - skyblock_super_fuel: { name: "Super Fuel", description: "Upgrade a minion with a Enchanted Lava Bucket", reward: 5 }, - skyblock_supreme_farmer: { name: "Supreme Farmer", description: "Wear a full set of Farm Armor", reward: 5 }, - skyblock_sweet_tooth: { name: "Sweet Tooth", description: "Find a Purple Candy", reward: 5 }, - skyblock_fallen_star_cult: { - name: "The Cult of the Fallen Star", - description: "Wear the Fallen Star Helmet to a Cult of the Fallen Star meeting (Secret Achievement)", - reward: 5, - }, - skyblock_dragons_egg: { - name: "The Dragon's Egg", - description: "Buy a Golden Dragon Egg from the dragon in the Crystal Hollows", - reward: 10, - }, - skyblock_end_race: { name: "The End Race", description: "Complete the End Race in under 42 Seconds", reward: 10 }, - skyblock_the_flash: { name: "The Flash", description: "Reach a Speed of 500%", reward: 5 }, - skyblock_the_flint_bros: { name: "The Flint Bros!", description: "Find both Pat and Rick", reward: 5 }, - skyblock_next_generation: { - name: "The Next Generation", - description: "Find a Golden Goblin by throwing a Goblin Egg", - reward: 5, - }, - skyblock_the_one_bottle: { name: "The One Bottle", description: "Craft a Titanic Experience Bottle", reward: 5 }, - skyblock_the_prodigy: { - name: "The Prodigy", - description: "Complete Through the Campfire song at any score", - reward: 10, - }, - skyblock_the_real_zoo_shady: { - name: "The Real Zoo Shady", - description: "Have 20 different Pets in your pet menu", - reward: 20, - }, - skyblock_eternal_flame_ring: { - name: "The Ring", - description: "Throw the Eternal Flame Ring into a specific pool of lava (Secret Achievement)", - reward: 10, - }, - skyblock_this_is_fair: { name: "This is fair", description: "Kill a pig using the Pigman Sword", reward: 5 }, - skyblock_three_birds_one_arrow: { - name: "Three Birds, One Arrow", - description: "Kill 3 monsters with one shot from Runaan's Bow", - reward: 5, - }, - skyblock_time_to_go_on_vacation: { - name: "Time to go on vacation", - description: "Upgrade a minion with the Super Compactor 3000", - reward: 5, - }, - skyblock_time_to_start_fishing: { name: "Time To Start Fishing", description: "Place the Pond Island", reward: 5 }, - skyblock_to_space_we_go: { - name: "To space we go!", - description: "Use a Launch Pad on your private island", - reward: 5, - }, - skyblock_though_choice: { name: "Tough Choice", description: "Apply an Ultimate Enchantment on an item", reward: 5 }, - skyblock_treasure_fishing: { name: "Treasure Fishing", description: "Fish up a Large Treasure", reward: 10 }, - skyblock_true_adventurer: { name: "True Adventurer", description: "Reach Catacombs level 40", reward: 10 }, - skyblock_true_alchemist: { name: "True Alchemist", description: "Obtain the Potion Affinity Artifact", reward: 5 }, - skyblock_united_in_blood: { name: "United in blood", description: "Obtain a Gilded Midas Sword", reward: 5 }, - skyblock_upgrades_people_upgrades: { - name: "Upgrades people, Upgrades!", - description: "Recombobulate any item", - reward: 10, - }, - skyblock_watch_me_shine: { name: "Watch Me Shine", description: "Wear The Crystal Armor Set", reward: 15 }, - skyblock_water_sword: { name: "Water Blade", description: "Kill a Squid using the Prismarine Blade", reward: 5 }, - skyblock_welcome_to_my_factory: { name: "Welcome to my Factory", description: "Place a Farm Crystal", reward: 5 }, - skyblock_bat_pinata: { name: "WHAM! POW!", description: "Kill a Bat Piñata", reward: 5 }, - skyblock_wonderful_treasures: { name: "Wonderful Treasures", description: "Open an Obsidian Chest", reward: 10 }, - skyblock_worth_it: { - name: "Worth it", - description: "Spend more than 200 levels on a single Sword Enchantment", - reward: 10, - }, - skyblock_your_adventure_begins: { - name: "Your adventure begins...", - description: "Travel to Hub from your island", - reward: 5, - }, - skyblock_your_big_break: { - name: "Your Big break", - description: "Survive an entire SkyBlock year without dying", - reward: 5, - }, - skyblock_zookeeper: { name: "Zookeeper", description: "Buy a pet from Oringo during the Traveling Zoo", reward: 10 }, -}; diff --git a/src/lib.js b/src/lib.js index e002481f99..a4d33f9713 100644 --- a/src/lib.js +++ b/src/lib.js @@ -2397,43 +2397,52 @@ export const getStats = async ( misc.claimed_items = hypixelProfile.claimed_items; } + const response = await axios("https://api.hypixel.net/resources/achievements"); let _tiered = { sum: 0, total: 0, completed: {}, uncompleted: {} }; - for (const key in constants.tieredAchievements) { - const tmp = constants.tieredAchievements[key]; - _tiered.total += tmp.tierRewards.reduce((a, b) => a + b, 0); - let tier = 0; - for (const req in tmp.tierLevelRequirements) { - if (tmp.tierLevelRequirements[req] <= hypixelProfile.achievements[key]) { - tier++; - _tiered.sum += Number(tmp.tierRewards[req]); - } - } - let achievement = { - name: tmp.name, - description: tmp.description, - level: hypixelProfile.achievements[key] || 0, - tier: tier, - }; - if (tier >= 5) { - _tiered.completed[key] = achievement; - } else { - _tiered.uncompleted[key] = achievement; - } - } - misc.achievements.tiered = _tiered; - let _oneTime = { sum: 0, total: 0, completed: {}, uncompleted: {} }; - for (const key in constants.oneTimeAchievements) { - const tmp = constants.oneTimeAchievements[key]; - _oneTime.total += tmp.reward; - let achievement = { name: tmp.name, description: tmp.description, reward: tmp.reward }; - if (hypixelProfile.achievementsOneTime && hypixelProfile.achievementsOneTime.includes(key)) { - _oneTime.completed[key] = achievement; - _oneTime.sum += Number(tmp.reward); - } else { - _oneTime.uncompleted[key] = achievement; + if (response?.data?.achievements?.skyblock) { + let skyblock_achievements = response.data.achievements.skyblock; + let tieredAchievements = skyblock_achievements.tiered; + let oneTimeAchievements = skyblock_achievements.one_time; + + for (const key in tieredAchievements) { + const tmp = tieredAchievements[key]; + _tiered.total += tmp.tiers.reduce((a, b) => a.points + b.points, 0); + let tier = 0; + for (const req in tmp.tiers) { + if (tmp.tiers[req].amount <= hypixelProfile.achievements["skyblock_" + key.toLowerCase()]) { + tier++; + _tiered.sum += Number(tmp.tiers[req].points); + } + } + let achievement = { + name: tmp.name, + description: tmp.description.replaceAll("%s", "x"), + level: hypixelProfile.achievements["skyblock_" + key.toLowerCase()] || 0, + tier: tier, + }; + if (tier >= 5) { + _tiered.completed["skyblock_" + key.toLowerCase()] = achievement; + } else { + _tiered.uncompleted["skyblock_" + key.toLowerCase()] = achievement; + } + } + for (const key in oneTimeAchievements) { + const tmp = oneTimeAchievements[key]; + _oneTime.total += tmp.points; + let achievement = { name: tmp.name, description: tmp.description, reward: tmp.points }; + if ( + hypixelProfile.achievementsOneTime && + hypixelProfile.achievementsOneTime.includes("skyblock_" + key.toLowerCase()) + ) { + _oneTime.completed["skyblock_" + key.toLowerCase()] = achievement; + _oneTime.sum += Number(tmp.points); + } else { + _oneTime.uncompleted["skyblock_" + key.toLowerCase()] = achievement; + } } } + misc.achievements.tiered = _tiered; misc.achievements.oneTime = _oneTime; const burrows = [ From 2291db06fd12c6347e0d160c8bce47da3e7a5e8a Mon Sep 17 00:00:00 2001 From: John Doe Date: Sun, 17 Apr 2022 19:42:58 +0200 Subject: [PATCH 5/9] fixed bug with tiered points total --- src/lib.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.js b/src/lib.js index a4d33f9713..a53cff62c1 100644 --- a/src/lib.js +++ b/src/lib.js @@ -2407,7 +2407,7 @@ export const getStats = async ( for (const key in tieredAchievements) { const tmp = tieredAchievements[key]; - _tiered.total += tmp.tiers.reduce((a, b) => a.points + b.points, 0); + _tiered.total += tmp.tiers.map((a) => a.points).reduce((a, b) => a + b, 0); let tier = 0; for (const req in tmp.tiers) { if (tmp.tiers[req].amount <= hypixelProfile.achievements["skyblock_" + key.toLowerCase()]) { From 6da7c43bdea9546c820f7f88d830094b607422ab Mon Sep 17 00:00:00 2001 From: John Doe Date: Mon, 18 Apr 2022 00:41:45 +0200 Subject: [PATCH 6/9] changed the icon to a book --- views/stats.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/stats.ejs b/views/stats.ejs index 2672543d62..70a72ee1a1 100644 --- a/views/stats.ejs +++ b/views/stats.ejs @@ -2723,7 +2723,7 @@ const metaDescription = getMetaDescription() <% } %> <% if('achievements' in calculated.misc){ %> <% let list = calculated.misc.achievements; %> -
achievements
+
achievements

<% if('tiered' in list){ %> ">Tiered Achievement Points: "><%= list.tiered.sum %> / <%= list.tiered.total %> (<%= Math.floor(list.tiered.sum / list.tiered.total * 100) %>%)
From 197cf1de25787ee0392fc7b7ac875793f7952077 Mon Sep 17 00:00:00 2001 From: MartinNemi03 Date: Sat, 23 Apr 2022 23:25:06 +0200 Subject: [PATCH 7/9] Added achievements collection to mongo --- src/lib.js | 53 +++++++++++++++--------------- src/master.js | 1 + src/scripts/init-collections.js | 2 ++ src/scripts/update-achievements.js | 42 +++++++++++++++++++++++ 4 files changed, 72 insertions(+), 26 deletions(-) create mode 100644 src/scripts/update-achievements.js diff --git a/src/lib.js b/src/lib.js index 025c4791f9..65820786cd 100644 --- a/src/lib.js +++ b/src/lib.js @@ -2401,51 +2401,52 @@ export const getStats = async ( misc.claimed_items = hypixelProfile.claimed_items; } - const response = await axios("https://api.hypixel.net/resources/achievements"); let _tiered = { sum: 0, total: 0, completed: {}, uncompleted: {} }; let _oneTime = { sum: 0, total: 0, completed: {}, uncompleted: {} }; - if (response?.data?.achievements?.skyblock) { - let skyblock_achievements = response.data.achievements.skyblock; - let tieredAchievements = skyblock_achievements.tiered; - let oneTimeAchievements = skyblock_achievements.one_time; - - for (const key in tieredAchievements) { - const tmp = tieredAchievements[key]; - _tiered.total += tmp.tiers.map((a) => a.points).reduce((a, b) => a + b, 0); + for await (const tmp of db.collection("achievements").find()) { + if (tmp?.tiered) { + _tiered.total += tmp.achievement.tiers.map((a) => a.points).reduce((a, b) => a + b, 0); + let tier = 0; - for (const req in tmp.tiers) { - if (tmp.tiers[req].amount <= hypixelProfile.achievements["skyblock_" + key.toLowerCase()]) { + for (const req in tmp.achievement.tiers) { + if (tmp.achievement.tiers[req].amount <= hypixelProfile.achievements["skyblock_" + tmp.id.toLowerCase()]) { tier++; - _tiered.sum += Number(tmp.tiers[req].points); + _tiered.sum += Number(tmp.achievement.tiers[req].points); } } + let achievement = { - name: tmp.name, - description: tmp.description.replaceAll("%s", "x"), - level: hypixelProfile.achievements["skyblock_" + key.toLowerCase()] || 0, + name: tmp.achievement.name, + description: tmp.achievement.description.replaceAll("%s", "x"), + level: hypixelProfile.achievements["skyblock_" + tmp.id.toLowerCase()] || 0, tier: tier, }; + if (tier >= 5) { - _tiered.completed["skyblock_" + key.toLowerCase()] = achievement; + _tiered.completed["skyblock_" + tmp.id.toLowerCase()] = achievement; } else { - _tiered.uncompleted["skyblock_" + key.toLowerCase()] = achievement; + _tiered.uncompleted["skyblock_" + tmp.id.toLowerCase()] = achievement; } - } - for (const key in oneTimeAchievements) { - const tmp = oneTimeAchievements[key]; - _oneTime.total += tmp.points; - let achievement = { name: tmp.name, description: tmp.description, reward: tmp.points }; + } else if (tmp?.one_time) { + _oneTime.total += tmp.achievement.points; + let achievement = { + name: tmp.achievement.name, + description: tmp.achievement.description, + reward: tmp.achievement.points, + }; + if ( hypixelProfile.achievementsOneTime && - hypixelProfile.achievementsOneTime.includes("skyblock_" + key.toLowerCase()) + hypixelProfile.achievementsOneTime.includes("skyblock_" + tmp.id.toLowerCase()) ) { - _oneTime.completed["skyblock_" + key.toLowerCase()] = achievement; - _oneTime.sum += Number(tmp.points); + _oneTime.completed["skyblock_" + tmp.id.toLowerCase()] = achievement; + _oneTime.sum += Number(tmp.achievement.points); } else { - _oneTime.uncompleted["skyblock_" + key.toLowerCase()] = achievement; + _oneTime.uncompleted["skyblock_" + tmp.id.toLowerCase()] = achievement; } } } + misc.achievements.tiered = _tiered; misc.achievements.oneTime = _oneTime; diff --git a/src/master.js b/src/master.js index d6bdbcb276..47d3ca9ff8 100644 --- a/src/master.js +++ b/src/master.js @@ -4,6 +4,7 @@ await import("./scripts/init-collections.js"); await Promise.all([ import("./scripts/cap-leaderboards.js"), import("./scripts/clear-favorite-cache.js"), + import("./scripts/update-achievements.js"), import("./scripts/update-bazaar.js"), import("./scripts/update-items.js"), import("./scripts/update-featured-profiles.js"), diff --git a/src/scripts/init-collections.js b/src/scripts/init-collections.js index df4c076cf5..e91e2f23e5 100644 --- a/src/scripts/init-collections.js +++ b/src/scripts/init-collections.js @@ -37,4 +37,6 @@ await Promise.all([ db.collection("profileCache").createIndex({ profile_id: 1 }, { unique: true }), db.collection("featuredProfiles").createIndex({ total: -1 }), + + db.collection("achievements").createIndex({ id: 1 }, { unique: true }), ]); diff --git a/src/scripts/update-achievements.js b/src/scripts/update-achievements.js new file mode 100644 index 0000000000..b66fa81274 --- /dev/null +++ b/src/scripts/update-achievements.js @@ -0,0 +1,42 @@ +import { db } from "../mongo.js"; +import axios from "axios"; +import "axios-debug-log"; + +const Hypixel = axios.create({ + baseURL: "https://api.hypixel.net/", +}); + +async function updateAchievements() { + try { + const response = await Hypixel.get("resources/achievements" /*, { params: { key: credentials.hypixel_api_key }}*/); + + const achievements = []; + const { one_time, tiered } = response.data.achievements.skyblock; + + for (const achId in one_time) { + achievements.push({ + id: achId, + one_time: true, + achievement: one_time[achId], + }); + } + + for (const achId in tiered) { + achievements.push({ + id: achId, + tiered: true, + achievement: tiered[achId], + }); + } + + achievements.forEach(async (item) => { + await db.collection("achievements").updateOne({ id: item.id }, { $set: item }, { upsert: true }); + }); + } catch (e) { + console.error(e); + } + + setTimeout(updateAchievements, 1000 * 60 * 60 * 6); +} + +updateAchievements(); From 3f81b048af34e2f49a4e5e947c79b9525b7d6213 Mon Sep 17 00:00:00 2001 From: dukio Date: Sun, 24 Apr 2022 13:50:07 +0200 Subject: [PATCH 8/9] minor fixes --- src/lib.js | 12 +++++++----- src/scripts/update-achievements.js | 2 +- views/stats.ejs | 22 +++++++++++----------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/lib.js b/src/lib.js index 65820786cd..a81a08b391 100644 --- a/src/lib.js +++ b/src/lib.js @@ -2401,8 +2401,8 @@ export const getStats = async ( misc.claimed_items = hypixelProfile.claimed_items; } - let _tiered = { sum: 0, total: 0, completed: {}, uncompleted: {} }; - let _oneTime = { sum: 0, total: 0, completed: {}, uncompleted: {} }; + const _tiered = { sum: 0, total: 0, completed: {}, uncompleted: {} }; + const _oneTime = { sum: 0, total: 0, completed: {}, uncompleted: {} }; for await (const tmp of db.collection("achievements").find()) { if (tmp?.tiered) { _tiered.total += tmp.achievement.tiers.map((a) => a.points).reduce((a, b) => a + b, 0); @@ -2415,7 +2415,7 @@ export const getStats = async ( } } - let achievement = { + const achievement = { name: tmp.achievement.name, description: tmp.achievement.description.replaceAll("%s", "x"), level: hypixelProfile.achievements["skyblock_" + tmp.id.toLowerCase()] || 0, @@ -2427,9 +2427,11 @@ export const getStats = async ( } else { _tiered.uncompleted["skyblock_" + tmp.id.toLowerCase()] = achievement; } - } else if (tmp?.one_time) { + } + + if (tmp?.one_time) { _oneTime.total += tmp.achievement.points; - let achievement = { + const achievement = { name: tmp.achievement.name, description: tmp.achievement.description, reward: tmp.achievement.points, diff --git a/src/scripts/update-achievements.js b/src/scripts/update-achievements.js index b66fa81274..d907f82c5a 100644 --- a/src/scripts/update-achievements.js +++ b/src/scripts/update-achievements.js @@ -8,7 +8,7 @@ const Hypixel = axios.create({ async function updateAchievements() { try { - const response = await Hypixel.get("resources/achievements" /*, { params: { key: credentials.hypixel_api_key }}*/); + const response = await Hypixel.get("resources/achievements"); const achievements = []; const { one_time, tiered } = response.data.achievements.skyblock; diff --git a/views/stats.ejs b/views/stats.ejs index 9558fdd0dd..8db9a47195 100644 --- a/views/stats.ejs +++ b/views/stats.ejs @@ -2503,16 +2503,17 @@ const metaDescription = getMetaDescription() <% } %>

<% } %> - <% if('achievements' in calculated.misc){ %> - <% let list = calculated.misc.achievements; %> -
achievements
-

- <% if('tiered' in list){ %> - ">Tiered Achievement Points: "><%= list.tiered.sum %> / <%= list.tiered.total %> (<%= Math.floor(list.tiered.sum / list.tiered.total * 100) %>%)
- <% } %> - <% if('oneTime' in list){ %> - ">One Time Achievement Points: "><%= list.oneTime.sum %> / <%= list.oneTime.total %> (<%= Math.floor(list.oneTime.sum / list.oneTime.total * 100) %>%)
- <% } %> + <% if ('achievements' in calculated.misc) { %> + <% const list = calculated.misc.achievements; %> +

achievements
+

+ <% if('tiered' in list){ %> + ">Tiered AP: "><%= list.tiered.sum %> / <%= list.tiered.total %> (<%= Math.floor(list.tiered.sum / list.tiered.total * 100) %>%)
+ <% } %> + <% if('oneTime' in list){ %> + ">One Time AP: "><%= list.oneTime.sum %> / <%= list.oneTime.total %> (<%= Math.floor(list.oneTime.sum / list.oneTime.total * 100) %>%)
+ <% } %> +

@@ -2554,7 +2555,6 @@ const metaDescription = getMetaDescription()
-

<% } %> From ddfc00b175851bba8fae6fc1d3a8e2b085c163fc Mon Sep 17 00:00:00 2001 From: John Doe Date: Mon, 1 Aug 2022 17:45:02 +0200 Subject: [PATCH 9/9] corrected a missing bracket error from the merge --- src/helper.js | 2 +- views/stats.ejs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/helper.js b/src/helper.js index 3f2401c1d6..dcebb68858 100644 --- a/src/helper.js +++ b/src/helper.js @@ -572,7 +572,7 @@ export async function updateRank(uuid, db) { if (player?.achievementsOneTime != undefined) { rank.achievementsOneTime = player.achievementsOneTime; } - + const claimable = { claimed_potato_talisman: "Potato Talisman", claimed_potato_basket: "Potato Basket", diff --git a/views/stats.ejs b/views/stats.ejs index bd03d80aeb..440c42fde4 100644 --- a/views/stats.ejs +++ b/views/stats.ejs @@ -2539,6 +2539,7 @@ const metaDescription = getMetaDescription() + <% } %> <% } %>