From c6fd094ab8023588fd9369fe8e959b223d2ec312 Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Tue, 3 Sep 2024 03:52:51 -0400 Subject: [PATCH] Fix: El Dorado and Stray Rabbit Horde patterns (#2450) --- .../ChocolateFactoryStrayTracker.kt | 49 +++++++------------ 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStrayTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStrayTracker.kt index e8ad465cdf6e..89b8355be153 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStrayTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStrayTracker.kt @@ -17,8 +17,10 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzRarity import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NumberUtil.formatLong +import at.hannibal2.skyhanni.utils.RegexUtils.groupOrNull import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matches +import at.hannibal2.skyhanni.utils.StringUtils.removeResets import at.hannibal2.skyhanni.utils.TimeUtils.format import at.hannibal2.skyhanni.utils.renderables.Renderable import at.hannibal2.skyhanni.utils.tracker.SkyHanniTracker @@ -64,26 +66,21 @@ object ChocolateFactoryStrayTracker { /** * REGEX-TEST: §7You caught a stray §6§lGolden Rabbit§7! §7You caught a glimpse of §6El Dorado§7, §7but he escaped and left behind §7§6313,780 Chocolate§7! - */ - private val goldenStrayDoradoEscape by ChocolateFactoryAPI.patternGroup.pattern( - "stray.goldendoradoescape", - "§7You caught a stray §6§lGolden Rabbit§7! §7You caught a glimpse of §6El Dorado§7, §7but he escaped and left behind §7§6\\+(?[\\d,]*) Chocolate§7!", - ) - - /** * REGEX-TEST: §7You caught a stray §6§lGolden Rabbit§7! §7You caught §6El Dorado §7- quite the elusive rabbit! + * REGEX-TEST: §7You caught a stray §6§lGolden Rabbit§7! §7You caught §6El Dorado§7! Since you §7already have captured him before, §7you gained §6+324,364,585 Chocolate§7. */ - private val goldenStrayDoradoCaught by ChocolateFactoryAPI.patternGroup.pattern( - "stray.goldendoradocaught", - "§7You caught a stray §6§lGolden Rabbit§7! §7You caught §6El Dorado §7- quite the elusive rabbit!", + private val strayDoradoPattern by ChocolateFactoryAPI.patternGroup.pattern( + "stray.dorado", + ".*§6El Dorado(?:.*?§6\\+?(?[\\d,]+) Chocolate)?.*", ) /** - * REGEX-TEST: §7You caught a stray §6§lGolden Rabbit§7! §7You caught §6El Dorado§7! Since you §7already have captured him before, §7you gained §6+324,364,585 Chocolate§7. + * REGEX-TEST: §7A hoard of §aStray Rabbits §7has appeared! + * REGEX-TEST: §r§7A hoard of §r§aStray Rabbits §r§7has appeared! */ - private val goldenStrayDoradoDuplicate by ChocolateFactoryAPI.patternGroup.pattern( - "stray.goldendoradoduplicate", - "§7You caught a stray §6§lGolden Rabbit§7! §7You caught §6El Dorado§7! Since you §7already have captured him before, §7you gained §6\\+(?[\\d,]*) Chocolate§7.", + private val strayHoardPattern by ChocolateFactoryAPI.patternGroup.pattern( + "stray.hoard", + ".*(?:§r)?§7A hoard of (?:§r)?§aStray Rabbits (?:§r)?§7has.*", ) /** @@ -248,28 +245,16 @@ object ChocolateFactoryStrayTracker { } // Golden Strays, hoard/stampede - if (loreLine == "§7You caught a stray §6§lGolden Rabbit§7! §7A hoard of §aStray Rabbits §7has appeared!") { + strayHoardPattern.matchMatcher(loreLine.removeResets()) { incrementGoldenType("stampede") } - // Golden Strays, El Dorado "glimpse" - 1/3 before capture - goldenStrayDoradoEscape.matchMatcher(loreLine) { - incrementRarity("legendary", group("amount").formatLong()) - incrementGoldenType("dorado") - } - - // Golden Strays, El Dorado caught - 3/3 - if (goldenStrayDoradoCaught.matches(loreLine)) { - incrementRarity("legendary") - tracker.modify { t -> t.goldenTypesCaught["dorado"] = 3 } - } - - // Golden Strays, El Dorado (duplicate catch) - goldenStrayDoradoDuplicate.matchMatcher(loreLine) { - incrementRarity("legendary", group("amount").formatLong()) - tracker.modify { t -> - t.goldenTypesCaught["dorado"] = t.goldenTypesCaught["dorado"]?.plus(1) ?: 4 + // El Dorado - all catches + strayDoradoPattern.matchMatcher(loreLine) { + groupOrNull("amount")?.let { amount -> + incrementRarity("legendary", amount.formatLong()) } + incrementGoldenType("dorado") } } }