From 8882ccd9787ac82374c24c91790a70679a436dc5 Mon Sep 17 00:00:00 2001 From: Nathan S Date: Wed, 7 Feb 2024 23:14:07 +0000 Subject: [PATCH 1/6] Add plugin to track enhancing This plugin will track enhancing activities while the player is online. It will track their successes, failures, consumed items, and highest level hit. It will reset when the item being enhanced changes, or if the player stops enhancing and then returns to a previous item. It won't reset otherwise. --- src/MooLite/core/MooLite.ts | 5 +- src/MooLite/core/actions/ActionHrid.ts | 520 +++++++++++++++++- .../core/inventory/items/decodeItemHash.ts | 29 + .../clientmessages/ClientMessageType.ts | 2 +- .../EnhancingTrackerPlugin.ts | 141 +++++ .../EnhancingTrackerPluginDisplay.vue | 55 ++ src/components/atoms/ItemIcon.vue | 2 +- src/main.ts | 2 + 8 files changed, 751 insertions(+), 5 deletions(-) create mode 100644 src/MooLite/core/inventory/items/decodeItemHash.ts create mode 100644 src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPlugin.ts create mode 100644 src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPluginDisplay.vue diff --git a/src/MooLite/core/MooLite.ts b/src/MooLite/core/MooLite.ts index e88045c..b4b53d6 100644 --- a/src/MooLite/core/MooLite.ts +++ b/src/MooLite/core/MooLite.ts @@ -22,6 +22,7 @@ import { EquipmentBuffsUpdatedParser } from "src/MooLite/core/server/messages/Eq import { ItemsUpdatedParser } from "src/MooLite/core/server/messages/ItemsUpdated"; import { LootOpenedParser } from "src/MooLite/core/server/messages/LootOpened"; import { AbilitiesUpdatedParser } from "src/MooLite/core/server/messages/AbilitiesUpdated"; +import { InitClientInfoParser } from "./server/messages/InitClientInfo"; export class MooLite { pluginManager: PluginManager; @@ -32,6 +33,7 @@ export class MooLite { messageParsers: MessageParser[] = [ // Server messages new InitCharacterInfoParser(), + new InitClientInfoParser(), new PongParser(), new ActionCompletedParser(), @@ -161,8 +163,7 @@ export class MooLite { }); if (!parser) { if (!isClientMessage) { - console.warn(`Unhandled message type ${message.type}`); - console.log(message); + console.warn(`Unhandled message type ${message.type}`, message); } return; } diff --git a/src/MooLite/core/actions/ActionHrid.ts b/src/MooLite/core/actions/ActionHrid.ts index 62ddf08..99f9f38 100644 --- a/src/MooLite/core/actions/ActionHrid.ts +++ b/src/MooLite/core/actions/ActionHrid.ts @@ -1 +1,519 @@ -export enum ActionHrid {} +/** + * ActionHrids pulled from init data - last updated 2024-08-02 + * + * While these are available from init data, we can't use init data for typing. + * Having a copy here lets us type things correctly and search against the + * ActionMap. Entries are sorted alphabetically in ascending order. + */ +export type ActionHrid = + | "/actions/brewing/artisan_tea" + | "/actions/brewing/attack_coffee" + | "/actions/brewing/blessed_tea" + | "/actions/brewing/brewing_tea" + | "/actions/brewing/channeling_coffee" + | "/actions/brewing/cheesesmithing_tea" + | "/actions/brewing/cooking_tea" + | "/actions/brewing/crafting_tea" + | "/actions/brewing/critical_coffee" + | "/actions/brewing/defense_coffee" + | "/actions/brewing/efficiency_tea" + | "/actions/brewing/enhancing_tea" + | "/actions/brewing/foraging_tea" + | "/actions/brewing/gathering_tea" + | "/actions/brewing/gourmet_tea" + | "/actions/brewing/intelligence_coffee" + | "/actions/brewing/lucky_coffee" + | "/actions/brewing/magic_coffee" + | "/actions/brewing/milking_tea" + | "/actions/brewing/power_coffee" + | "/actions/brewing/processing_tea" + | "/actions/brewing/ranged_coffee" + | "/actions/brewing/stamina_coffee" + | "/actions/brewing/super_attack_coffee" + | "/actions/brewing/super_brewing_tea" + | "/actions/brewing/super_cheesesmithing_tea" + | "/actions/brewing/super_cooking_tea" + | "/actions/brewing/super_crafting_tea" + | "/actions/brewing/super_defense_coffee" + | "/actions/brewing/super_enhancing_tea" + | "/actions/brewing/super_foraging_tea" + | "/actions/brewing/super_intelligence_coffee" + | "/actions/brewing/super_magic_coffee" + | "/actions/brewing/super_milking_tea" + | "/actions/brewing/super_power_coffee" + | "/actions/brewing/super_ranged_coffee" + | "/actions/brewing/super_stamina_coffee" + | "/actions/brewing/super_tailoring_tea" + | "/actions/brewing/super_woodcutting_tea" + | "/actions/brewing/swiftness_coffee" + | "/actions/brewing/tailoring_tea" + | "/actions/brewing/wisdom_coffee" + | "/actions/brewing/wisdom_tea" + | "/actions/brewing/woodcutting_tea" + | "/actions/cheesesmithing/azure_boots" + | "/actions/cheesesmithing/azure_brush" + | "/actions/cheesesmithing/azure_buckler" + | "/actions/cheesesmithing/azure_bulwark" + | "/actions/cheesesmithing/azure_cheese" + | "/actions/cheesesmithing/azure_chisel" + | "/actions/cheesesmithing/azure_enhancer" + | "/actions/cheesesmithing/azure_gauntlets" + | "/actions/cheesesmithing/azure_hammer" + | "/actions/cheesesmithing/azure_hatchet" + | "/actions/cheesesmithing/azure_helmet" + | "/actions/cheesesmithing/azure_mace" + | "/actions/cheesesmithing/azure_needle" + | "/actions/cheesesmithing/azure_plate_body" + | "/actions/cheesesmithing/azure_plate_legs" + | "/actions/cheesesmithing/azure_pot" + | "/actions/cheesesmithing/azure_shears" + | "/actions/cheesesmithing/azure_spatula" + | "/actions/cheesesmithing/azure_spear" + | "/actions/cheesesmithing/azure_sword" + | "/actions/cheesesmithing/black_bear_shoes" + | "/actions/cheesesmithing/burble_boots" + | "/actions/cheesesmithing/burble_brush" + | "/actions/cheesesmithing/burble_buckler" + | "/actions/cheesesmithing/burble_bulwark" + | "/actions/cheesesmithing/burble_cheese" + | "/actions/cheesesmithing/burble_chisel" + | "/actions/cheesesmithing/burble_enhancer" + | "/actions/cheesesmithing/burble_gauntlets" + | "/actions/cheesesmithing/burble_hammer" + | "/actions/cheesesmithing/burble_hatchet" + | "/actions/cheesesmithing/burble_helmet" + | "/actions/cheesesmithing/burble_mace" + | "/actions/cheesesmithing/burble_needle" + | "/actions/cheesesmithing/burble_plate_body" + | "/actions/cheesesmithing/burble_plate_legs" + | "/actions/cheesesmithing/burble_pot" + | "/actions/cheesesmithing/burble_shears" + | "/actions/cheesesmithing/burble_spatula" + | "/actions/cheesesmithing/burble_spear" + | "/actions/cheesesmithing/burble_sword" + | "/actions/cheesesmithing/cheese_boots" + | "/actions/cheesesmithing/cheese_brush" + | "/actions/cheesesmithing/cheese_buckler" + | "/actions/cheesesmithing/cheese_bulwark" + | "/actions/cheesesmithing/cheese_chisel" + | "/actions/cheesesmithing/cheese_enhancer" + | "/actions/cheesesmithing/cheese_gauntlets" + | "/actions/cheesesmithing/cheese_hammer" + | "/actions/cheesesmithing/cheese_hatchet" + | "/actions/cheesesmithing/cheese_helmet" + | "/actions/cheesesmithing/cheese_mace" + | "/actions/cheesesmithing/cheese_needle" + | "/actions/cheesesmithing/cheese_plate_body" + | "/actions/cheesesmithing/cheese_plate_legs" + | "/actions/cheesesmithing/cheese_pot" + | "/actions/cheesesmithing/cheese_shears" + | "/actions/cheesesmithing/cheese_spatula" + | "/actions/cheesesmithing/cheese_spear" + | "/actions/cheesesmithing/cheese_sword" + | "/actions/cheesesmithing/cheese" + | "/actions/cheesesmithing/colossus_plate_body" + | "/actions/cheesesmithing/colossus_plate_legs" + | "/actions/cheesesmithing/crimson_boots" + | "/actions/cheesesmithing/crimson_brush" + | "/actions/cheesesmithing/crimson_buckler" + | "/actions/cheesesmithing/crimson_bulwark" + | "/actions/cheesesmithing/crimson_cheese" + | "/actions/cheesesmithing/crimson_chisel" + | "/actions/cheesesmithing/crimson_enhancer" + | "/actions/cheesesmithing/crimson_gauntlets" + | "/actions/cheesesmithing/crimson_hammer" + | "/actions/cheesesmithing/crimson_hatchet" + | "/actions/cheesesmithing/crimson_helmet" + | "/actions/cheesesmithing/crimson_mace" + | "/actions/cheesesmithing/crimson_needle" + | "/actions/cheesesmithing/crimson_plate_body" + | "/actions/cheesesmithing/crimson_plate_legs" + | "/actions/cheesesmithing/crimson_pot" + | "/actions/cheesesmithing/crimson_shears" + | "/actions/cheesesmithing/crimson_spatula" + | "/actions/cheesesmithing/crimson_spear" + | "/actions/cheesesmithing/crimson_sword" + | "/actions/cheesesmithing/demonic_plate_body" + | "/actions/cheesesmithing/demonic_plate_legs" + | "/actions/cheesesmithing/granite_bludgeon" + | "/actions/cheesesmithing/grizzly_bear_shoes" + | "/actions/cheesesmithing/holy_boots" + | "/actions/cheesesmithing/holy_brush" + | "/actions/cheesesmithing/holy_buckler" + | "/actions/cheesesmithing/holy_bulwark" + | "/actions/cheesesmithing/holy_cheese" + | "/actions/cheesesmithing/holy_chisel" + | "/actions/cheesesmithing/holy_enhancer" + | "/actions/cheesesmithing/holy_gauntlets" + | "/actions/cheesesmithing/holy_hammer" + | "/actions/cheesesmithing/holy_hatchet" + | "/actions/cheesesmithing/holy_helmet" + | "/actions/cheesesmithing/holy_mace" + | "/actions/cheesesmithing/holy_needle" + | "/actions/cheesesmithing/holy_plate_body" + | "/actions/cheesesmithing/holy_plate_legs" + | "/actions/cheesesmithing/holy_pot" + | "/actions/cheesesmithing/holy_shears" + | "/actions/cheesesmithing/holy_spatula" + | "/actions/cheesesmithing/holy_spear" + | "/actions/cheesesmithing/holy_sword" + | "/actions/cheesesmithing/magnetic_gloves" + | "/actions/cheesesmithing/panda_gloves" + | "/actions/cheesesmithing/pincer_gloves" + | "/actions/cheesesmithing/polar_bear_shoes" + | "/actions/cheesesmithing/rainbow_boots" + | "/actions/cheesesmithing/rainbow_brush" + | "/actions/cheesesmithing/rainbow_buckler" + | "/actions/cheesesmithing/rainbow_bulwark" + | "/actions/cheesesmithing/rainbow_cheese" + | "/actions/cheesesmithing/rainbow_chisel" + | "/actions/cheesesmithing/rainbow_enhancer" + | "/actions/cheesesmithing/rainbow_gauntlets" + | "/actions/cheesesmithing/rainbow_hammer" + | "/actions/cheesesmithing/rainbow_hatchet" + | "/actions/cheesesmithing/rainbow_helmet" + | "/actions/cheesesmithing/rainbow_mace" + | "/actions/cheesesmithing/rainbow_needle" + | "/actions/cheesesmithing/rainbow_plate_body" + | "/actions/cheesesmithing/rainbow_plate_legs" + | "/actions/cheesesmithing/rainbow_pot" + | "/actions/cheesesmithing/rainbow_shears" + | "/actions/cheesesmithing/rainbow_spatula" + | "/actions/cheesesmithing/rainbow_spear" + | "/actions/cheesesmithing/rainbow_sword" + | "/actions/cheesesmithing/snail_shell_helmet" + | "/actions/cheesesmithing/snake_fang_dirk" + | "/actions/cheesesmithing/spiked_bulwark" + | "/actions/cheesesmithing/stalactite_spear" + | "/actions/cheesesmithing/turtle_shell_body" + | "/actions/cheesesmithing/turtle_shell_legs" + | "/actions/cheesesmithing/vampire_fang_dirk" + | "/actions/cheesesmithing/verdant_boots" + | "/actions/cheesesmithing/verdant_brush" + | "/actions/cheesesmithing/verdant_buckler" + | "/actions/cheesesmithing/verdant_bulwark" + | "/actions/cheesesmithing/verdant_cheese" + | "/actions/cheesesmithing/verdant_chisel" + | "/actions/cheesesmithing/verdant_enhancer" + | "/actions/cheesesmithing/verdant_gauntlets" + | "/actions/cheesesmithing/verdant_hammer" + | "/actions/cheesesmithing/verdant_hatchet" + | "/actions/cheesesmithing/verdant_helmet" + | "/actions/cheesesmithing/verdant_mace" + | "/actions/cheesesmithing/verdant_needle" + | "/actions/cheesesmithing/verdant_plate_body" + | "/actions/cheesesmithing/verdant_plate_legs" + | "/actions/cheesesmithing/verdant_pot" + | "/actions/cheesesmithing/verdant_shears" + | "/actions/cheesesmithing/verdant_spatula" + | "/actions/cheesesmithing/verdant_spear" + | "/actions/cheesesmithing/verdant_sword" + | "/actions/cheesesmithing/vision_helmet" + | "/actions/cheesesmithing/vision_shield" + | "/actions/cheesesmithing/werewolf_slasher" + | "/actions/combat/abyssal_imp" + | "/actions/combat/alligator" + | "/actions/combat/aqua_planet_elite" + | "/actions/combat/aqua_planet" + | "/actions/combat/aquahorse" + | "/actions/combat/bear_with_it_elite" + | "/actions/combat/bear_with_it" + | "/actions/combat/black_bear" + | "/actions/combat/centaur_archer" + | "/actions/combat/crab" + | "/actions/combat/elementalist" + | "/actions/combat/eye" + | "/actions/combat/eyes" + | "/actions/combat/flame_sorcerer" + | "/actions/combat/fly" + | "/actions/combat/frog" + | "/actions/combat/gobo_boomy" + | "/actions/combat/gobo_planet_elite" + | "/actions/combat/gobo_planet" + | "/actions/combat/gobo_shooty" + | "/actions/combat/gobo_slashy" + | "/actions/combat/gobo_smashy" + | "/actions/combat/gobo_stabby" + | "/actions/combat/golem_cave_elite" + | "/actions/combat/golem_cave" + | "/actions/combat/granite_golem" + | "/actions/combat/grizzly_bear" + | "/actions/combat/gummy_bear" + | "/actions/combat/ice_sorcerer" + | "/actions/combat/infernal_abyss_elite" + | "/actions/combat/infernal_abyss" + | "/actions/combat/infernal_warlock" + | "/actions/combat/jungle_planet_elite" + | "/actions/combat/jungle_planet" + | "/actions/combat/jungle_sprite" + | "/actions/combat/magnetic_golem" + | "/actions/combat/myconid" + | "/actions/combat/nom_nom" + | "/actions/combat/novice_sorcerer" + | "/actions/combat/panda" + | "/actions/combat/planet_of_the_eyes_elite" + | "/actions/combat/planet_of_the_eyes" + | "/actions/combat/polar_bear" + | "/actions/combat/porcupine" + | "/actions/combat/rat" + | "/actions/combat/sea_snail" + | "/actions/combat/skunk" + | "/actions/combat/slimy" + | "/actions/combat/smelly_planet_elite" + | "/actions/combat/smelly_planet" + | "/actions/combat/snake" + | "/actions/combat/sorcerers_tower_elite" + | "/actions/combat/sorcerers_tower" + | "/actions/combat/soul_hunter" + | "/actions/combat/stalactite_golem" + | "/actions/combat/swamp_planet_elite" + | "/actions/combat/swamp_planet" + | "/actions/combat/swampy" + | "/actions/combat/treant" + | "/actions/combat/turtle" + | "/actions/combat/twilight_zone_elite" + | "/actions/combat/twilight_zone" + | "/actions/combat/vampire" + | "/actions/combat/veyes" + | "/actions/combat/werewolf" + | "/actions/combat/zombie" + | "/actions/cooking/apple_gummy" + | "/actions/cooking/apple_yogurt" + | "/actions/cooking/blackberry_cake" + | "/actions/cooking/blackberry_donut" + | "/actions/cooking/blueberry_cake" + | "/actions/cooking/blueberry_donut" + | "/actions/cooking/cupcake" + | "/actions/cooking/donut" + | "/actions/cooking/dragon_fruit_gummy" + | "/actions/cooking/dragon_fruit_yogurt" + | "/actions/cooking/gummy" + | "/actions/cooking/marsberry_cake" + | "/actions/cooking/marsberry_donut" + | "/actions/cooking/mooberry_cake" + | "/actions/cooking/mooberry_donut" + | "/actions/cooking/orange_gummy" + | "/actions/cooking/orange_yogurt" + | "/actions/cooking/peach_gummy" + | "/actions/cooking/peach_yogurt" + | "/actions/cooking/plum_gummy" + | "/actions/cooking/plum_yogurt" + | "/actions/cooking/spaceberry_cake" + | "/actions/cooking/spaceberry_donut" + | "/actions/cooking/star_fruit_gummy" + | "/actions/cooking/star_fruit_yogurt" + | "/actions/cooking/strawberry_cake" + | "/actions/cooking/strawberry_donut" + | "/actions/cooking/yogurt" + | "/actions/crafting/advanced_task_ring" + | "/actions/crafting/arcane_bow" + | "/actions/crafting/arcane_crossbow" + | "/actions/crafting/arcane_fire_staff" + | "/actions/crafting/arcane_lumber" + | "/actions/crafting/arcane_nature_staff" + | "/actions/crafting/arcane_shield" + | "/actions/crafting/arcane_water_staff" + | "/actions/crafting/basic_task_ring" + | "/actions/crafting/birch_bow" + | "/actions/crafting/birch_crossbow" + | "/actions/crafting/birch_fire_staff" + | "/actions/crafting/birch_lumber" + | "/actions/crafting/birch_nature_staff" + | "/actions/crafting/birch_shield" + | "/actions/crafting/birch_water_staff" + | "/actions/crafting/cedar_bow" + | "/actions/crafting/cedar_crossbow" + | "/actions/crafting/cedar_fire_staff" + | "/actions/crafting/cedar_lumber" + | "/actions/crafting/cedar_nature_staff" + | "/actions/crafting/cedar_shield" + | "/actions/crafting/cedar_water_staff" + | "/actions/crafting/crushed_amber" + | "/actions/crafting/crushed_amethyst" + | "/actions/crafting/crushed_garnet" + | "/actions/crafting/crushed_jade" + | "/actions/crafting/crushed_moonstone" + | "/actions/crafting/crushed_pearl" + | "/actions/crafting/earrings_of_armor" + | "/actions/crafting/earrings_of_gathering" + | "/actions/crafting/earrings_of_rare_find" + | "/actions/crafting/earrings_of_regeneration" + | "/actions/crafting/earrings_of_resistance" + | "/actions/crafting/expert_task_ring" + | "/actions/crafting/eye_watch" + | "/actions/crafting/fighter_necklace" + | "/actions/crafting/frost_staff" + | "/actions/crafting/ginkgo_bow" + | "/actions/crafting/ginkgo_crossbow" + | "/actions/crafting/ginkgo_fire_staff" + | "/actions/crafting/ginkgo_lumber" + | "/actions/crafting/ginkgo_nature_staff" + | "/actions/crafting/ginkgo_shield" + | "/actions/crafting/ginkgo_water_staff" + | "/actions/crafting/infernal_battlestaff" + | "/actions/crafting/lumber" + | "/actions/crafting/mirror_of_protection" + | "/actions/crafting/necklace_of_efficiency" + | "/actions/crafting/necklace_of_wisdom" + | "/actions/crafting/purpleheart_bow" + | "/actions/crafting/purpleheart_crossbow" + | "/actions/crafting/purpleheart_fire_staff" + | "/actions/crafting/purpleheart_lumber" + | "/actions/crafting/purpleheart_nature_staff" + | "/actions/crafting/purpleheart_shield" + | "/actions/crafting/purpleheart_water_staff" + | "/actions/crafting/ranger_necklace" + | "/actions/crafting/redwood_bow" + | "/actions/crafting/redwood_crossbow" + | "/actions/crafting/redwood_fire_staff" + | "/actions/crafting/redwood_lumber" + | "/actions/crafting/redwood_nature_staff" + | "/actions/crafting/redwood_shield" + | "/actions/crafting/redwood_water_staff" + | "/actions/crafting/ring_of_armor" + | "/actions/crafting/ring_of_gathering" + | "/actions/crafting/ring_of_rare_find" + | "/actions/crafting/ring_of_regeneration" + | "/actions/crafting/ring_of_resistance" + | "/actions/crafting/soul_hunter_crossbow" + | "/actions/crafting/treant_shield" + | "/actions/crafting/vampiric_bow" + | "/actions/crafting/watchful_relic" + | "/actions/crafting/wizard_necklace" + | "/actions/crafting/wooden_bow" + | "/actions/crafting/wooden_crossbow" + | "/actions/crafting/wooden_fire_staff" + | "/actions/crafting/wooden_nature_staff" + | "/actions/crafting/wooden_shield" + | "/actions/crafting/wooden_water_staff" + | "/actions/enhancing/enhance" + | "/actions/foraging/apple" + | "/actions/foraging/arabica_coffee_bean" + | "/actions/foraging/asteroid_belt" + | "/actions/foraging/bamboo_branch" + | "/actions/foraging/blackberry" + | "/actions/foraging/blueberry" + | "/actions/foraging/burble_beach" + | "/actions/foraging/cocoon" + | "/actions/foraging/cotton" + | "/actions/foraging/dragon_fruit" + | "/actions/foraging/egg" + | "/actions/foraging/excelsa_coffee_bean" + | "/actions/foraging/farmland" + | "/actions/foraging/fieriosa_coffee_bean" + | "/actions/foraging/flax" + | "/actions/foraging/liberica_coffee_bean" + | "/actions/foraging/marsberry" + | "/actions/foraging/misty_forest" + | "/actions/foraging/mooberry" + | "/actions/foraging/olympus_mons" + | "/actions/foraging/orange" + | "/actions/foraging/peach" + | "/actions/foraging/plum" + | "/actions/foraging/radiant_fiber" + | "/actions/foraging/robusta_coffee_bean" + | "/actions/foraging/shimmering_lake" + | "/actions/foraging/silly_cow_valley" + | "/actions/foraging/spaceberry" + | "/actions/foraging/spacia_coffee_bean" + | "/actions/foraging/star_fruit" + | "/actions/foraging/strawberry" + | "/actions/foraging/sugar" + | "/actions/foraging/wheat" + | "/actions/milking/azure_cow" + | "/actions/milking/burble_cow" + | "/actions/milking/cow" + | "/actions/milking/crimson_cow" + | "/actions/milking/holy_cow" + | "/actions/milking/unicow" + | "/actions/milking/verdant_cow" + | "/actions/tailoring/bamboo_boots" + | "/actions/tailoring/bamboo_fabric" + | "/actions/tailoring/bamboo_gloves" + | "/actions/tailoring/bamboo_hat" + | "/actions/tailoring/bamboo_robe_bottoms" + | "/actions/tailoring/bamboo_robe_top" + | "/actions/tailoring/beast_boots" + | "/actions/tailoring/beast_bracers" + | "/actions/tailoring/beast_chaps" + | "/actions/tailoring/beast_hood" + | "/actions/tailoring/beast_leather" + | "/actions/tailoring/beast_tunic" + | "/actions/tailoring/centaur_boots" + | "/actions/tailoring/chrono_gloves" + | "/actions/tailoring/collectors_boots" + | "/actions/tailoring/cotton_boots" + | "/actions/tailoring/cotton_fabric" + | "/actions/tailoring/cotton_gloves" + | "/actions/tailoring/cotton_hat" + | "/actions/tailoring/cotton_robe_bottoms" + | "/actions/tailoring/cotton_robe_top" + | "/actions/tailoring/enchanted_gloves" + | "/actions/tailoring/flaming_robe_bottoms" + | "/actions/tailoring/flaming_robe_top" + | "/actions/tailoring/fluffy_red_hat" + | "/actions/tailoring/giant_pouch" + | "/actions/tailoring/gobo_boots" + | "/actions/tailoring/gobo_bracers" + | "/actions/tailoring/gobo_chaps" + | "/actions/tailoring/gobo_hood" + | "/actions/tailoring/gobo_leather" + | "/actions/tailoring/gobo_tunic" + | "/actions/tailoring/icy_robe_bottoms" + | "/actions/tailoring/icy_robe_top" + | "/actions/tailoring/large_pouch" + | "/actions/tailoring/linen_boots" + | "/actions/tailoring/linen_fabric" + | "/actions/tailoring/linen_gloves" + | "/actions/tailoring/linen_hat" + | "/actions/tailoring/linen_robe_bottoms" + | "/actions/tailoring/linen_robe_top" + | "/actions/tailoring/luna_robe_bottoms" + | "/actions/tailoring/luna_robe_top" + | "/actions/tailoring/marine_chaps" + | "/actions/tailoring/marine_tunic" + | "/actions/tailoring/medium_pouch" + | "/actions/tailoring/radiant_boots" + | "/actions/tailoring/radiant_fabric" + | "/actions/tailoring/radiant_gloves" + | "/actions/tailoring/radiant_hat" + | "/actions/tailoring/radiant_robe_bottoms" + | "/actions/tailoring/radiant_robe_top" + | "/actions/tailoring/red_chefs_hat" + | "/actions/tailoring/reptile_boots" + | "/actions/tailoring/reptile_bracers" + | "/actions/tailoring/reptile_chaps" + | "/actions/tailoring/reptile_hood" + | "/actions/tailoring/reptile_leather" + | "/actions/tailoring/reptile_tunic" + | "/actions/tailoring/revenant_chaps" + | "/actions/tailoring/revenant_tunic" + | "/actions/tailoring/rough_boots" + | "/actions/tailoring/rough_bracers" + | "/actions/tailoring/rough_chaps" + | "/actions/tailoring/rough_hood" + | "/actions/tailoring/rough_leather" + | "/actions/tailoring/rough_tunic" + | "/actions/tailoring/shoebill_shoes" + | "/actions/tailoring/sighted_bracers" + | "/actions/tailoring/silk_boots" + | "/actions/tailoring/silk_fabric" + | "/actions/tailoring/silk_gloves" + | "/actions/tailoring/silk_hat" + | "/actions/tailoring/silk_robe_bottoms" + | "/actions/tailoring/silk_robe_top" + | "/actions/tailoring/small_pouch" + | "/actions/tailoring/sorcerer_boots" + | "/actions/tailoring/umbral_boots" + | "/actions/tailoring/umbral_bracers" + | "/actions/tailoring/umbral_chaps" + | "/actions/tailoring/umbral_hood" + | "/actions/tailoring/umbral_leather" + | "/actions/tailoring/umbral_tunic" + | "/actions/woodcutting/arcane_tree" + | "/actions/woodcutting/birch_tree" + | "/actions/woodcutting/cedar_tree" + | "/actions/woodcutting/ginkgo_tree" + | "/actions/woodcutting/purpleheart_tree" + | "/actions/woodcutting/redwood_tree" + | "/actions/woodcutting/tree"; diff --git a/src/MooLite/core/inventory/items/decodeItemHash.ts b/src/MooLite/core/inventory/items/decodeItemHash.ts new file mode 100644 index 0000000..b08ad52 --- /dev/null +++ b/src/MooLite/core/inventory/items/decodeItemHash.ts @@ -0,0 +1,29 @@ +import { ItemHrid } from "../ItemHrid"; +import { ItemLocationHrid } from "../ItemLocationHrid"; + +export interface ItemHashParts { + characterId: number; + itemLocationHrid: ItemLocationHrid; + itemHrid: ItemHrid; + enhancementLevel: number; +} + +/** + * An item hash looks like + * `123456::/item_locations/inventory::/items/cheese_enhancer::0` + * This function will break it down into its component parts so they can be + * used elsewhere, like when tracking what items are being used for enhancing. + * + * @param itemHash - the hash to deconstruct, should be in the above format + * @returns a deconstructed item hash + */ +export function decodeItemHash(itemHash: string): ItemHashParts { + const parts = itemHash.split("::"); + + return { + characterId: parseInt(parts[0]), + itemLocationHrid: parts[1] as any as ItemLocationHrid, + itemHrid: parts[2] as any as ItemHrid, + enhancementLevel: parseInt(parts[3]), + }; +} diff --git a/src/MooLite/core/server/clientmessages/ClientMessageType.ts b/src/MooLite/core/server/clientmessages/ClientMessageType.ts index 0081d5f..d09e4a0 100644 --- a/src/MooLite/core/server/clientmessages/ClientMessageType.ts +++ b/src/MooLite/core/server/clientmessages/ClientMessageType.ts @@ -1,3 +1,3 @@ export enum ClientMessageType { - Ping = "/character_tasks/ping", + Ping = "ping", } diff --git a/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPlugin.ts b/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPlugin.ts new file mode 100644 index 0000000..86b9375 --- /dev/null +++ b/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPlugin.ts @@ -0,0 +1,141 @@ +import { MooLitePlugin } from "src/MooLite/core/plugins/MooLitePlugin"; +import { MooLiteTab } from "src/MooLite/core/plugins/MooLiteTab"; +import EnhancingTrackerPluginDisplay from "src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPluginDisplay.vue"; +import { markRaw } from "vue"; +import { PluginAuthorCredits } from "src/MooLite/core/plugins/PluginAuthorCredits"; +import { ItemDetail } from "src/MooLite/core/inventory/items/ItemDetail"; +import { ItemHrid } from "src/MooLite/core/inventory/ItemHrid"; +import { CharacterAction } from "src/MooLite/core/actions/CharacterAction"; +import { ItemGained } from "src/MooLite/core/inventory/Inventory"; +import { ItemHashParts, decodeItemHash } from "src/MooLite/core/inventory/items/decodeItemHash"; +import { ItemAmount } from "src/MooLite/core/inventory/items/ItemAmount"; + +export class EnhancingTrackerPlugin extends MooLitePlugin { + name: string = "Enhancing Tracker"; + key = "enhancing-tracker"; + description: string = "Tracks materials consumed during enhancing."; + + credits: PluginAuthorCredits = { + author: "seashairo", + maintainer: "seashairo", + }; + + tab: MooLiteTab = { + icon: "⭐", + pluginName: this.name, + componentName: "EnhancingTrackerPluginDisplay", + component: markRaw(EnhancingTrackerPluginDisplay), + }; + + public get itemDetailMap(): Record { + return this._game.inventory.itemDetailMap; + } + + itemBeingEnhancedHrid: ItemHrid | null = null; + itemsConsumed: Record = {}; + bestEnhancementLevel: number = 0; + successes: number = 0; + failures: number = 0; + blessedTeaProcs: number = 0; + itemState: ItemHashParts | null = null; + previousAction: CharacterAction | null = null; + + public get successRate(): number { + const attempts = this.successes + this.failures; + if (attempts === 0) { + return 100; + } + + return (this.successes / (this.successes + this.failures)) * 100; + } + + onActionQueueUpdated(queue: CharacterAction[]): void { + const currentAction = queue.length ? queue[0] : null; + if (currentAction !== null) { + if ( + currentAction.actionHrid === "/actions/enhancing/enhance" && + !(this.previousAction?.actionHrid === "/actions/enhancing/enhance") + ) { + this.handleStartedEnhancing(currentAction); + } + + if ( + currentAction.actionHrid === "/actions/enhancing/enhance" && + this.previousAction?.actionHrid === "/actions/enhancing/enhance" + ) { + this.handleEnhancing(currentAction); + } + } + + this.previousAction = currentAction; + } + + handleStartedEnhancing(currentAction: CharacterAction): void { + const itemHashParts = decodeItemHash(currentAction.upgradeItemHash); + this.itemState = itemHashParts; + this.itemBeingEnhancedHrid = itemHashParts.itemHrid; + this.bestEnhancementLevel = itemHashParts.enhancementLevel; + this.itemsConsumed = {}; + } + + addConsumedItem(itemAmount: ItemAmount): void { + if (itemAmount.itemHrid in this.itemsConsumed) { + this.itemsConsumed[itemAmount.itemHrid] += itemAmount.count; + } else { + this.itemsConsumed[itemAmount.itemHrid] = itemAmount.count; + } + } + + handleEnhancing(currentAction: CharacterAction): void { + const currentItemState = decodeItemHash(currentAction.upgradeItemHash); + const itemBeingEnhancedHrid = currentItemState.itemHrid; + + // If the item being enhanced has changed hrid, then we're enhancing + // something new. + // + // TODO: Handle this more gracefully. Maybe store a dict of enhancing + // data against hrid to display a table? + if (this.itemBeingEnhancedHrid !== itemBeingEnhancedHrid) { + return this.handleStartedEnhancing(currentAction); + } + + // Instead of watching the items gained and lost, we want to use the + // item's enhancement cost. This is because players using the market + // will hit the onItemGained handler and leave the count inaccurate. + // + // TODO: When Blessed Tea procs, do you use 1 or 2 sets of consumables? + // If it's 1 then this is accurate, but if it's 2 then this logic would + // need to be part of the level check below + const enhancingCosts = this._game.inventory.itemDetailMap[itemBeingEnhancedHrid].enhancementCosts; + enhancingCosts!.forEach((itemAmount) => this.addConsumedItem(itemAmount)); + + const itemState = this.itemState!; + if (currentItemState.enhancementLevel > itemState.enhancementLevel) { + const diff = currentItemState.enhancementLevel - itemState.enhancementLevel; + this.successes += 1; + // I'm pretty sure the level diff will only ever be 1 or 2, but just + // in case blessed tea can multi-proc we'll check for anything + // greater than 1. I'm also assuming (but haven't confirmed) that a + // blessed tea proc will still be in a single action update and not + // two separate ones. + if (diff > 1) { + this.blessedTeaProcs += 1; + } + } else { + this.failures += 1; + + // Protections don't get counted in the regular consumed items + // report, so if we drop an enhancement level then we need to + // manually count a lost protection. + const protectionHash = currentAction.enhancingProtectionItemHash; + if (protectionHash !== "" && itemState.enhancementLevel >= currentAction.enhancingProtectionItemMinLevel) { + const itemHrid = decodeItemHash(protectionHash).itemHrid; + this.addConsumedItem({ itemHrid, count: 1 }); + } + } + + this.bestEnhancementLevel = Math.max(currentItemState.enhancementLevel, this.bestEnhancementLevel); + + this.itemState = currentItemState; + } +} diff --git a/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPluginDisplay.vue b/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPluginDisplay.vue new file mode 100644 index 0000000..fd9fe89 --- /dev/null +++ b/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPluginDisplay.vue @@ -0,0 +1,55 @@ + + + diff --git a/src/components/atoms/ItemIcon.vue b/src/components/atoms/ItemIcon.vue index e8c941b..dd5ff69 100644 --- a/src/components/atoms/ItemIcon.vue +++ b/src/components/atoms/ItemIcon.vue @@ -15,7 +15,7 @@ const imgUrl = computed(() => { const split = (props.item as unknown as string).split("/"); const itemPostfix = split[split.length - 1]; // TODO(@Isha): Research how these CDN resource urls are generated - return `/static/media/items_sprite.951ef1ec.svg#${itemPostfix}`; + return `/static/media/items_sprite.018a3c6e.svg#${itemPostfix}`; }); diff --git a/src/main.ts b/src/main.ts index dab91f7..234bf80 100644 --- a/src/main.ts +++ b/src/main.ts @@ -19,6 +19,7 @@ import { ConsumableNotifierPlugin } from "./MooLite/plugins/ConsumableNotifier/C import { EquipmentExporterPlugin } from "src/MooLite/plugins/EquipmentExporter/EquipmentExporterPlugin"; import { WhisperManagerPlugin } from "./MooLite/plugins/WhisperManager/WhisperManagerPlugin"; import { ThemesPlugin } from "src/MooLite/plugins/Themes/ThemesPlugin"; +import { EnhancingTrackerPlugin } from "./MooLite/plugins/EnhancingTracker/EnhancingTrackerPlugin"; declare global { interface Window { @@ -62,6 +63,7 @@ const launchMooLite = () => { new EquipmentExporterPlugin(), new WhisperManagerPlugin(), new ThemesPlugin(), + new EnhancingTrackerPlugin(), ]) as unknown as MooLitePlugin[]; const pluginManager = reactive(new PluginManager(game, plugins)) as PluginManager; From 2d37856543d2d318ec1a429f38ffeb207f835a05 Mon Sep 17 00:00:00 2001 From: Nathan S Date: Thu, 8 Feb 2024 02:02:54 +0000 Subject: [PATCH 2/6] How do I always forget the fucking linter? --- .../EnhancingTrackerPluginDisplay.vue | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPluginDisplay.vue b/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPluginDisplay.vue index fd9fe89..db25a57 100644 --- a/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPluginDisplay.vue +++ b/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPluginDisplay.vue @@ -21,7 +21,7 @@ const loot: Ref = ref([]);

Enhancing {{ plugin.itemDetailMap[plugin.itemBeingEnhancedHrid].name }}

- +

@@ -29,10 +29,9 @@ const loot: Ref = ref([]);

Items consumed

None!

-
+
- + {{ plugin.itemDetailMap[key].name }}

{{ value }}

@@ -40,16 +39,11 @@ const loot: Ref = ref([]);

Best enhancement level: {{ plugin.bestEnhancementLevel }}

-

- Success rate: {{ plugin.successRate.toFixed(2) }}% ({{ plugin.successes }} / {{ plugin.failures }}) -

-
+

Success rate: {{ plugin.successRate.toFixed(2) }}% ({{ plugin.successes }} / {{ plugin.failures }})

+
-

- It doesn't look like you're enhancing anything at the moment. - Try it out! -

+

It doesn't look like you're enhancing anything at the moment. Try it out!

From 5c3772d4e82206162e59c4e02f2610c12e328aba Mon Sep 17 00:00:00 2001 From: Nathan S Date: Sun, 11 Feb 2024 21:27:43 +0000 Subject: [PATCH 3/6] Untype ActionHrid --- src/MooLite/core/actions/ActionHrid.ts | 520 +----------------- .../EnhancingTrackerPlugin.ts | 23 +- 2 files changed, 11 insertions(+), 532 deletions(-) diff --git a/src/MooLite/core/actions/ActionHrid.ts b/src/MooLite/core/actions/ActionHrid.ts index 99f9f38..62ddf08 100644 --- a/src/MooLite/core/actions/ActionHrid.ts +++ b/src/MooLite/core/actions/ActionHrid.ts @@ -1,519 +1 @@ -/** - * ActionHrids pulled from init data - last updated 2024-08-02 - * - * While these are available from init data, we can't use init data for typing. - * Having a copy here lets us type things correctly and search against the - * ActionMap. Entries are sorted alphabetically in ascending order. - */ -export type ActionHrid = - | "/actions/brewing/artisan_tea" - | "/actions/brewing/attack_coffee" - | "/actions/brewing/blessed_tea" - | "/actions/brewing/brewing_tea" - | "/actions/brewing/channeling_coffee" - | "/actions/brewing/cheesesmithing_tea" - | "/actions/brewing/cooking_tea" - | "/actions/brewing/crafting_tea" - | "/actions/brewing/critical_coffee" - | "/actions/brewing/defense_coffee" - | "/actions/brewing/efficiency_tea" - | "/actions/brewing/enhancing_tea" - | "/actions/brewing/foraging_tea" - | "/actions/brewing/gathering_tea" - | "/actions/brewing/gourmet_tea" - | "/actions/brewing/intelligence_coffee" - | "/actions/brewing/lucky_coffee" - | "/actions/brewing/magic_coffee" - | "/actions/brewing/milking_tea" - | "/actions/brewing/power_coffee" - | "/actions/brewing/processing_tea" - | "/actions/brewing/ranged_coffee" - | "/actions/brewing/stamina_coffee" - | "/actions/brewing/super_attack_coffee" - | "/actions/brewing/super_brewing_tea" - | "/actions/brewing/super_cheesesmithing_tea" - | "/actions/brewing/super_cooking_tea" - | "/actions/brewing/super_crafting_tea" - | "/actions/brewing/super_defense_coffee" - | "/actions/brewing/super_enhancing_tea" - | "/actions/brewing/super_foraging_tea" - | "/actions/brewing/super_intelligence_coffee" - | "/actions/brewing/super_magic_coffee" - | "/actions/brewing/super_milking_tea" - | "/actions/brewing/super_power_coffee" - | "/actions/brewing/super_ranged_coffee" - | "/actions/brewing/super_stamina_coffee" - | "/actions/brewing/super_tailoring_tea" - | "/actions/brewing/super_woodcutting_tea" - | "/actions/brewing/swiftness_coffee" - | "/actions/brewing/tailoring_tea" - | "/actions/brewing/wisdom_coffee" - | "/actions/brewing/wisdom_tea" - | "/actions/brewing/woodcutting_tea" - | "/actions/cheesesmithing/azure_boots" - | "/actions/cheesesmithing/azure_brush" - | "/actions/cheesesmithing/azure_buckler" - | "/actions/cheesesmithing/azure_bulwark" - | "/actions/cheesesmithing/azure_cheese" - | "/actions/cheesesmithing/azure_chisel" - | "/actions/cheesesmithing/azure_enhancer" - | "/actions/cheesesmithing/azure_gauntlets" - | "/actions/cheesesmithing/azure_hammer" - | "/actions/cheesesmithing/azure_hatchet" - | "/actions/cheesesmithing/azure_helmet" - | "/actions/cheesesmithing/azure_mace" - | "/actions/cheesesmithing/azure_needle" - | "/actions/cheesesmithing/azure_plate_body" - | "/actions/cheesesmithing/azure_plate_legs" - | "/actions/cheesesmithing/azure_pot" - | "/actions/cheesesmithing/azure_shears" - | "/actions/cheesesmithing/azure_spatula" - | "/actions/cheesesmithing/azure_spear" - | "/actions/cheesesmithing/azure_sword" - | "/actions/cheesesmithing/black_bear_shoes" - | "/actions/cheesesmithing/burble_boots" - | "/actions/cheesesmithing/burble_brush" - | "/actions/cheesesmithing/burble_buckler" - | "/actions/cheesesmithing/burble_bulwark" - | "/actions/cheesesmithing/burble_cheese" - | "/actions/cheesesmithing/burble_chisel" - | "/actions/cheesesmithing/burble_enhancer" - | "/actions/cheesesmithing/burble_gauntlets" - | "/actions/cheesesmithing/burble_hammer" - | "/actions/cheesesmithing/burble_hatchet" - | "/actions/cheesesmithing/burble_helmet" - | "/actions/cheesesmithing/burble_mace" - | "/actions/cheesesmithing/burble_needle" - | "/actions/cheesesmithing/burble_plate_body" - | "/actions/cheesesmithing/burble_plate_legs" - | "/actions/cheesesmithing/burble_pot" - | "/actions/cheesesmithing/burble_shears" - | "/actions/cheesesmithing/burble_spatula" - | "/actions/cheesesmithing/burble_spear" - | "/actions/cheesesmithing/burble_sword" - | "/actions/cheesesmithing/cheese_boots" - | "/actions/cheesesmithing/cheese_brush" - | "/actions/cheesesmithing/cheese_buckler" - | "/actions/cheesesmithing/cheese_bulwark" - | "/actions/cheesesmithing/cheese_chisel" - | "/actions/cheesesmithing/cheese_enhancer" - | "/actions/cheesesmithing/cheese_gauntlets" - | "/actions/cheesesmithing/cheese_hammer" - | "/actions/cheesesmithing/cheese_hatchet" - | "/actions/cheesesmithing/cheese_helmet" - | "/actions/cheesesmithing/cheese_mace" - | "/actions/cheesesmithing/cheese_needle" - | "/actions/cheesesmithing/cheese_plate_body" - | "/actions/cheesesmithing/cheese_plate_legs" - | "/actions/cheesesmithing/cheese_pot" - | "/actions/cheesesmithing/cheese_shears" - | "/actions/cheesesmithing/cheese_spatula" - | "/actions/cheesesmithing/cheese_spear" - | "/actions/cheesesmithing/cheese_sword" - | "/actions/cheesesmithing/cheese" - | "/actions/cheesesmithing/colossus_plate_body" - | "/actions/cheesesmithing/colossus_plate_legs" - | "/actions/cheesesmithing/crimson_boots" - | "/actions/cheesesmithing/crimson_brush" - | "/actions/cheesesmithing/crimson_buckler" - | "/actions/cheesesmithing/crimson_bulwark" - | "/actions/cheesesmithing/crimson_cheese" - | "/actions/cheesesmithing/crimson_chisel" - | "/actions/cheesesmithing/crimson_enhancer" - | "/actions/cheesesmithing/crimson_gauntlets" - | "/actions/cheesesmithing/crimson_hammer" - | "/actions/cheesesmithing/crimson_hatchet" - | "/actions/cheesesmithing/crimson_helmet" - | "/actions/cheesesmithing/crimson_mace" - | "/actions/cheesesmithing/crimson_needle" - | "/actions/cheesesmithing/crimson_plate_body" - | "/actions/cheesesmithing/crimson_plate_legs" - | "/actions/cheesesmithing/crimson_pot" - | "/actions/cheesesmithing/crimson_shears" - | "/actions/cheesesmithing/crimson_spatula" - | "/actions/cheesesmithing/crimson_spear" - | "/actions/cheesesmithing/crimson_sword" - | "/actions/cheesesmithing/demonic_plate_body" - | "/actions/cheesesmithing/demonic_plate_legs" - | "/actions/cheesesmithing/granite_bludgeon" - | "/actions/cheesesmithing/grizzly_bear_shoes" - | "/actions/cheesesmithing/holy_boots" - | "/actions/cheesesmithing/holy_brush" - | "/actions/cheesesmithing/holy_buckler" - | "/actions/cheesesmithing/holy_bulwark" - | "/actions/cheesesmithing/holy_cheese" - | "/actions/cheesesmithing/holy_chisel" - | "/actions/cheesesmithing/holy_enhancer" - | "/actions/cheesesmithing/holy_gauntlets" - | "/actions/cheesesmithing/holy_hammer" - | "/actions/cheesesmithing/holy_hatchet" - | "/actions/cheesesmithing/holy_helmet" - | "/actions/cheesesmithing/holy_mace" - | "/actions/cheesesmithing/holy_needle" - | "/actions/cheesesmithing/holy_plate_body" - | "/actions/cheesesmithing/holy_plate_legs" - | "/actions/cheesesmithing/holy_pot" - | "/actions/cheesesmithing/holy_shears" - | "/actions/cheesesmithing/holy_spatula" - | "/actions/cheesesmithing/holy_spear" - | "/actions/cheesesmithing/holy_sword" - | "/actions/cheesesmithing/magnetic_gloves" - | "/actions/cheesesmithing/panda_gloves" - | "/actions/cheesesmithing/pincer_gloves" - | "/actions/cheesesmithing/polar_bear_shoes" - | "/actions/cheesesmithing/rainbow_boots" - | "/actions/cheesesmithing/rainbow_brush" - | "/actions/cheesesmithing/rainbow_buckler" - | "/actions/cheesesmithing/rainbow_bulwark" - | "/actions/cheesesmithing/rainbow_cheese" - | "/actions/cheesesmithing/rainbow_chisel" - | "/actions/cheesesmithing/rainbow_enhancer" - | "/actions/cheesesmithing/rainbow_gauntlets" - | "/actions/cheesesmithing/rainbow_hammer" - | "/actions/cheesesmithing/rainbow_hatchet" - | "/actions/cheesesmithing/rainbow_helmet" - | "/actions/cheesesmithing/rainbow_mace" - | "/actions/cheesesmithing/rainbow_needle" - | "/actions/cheesesmithing/rainbow_plate_body" - | "/actions/cheesesmithing/rainbow_plate_legs" - | "/actions/cheesesmithing/rainbow_pot" - | "/actions/cheesesmithing/rainbow_shears" - | "/actions/cheesesmithing/rainbow_spatula" - | "/actions/cheesesmithing/rainbow_spear" - | "/actions/cheesesmithing/rainbow_sword" - | "/actions/cheesesmithing/snail_shell_helmet" - | "/actions/cheesesmithing/snake_fang_dirk" - | "/actions/cheesesmithing/spiked_bulwark" - | "/actions/cheesesmithing/stalactite_spear" - | "/actions/cheesesmithing/turtle_shell_body" - | "/actions/cheesesmithing/turtle_shell_legs" - | "/actions/cheesesmithing/vampire_fang_dirk" - | "/actions/cheesesmithing/verdant_boots" - | "/actions/cheesesmithing/verdant_brush" - | "/actions/cheesesmithing/verdant_buckler" - | "/actions/cheesesmithing/verdant_bulwark" - | "/actions/cheesesmithing/verdant_cheese" - | "/actions/cheesesmithing/verdant_chisel" - | "/actions/cheesesmithing/verdant_enhancer" - | "/actions/cheesesmithing/verdant_gauntlets" - | "/actions/cheesesmithing/verdant_hammer" - | "/actions/cheesesmithing/verdant_hatchet" - | "/actions/cheesesmithing/verdant_helmet" - | "/actions/cheesesmithing/verdant_mace" - | "/actions/cheesesmithing/verdant_needle" - | "/actions/cheesesmithing/verdant_plate_body" - | "/actions/cheesesmithing/verdant_plate_legs" - | "/actions/cheesesmithing/verdant_pot" - | "/actions/cheesesmithing/verdant_shears" - | "/actions/cheesesmithing/verdant_spatula" - | "/actions/cheesesmithing/verdant_spear" - | "/actions/cheesesmithing/verdant_sword" - | "/actions/cheesesmithing/vision_helmet" - | "/actions/cheesesmithing/vision_shield" - | "/actions/cheesesmithing/werewolf_slasher" - | "/actions/combat/abyssal_imp" - | "/actions/combat/alligator" - | "/actions/combat/aqua_planet_elite" - | "/actions/combat/aqua_planet" - | "/actions/combat/aquahorse" - | "/actions/combat/bear_with_it_elite" - | "/actions/combat/bear_with_it" - | "/actions/combat/black_bear" - | "/actions/combat/centaur_archer" - | "/actions/combat/crab" - | "/actions/combat/elementalist" - | "/actions/combat/eye" - | "/actions/combat/eyes" - | "/actions/combat/flame_sorcerer" - | "/actions/combat/fly" - | "/actions/combat/frog" - | "/actions/combat/gobo_boomy" - | "/actions/combat/gobo_planet_elite" - | "/actions/combat/gobo_planet" - | "/actions/combat/gobo_shooty" - | "/actions/combat/gobo_slashy" - | "/actions/combat/gobo_smashy" - | "/actions/combat/gobo_stabby" - | "/actions/combat/golem_cave_elite" - | "/actions/combat/golem_cave" - | "/actions/combat/granite_golem" - | "/actions/combat/grizzly_bear" - | "/actions/combat/gummy_bear" - | "/actions/combat/ice_sorcerer" - | "/actions/combat/infernal_abyss_elite" - | "/actions/combat/infernal_abyss" - | "/actions/combat/infernal_warlock" - | "/actions/combat/jungle_planet_elite" - | "/actions/combat/jungle_planet" - | "/actions/combat/jungle_sprite" - | "/actions/combat/magnetic_golem" - | "/actions/combat/myconid" - | "/actions/combat/nom_nom" - | "/actions/combat/novice_sorcerer" - | "/actions/combat/panda" - | "/actions/combat/planet_of_the_eyes_elite" - | "/actions/combat/planet_of_the_eyes" - | "/actions/combat/polar_bear" - | "/actions/combat/porcupine" - | "/actions/combat/rat" - | "/actions/combat/sea_snail" - | "/actions/combat/skunk" - | "/actions/combat/slimy" - | "/actions/combat/smelly_planet_elite" - | "/actions/combat/smelly_planet" - | "/actions/combat/snake" - | "/actions/combat/sorcerers_tower_elite" - | "/actions/combat/sorcerers_tower" - | "/actions/combat/soul_hunter" - | "/actions/combat/stalactite_golem" - | "/actions/combat/swamp_planet_elite" - | "/actions/combat/swamp_planet" - | "/actions/combat/swampy" - | "/actions/combat/treant" - | "/actions/combat/turtle" - | "/actions/combat/twilight_zone_elite" - | "/actions/combat/twilight_zone" - | "/actions/combat/vampire" - | "/actions/combat/veyes" - | "/actions/combat/werewolf" - | "/actions/combat/zombie" - | "/actions/cooking/apple_gummy" - | "/actions/cooking/apple_yogurt" - | "/actions/cooking/blackberry_cake" - | "/actions/cooking/blackberry_donut" - | "/actions/cooking/blueberry_cake" - | "/actions/cooking/blueberry_donut" - | "/actions/cooking/cupcake" - | "/actions/cooking/donut" - | "/actions/cooking/dragon_fruit_gummy" - | "/actions/cooking/dragon_fruit_yogurt" - | "/actions/cooking/gummy" - | "/actions/cooking/marsberry_cake" - | "/actions/cooking/marsberry_donut" - | "/actions/cooking/mooberry_cake" - | "/actions/cooking/mooberry_donut" - | "/actions/cooking/orange_gummy" - | "/actions/cooking/orange_yogurt" - | "/actions/cooking/peach_gummy" - | "/actions/cooking/peach_yogurt" - | "/actions/cooking/plum_gummy" - | "/actions/cooking/plum_yogurt" - | "/actions/cooking/spaceberry_cake" - | "/actions/cooking/spaceberry_donut" - | "/actions/cooking/star_fruit_gummy" - | "/actions/cooking/star_fruit_yogurt" - | "/actions/cooking/strawberry_cake" - | "/actions/cooking/strawberry_donut" - | "/actions/cooking/yogurt" - | "/actions/crafting/advanced_task_ring" - | "/actions/crafting/arcane_bow" - | "/actions/crafting/arcane_crossbow" - | "/actions/crafting/arcane_fire_staff" - | "/actions/crafting/arcane_lumber" - | "/actions/crafting/arcane_nature_staff" - | "/actions/crafting/arcane_shield" - | "/actions/crafting/arcane_water_staff" - | "/actions/crafting/basic_task_ring" - | "/actions/crafting/birch_bow" - | "/actions/crafting/birch_crossbow" - | "/actions/crafting/birch_fire_staff" - | "/actions/crafting/birch_lumber" - | "/actions/crafting/birch_nature_staff" - | "/actions/crafting/birch_shield" - | "/actions/crafting/birch_water_staff" - | "/actions/crafting/cedar_bow" - | "/actions/crafting/cedar_crossbow" - | "/actions/crafting/cedar_fire_staff" - | "/actions/crafting/cedar_lumber" - | "/actions/crafting/cedar_nature_staff" - | "/actions/crafting/cedar_shield" - | "/actions/crafting/cedar_water_staff" - | "/actions/crafting/crushed_amber" - | "/actions/crafting/crushed_amethyst" - | "/actions/crafting/crushed_garnet" - | "/actions/crafting/crushed_jade" - | "/actions/crafting/crushed_moonstone" - | "/actions/crafting/crushed_pearl" - | "/actions/crafting/earrings_of_armor" - | "/actions/crafting/earrings_of_gathering" - | "/actions/crafting/earrings_of_rare_find" - | "/actions/crafting/earrings_of_regeneration" - | "/actions/crafting/earrings_of_resistance" - | "/actions/crafting/expert_task_ring" - | "/actions/crafting/eye_watch" - | "/actions/crafting/fighter_necklace" - | "/actions/crafting/frost_staff" - | "/actions/crafting/ginkgo_bow" - | "/actions/crafting/ginkgo_crossbow" - | "/actions/crafting/ginkgo_fire_staff" - | "/actions/crafting/ginkgo_lumber" - | "/actions/crafting/ginkgo_nature_staff" - | "/actions/crafting/ginkgo_shield" - | "/actions/crafting/ginkgo_water_staff" - | "/actions/crafting/infernal_battlestaff" - | "/actions/crafting/lumber" - | "/actions/crafting/mirror_of_protection" - | "/actions/crafting/necklace_of_efficiency" - | "/actions/crafting/necklace_of_wisdom" - | "/actions/crafting/purpleheart_bow" - | "/actions/crafting/purpleheart_crossbow" - | "/actions/crafting/purpleheart_fire_staff" - | "/actions/crafting/purpleheart_lumber" - | "/actions/crafting/purpleheart_nature_staff" - | "/actions/crafting/purpleheart_shield" - | "/actions/crafting/purpleheart_water_staff" - | "/actions/crafting/ranger_necklace" - | "/actions/crafting/redwood_bow" - | "/actions/crafting/redwood_crossbow" - | "/actions/crafting/redwood_fire_staff" - | "/actions/crafting/redwood_lumber" - | "/actions/crafting/redwood_nature_staff" - | "/actions/crafting/redwood_shield" - | "/actions/crafting/redwood_water_staff" - | "/actions/crafting/ring_of_armor" - | "/actions/crafting/ring_of_gathering" - | "/actions/crafting/ring_of_rare_find" - | "/actions/crafting/ring_of_regeneration" - | "/actions/crafting/ring_of_resistance" - | "/actions/crafting/soul_hunter_crossbow" - | "/actions/crafting/treant_shield" - | "/actions/crafting/vampiric_bow" - | "/actions/crafting/watchful_relic" - | "/actions/crafting/wizard_necklace" - | "/actions/crafting/wooden_bow" - | "/actions/crafting/wooden_crossbow" - | "/actions/crafting/wooden_fire_staff" - | "/actions/crafting/wooden_nature_staff" - | "/actions/crafting/wooden_shield" - | "/actions/crafting/wooden_water_staff" - | "/actions/enhancing/enhance" - | "/actions/foraging/apple" - | "/actions/foraging/arabica_coffee_bean" - | "/actions/foraging/asteroid_belt" - | "/actions/foraging/bamboo_branch" - | "/actions/foraging/blackberry" - | "/actions/foraging/blueberry" - | "/actions/foraging/burble_beach" - | "/actions/foraging/cocoon" - | "/actions/foraging/cotton" - | "/actions/foraging/dragon_fruit" - | "/actions/foraging/egg" - | "/actions/foraging/excelsa_coffee_bean" - | "/actions/foraging/farmland" - | "/actions/foraging/fieriosa_coffee_bean" - | "/actions/foraging/flax" - | "/actions/foraging/liberica_coffee_bean" - | "/actions/foraging/marsberry" - | "/actions/foraging/misty_forest" - | "/actions/foraging/mooberry" - | "/actions/foraging/olympus_mons" - | "/actions/foraging/orange" - | "/actions/foraging/peach" - | "/actions/foraging/plum" - | "/actions/foraging/radiant_fiber" - | "/actions/foraging/robusta_coffee_bean" - | "/actions/foraging/shimmering_lake" - | "/actions/foraging/silly_cow_valley" - | "/actions/foraging/spaceberry" - | "/actions/foraging/spacia_coffee_bean" - | "/actions/foraging/star_fruit" - | "/actions/foraging/strawberry" - | "/actions/foraging/sugar" - | "/actions/foraging/wheat" - | "/actions/milking/azure_cow" - | "/actions/milking/burble_cow" - | "/actions/milking/cow" - | "/actions/milking/crimson_cow" - | "/actions/milking/holy_cow" - | "/actions/milking/unicow" - | "/actions/milking/verdant_cow" - | "/actions/tailoring/bamboo_boots" - | "/actions/tailoring/bamboo_fabric" - | "/actions/tailoring/bamboo_gloves" - | "/actions/tailoring/bamboo_hat" - | "/actions/tailoring/bamboo_robe_bottoms" - | "/actions/tailoring/bamboo_robe_top" - | "/actions/tailoring/beast_boots" - | "/actions/tailoring/beast_bracers" - | "/actions/tailoring/beast_chaps" - | "/actions/tailoring/beast_hood" - | "/actions/tailoring/beast_leather" - | "/actions/tailoring/beast_tunic" - | "/actions/tailoring/centaur_boots" - | "/actions/tailoring/chrono_gloves" - | "/actions/tailoring/collectors_boots" - | "/actions/tailoring/cotton_boots" - | "/actions/tailoring/cotton_fabric" - | "/actions/tailoring/cotton_gloves" - | "/actions/tailoring/cotton_hat" - | "/actions/tailoring/cotton_robe_bottoms" - | "/actions/tailoring/cotton_robe_top" - | "/actions/tailoring/enchanted_gloves" - | "/actions/tailoring/flaming_robe_bottoms" - | "/actions/tailoring/flaming_robe_top" - | "/actions/tailoring/fluffy_red_hat" - | "/actions/tailoring/giant_pouch" - | "/actions/tailoring/gobo_boots" - | "/actions/tailoring/gobo_bracers" - | "/actions/tailoring/gobo_chaps" - | "/actions/tailoring/gobo_hood" - | "/actions/tailoring/gobo_leather" - | "/actions/tailoring/gobo_tunic" - | "/actions/tailoring/icy_robe_bottoms" - | "/actions/tailoring/icy_robe_top" - | "/actions/tailoring/large_pouch" - | "/actions/tailoring/linen_boots" - | "/actions/tailoring/linen_fabric" - | "/actions/tailoring/linen_gloves" - | "/actions/tailoring/linen_hat" - | "/actions/tailoring/linen_robe_bottoms" - | "/actions/tailoring/linen_robe_top" - | "/actions/tailoring/luna_robe_bottoms" - | "/actions/tailoring/luna_robe_top" - | "/actions/tailoring/marine_chaps" - | "/actions/tailoring/marine_tunic" - | "/actions/tailoring/medium_pouch" - | "/actions/tailoring/radiant_boots" - | "/actions/tailoring/radiant_fabric" - | "/actions/tailoring/radiant_gloves" - | "/actions/tailoring/radiant_hat" - | "/actions/tailoring/radiant_robe_bottoms" - | "/actions/tailoring/radiant_robe_top" - | "/actions/tailoring/red_chefs_hat" - | "/actions/tailoring/reptile_boots" - | "/actions/tailoring/reptile_bracers" - | "/actions/tailoring/reptile_chaps" - | "/actions/tailoring/reptile_hood" - | "/actions/tailoring/reptile_leather" - | "/actions/tailoring/reptile_tunic" - | "/actions/tailoring/revenant_chaps" - | "/actions/tailoring/revenant_tunic" - | "/actions/tailoring/rough_boots" - | "/actions/tailoring/rough_bracers" - | "/actions/tailoring/rough_chaps" - | "/actions/tailoring/rough_hood" - | "/actions/tailoring/rough_leather" - | "/actions/tailoring/rough_tunic" - | "/actions/tailoring/shoebill_shoes" - | "/actions/tailoring/sighted_bracers" - | "/actions/tailoring/silk_boots" - | "/actions/tailoring/silk_fabric" - | "/actions/tailoring/silk_gloves" - | "/actions/tailoring/silk_hat" - | "/actions/tailoring/silk_robe_bottoms" - | "/actions/tailoring/silk_robe_top" - | "/actions/tailoring/small_pouch" - | "/actions/tailoring/sorcerer_boots" - | "/actions/tailoring/umbral_boots" - | "/actions/tailoring/umbral_bracers" - | "/actions/tailoring/umbral_chaps" - | "/actions/tailoring/umbral_hood" - | "/actions/tailoring/umbral_leather" - | "/actions/tailoring/umbral_tunic" - | "/actions/woodcutting/arcane_tree" - | "/actions/woodcutting/birch_tree" - | "/actions/woodcutting/cedar_tree" - | "/actions/woodcutting/ginkgo_tree" - | "/actions/woodcutting/purpleheart_tree" - | "/actions/woodcutting/redwood_tree" - | "/actions/woodcutting/tree"; +export enum ActionHrid {} diff --git a/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPlugin.ts b/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPlugin.ts index 86b9375..920b194 100644 --- a/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPlugin.ts +++ b/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPlugin.ts @@ -9,6 +9,7 @@ import { CharacterAction } from "src/MooLite/core/actions/CharacterAction"; import { ItemGained } from "src/MooLite/core/inventory/Inventory"; import { ItemHashParts, decodeItemHash } from "src/MooLite/core/inventory/items/decodeItemHash"; import { ItemAmount } from "src/MooLite/core/inventory/items/ItemAmount"; +import { ActionHrid } from "src/MooLite/core/actions/ActionHrid"; export class EnhancingTrackerPlugin extends MooLitePlugin { name: string = "Enhancing Tracker"; @@ -51,20 +52,16 @@ export class EnhancingTrackerPlugin extends MooLitePlugin { onActionQueueUpdated(queue: CharacterAction[]): void { const currentAction = queue.length ? queue[0] : null; - if (currentAction !== null) { - if ( - currentAction.actionHrid === "/actions/enhancing/enhance" && - !(this.previousAction?.actionHrid === "/actions/enhancing/enhance") - ) { - this.handleStartedEnhancing(currentAction); - } - if ( - currentAction.actionHrid === "/actions/enhancing/enhance" && - this.previousAction?.actionHrid === "/actions/enhancing/enhance" - ) { - this.handleEnhancing(currentAction); - } + const currentActionIsEnhancing = + currentAction?.actionHrid === ("/actions/enhancing/enhance" as unknown as ActionHrid); + const previousActionIsEnhancing = + this.previousAction?.actionHrid === ("/actions/enhancing/enhance" as unknown as ActionHrid); + + if (currentActionIsEnhancing) { + previousActionIsEnhancing + ? this.handleEnhancing(currentAction) + : this.handleStartedEnhancing(currentAction); } this.previousAction = currentAction; From 0a77f83b9c457e5a60ad7a5630606e47075f99eb Mon Sep 17 00:00:00 2001 From: Nathan S Date: Sun, 11 Feb 2024 22:09:38 +0000 Subject: [PATCH 4/6] DRY --- .../plugins/EnhancingTracker/EnhancingTrackerPlugin.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPlugin.ts b/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPlugin.ts index 920b194..4176945 100644 --- a/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPlugin.ts +++ b/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPlugin.ts @@ -53,10 +53,9 @@ export class EnhancingTrackerPlugin extends MooLitePlugin { onActionQueueUpdated(queue: CharacterAction[]): void { const currentAction = queue.length ? queue[0] : null; - const currentActionIsEnhancing = - currentAction?.actionHrid === ("/actions/enhancing/enhance" as unknown as ActionHrid); - const previousActionIsEnhancing = - this.previousAction?.actionHrid === ("/actions/enhancing/enhance" as unknown as ActionHrid); + const enhancing = "/actions/enhancing/enhance" as unknown as ActionHrid; + const currentActionIsEnhancing = currentAction?.actionHrid === enhancingHrid; + const previousActionIsEnhancing = this.previousAction?.actionHrid === enhancingHrid; if (currentActionIsEnhancing) { previousActionIsEnhancing From 2b572590785c0c59bbd2ebe3d1816712a7e3e54d Mon Sep 17 00:00:00 2001 From: Nathan S Date: Sun, 11 Feb 2024 22:10:29 +0000 Subject: [PATCH 5/6] Weird that that didn't error --- .../plugins/EnhancingTracker/EnhancingTrackerPlugin.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPlugin.ts b/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPlugin.ts index 4176945..8526d67 100644 --- a/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPlugin.ts +++ b/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPlugin.ts @@ -6,7 +6,6 @@ import { PluginAuthorCredits } from "src/MooLite/core/plugins/PluginAuthorCredit import { ItemDetail } from "src/MooLite/core/inventory/items/ItemDetail"; import { ItemHrid } from "src/MooLite/core/inventory/ItemHrid"; import { CharacterAction } from "src/MooLite/core/actions/CharacterAction"; -import { ItemGained } from "src/MooLite/core/inventory/Inventory"; import { ItemHashParts, decodeItemHash } from "src/MooLite/core/inventory/items/decodeItemHash"; import { ItemAmount } from "src/MooLite/core/inventory/items/ItemAmount"; import { ActionHrid } from "src/MooLite/core/actions/ActionHrid"; @@ -54,8 +53,8 @@ export class EnhancingTrackerPlugin extends MooLitePlugin { const currentAction = queue.length ? queue[0] : null; const enhancing = "/actions/enhancing/enhance" as unknown as ActionHrid; - const currentActionIsEnhancing = currentAction?.actionHrid === enhancingHrid; - const previousActionIsEnhancing = this.previousAction?.actionHrid === enhancingHrid; + const currentActionIsEnhancing = currentAction?.actionHrid === enhancing; + const previousActionIsEnhancing = this.previousAction?.actionHrid === enhancing; if (currentActionIsEnhancing) { previousActionIsEnhancing From 763fa5a639debe6dc042926266037042d6c99c99 Mon Sep 17 00:00:00 2001 From: Nathan S Date: Sun, 11 Feb 2024 22:16:43 +0000 Subject: [PATCH 6/6] Fix some rendering - numbers didn't look quite right --- .../EnhancingTracker/EnhancingTrackerPlugin.ts | 14 ++++---------- .../EnhancingTrackerPluginDisplay.vue | 5 ++++- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPlugin.ts b/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPlugin.ts index 8526d67..8a334b7 100644 --- a/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPlugin.ts +++ b/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPlugin.ts @@ -42,11 +42,7 @@ export class EnhancingTrackerPlugin extends MooLitePlugin { public get successRate(): number { const attempts = this.successes + this.failures; - if (attempts === 0) { - return 100; - } - - return (this.successes / (this.successes + this.failures)) * 100; + return attempts === 0 ? 0 : (this.successes / attempts) * 100; } onActionQueueUpdated(queue: CharacterAction[]): void { @@ -74,11 +70,9 @@ export class EnhancingTrackerPlugin extends MooLitePlugin { } addConsumedItem(itemAmount: ItemAmount): void { - if (itemAmount.itemHrid in this.itemsConsumed) { - this.itemsConsumed[itemAmount.itemHrid] += itemAmount.count; - } else { - this.itemsConsumed[itemAmount.itemHrid] = itemAmount.count; - } + itemAmount.itemHrid in this.itemsConsumed + ? (this.itemsConsumed[itemAmount.itemHrid] += itemAmount.count) + : (this.itemsConsumed[itemAmount.itemHrid] = itemAmount.count); } handleEnhancing(currentAction: CharacterAction): void { diff --git a/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPluginDisplay.vue b/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPluginDisplay.vue index db25a57..f4b5095 100644 --- a/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPluginDisplay.vue +++ b/src/MooLite/plugins/EnhancingTracker/EnhancingTrackerPluginDisplay.vue @@ -39,7 +39,10 @@ const loot: Ref = ref([]);

Best enhancement level: {{ plugin.bestEnhancementLevel }}

-

Success rate: {{ plugin.successRate.toFixed(2) }}% ({{ plugin.successes }} / {{ plugin.failures }})

+

+ Success rate: {{ plugin.successRate.toFixed(2) }}% ({{ plugin.successes }} / + {{ plugin.successes + plugin.failures }}) +