diff options
author | David Cole <40234707+DavidArthurCole@users.noreply.github.com> | 2024-06-14 20:54:21 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-15 02:54:21 +0200 |
commit | e0f3a5e3f5e1c0361d3f96ede45d7fe069d072d6 (patch) | |
tree | 8e9b578be2ddd9c87056394b8f5ddb2aa8659899 /src/main/java | |
parent | ae03a7f85cc09ddda3bb7c34de51670b61c56e4b (diff) | |
download | skyhanni-e0f3a5e3f5e1c0361d3f96ede45d7fe069d072d6.tar.gz skyhanni-e0f3a5e3f5e1c0361d3f96ede45d7fe069d072d6.tar.bz2 skyhanni-e0f3a5e3f5e1c0361d3f96ede45d7fe069d072d6.zip |
Fix: Compact Hoppity Chat for Purchased Rabbits (#2100)
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsCompactChat.kt | 24 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt | 9 |
2 files changed, 30 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsCompactChat.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsCompactChat.kt index a0a42c767..9420676d5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsCompactChat.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsCompactChat.kt @@ -23,6 +23,7 @@ object HoppityEggsCompactChat { private var newRabbit = false private var lastChatMeal: HoppityEggType? = null private var lastDuplicateAmount: Long? = null + private var rabbitBought = false private val config get() = ChocolateFactoryAPI.config fun compactChat(event: LorenzChatEvent, lastDuplicateAmount: Long? = null) { @@ -58,21 +59,23 @@ object HoppityEggsCompactChat { this.lastProfit = "" this.lastChatMeal = null this.lastDuplicateAmount = null + this.rabbitBought = false } private fun createCompactMessage(): String { val mealName = lastChatMeal?.coloredName ?: "" + val mealNameFormatted = if (rabbitBought) "§aBought Rabbit" else "$mealName Egg" return if (duplicate) { - val format = lastDuplicateAmount?.let { it.shortFormat() } ?: "?" + val format = lastDuplicateAmount?.shortFormat() ?: "?" val timeFormatted = lastDuplicateAmount?.let { ChocolateFactoryAPI.timeUntilNeed(it).format(maxUnits = 2) } ?: "?" val timeStr = if (config.showDuplicateTime) ", §a+§b$timeFormatted§7" else "" - "$mealName Egg! §7Duplicate $lastName §7(§6+$format Chocolate§7$timeStr)" + "$mealNameFormatted! §7Duplicate $lastName §7(§6+$format Chocolate§7$timeStr)" } else if (newRabbit) { - "$mealName Egg! §d§lNEW $lastName §7(${lastProfit}§7)" + "$mealNameFormatted! §d§lNEW $lastName §7(${lastProfit}§7)" } else "?" } @@ -83,11 +86,26 @@ object HoppityEggsCompactChat { compactChat(event) } + HoppityEggsManager.eggBoughtPattern.matchMatcher(event.message) { + rabbitBought = true + compactChat(event) + } + HoppityEggsManager.rabbitFoundPattern.matchMatcher(event.message) { + // The only case where "You found ..." will come in with more than 1 message, + // or empty for hoppityEggChat, is where the rabbit was purchased from hoppity + // in this case, we want to reset variables to a clean state during this capture, + // as the important capture for the purchased message is the final message in + // the chain; "You found [rabbit]" -> "Dupe/New Rabbit" -> "You bought [rabbit]" + if (hoppityEggChat.isEmpty() || hoppityEggChat.size > 1) { + resetCompactData() + } + lastName = group("name") lastRarity = group("rarity") compactChat(event) } + HoppityEggsManager.newRabbitFound.matchMatcher(event.message) { val chocolate = groupOrNull("chocolate") val perSecond = group("perSecond") diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt index 800167460..0640bfff2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt @@ -45,6 +45,15 @@ object HoppityEggsManager { ) /** + * REGEX-TEST: §aYou bought §r§9Casanova §r§afor §r§6970,000 Coins§r§a! + * REGEX-TEST: §aYou bought §r§fHeidie §r§afor §r§6194,000 Coins§r§a! + */ + val eggBoughtPattern by ChocolateFactoryAPI.patternGroup.pattern( + "egg.bought", + "§aYou bought §r§.(?<rabbitname>.*?) §r§afor §r§6((\\d|,)*) Coins§r§a!" + ) + + /** * REGEX-TEST: §D§LHOPPITY'S HUNT §7You found §fArnie §7(§F§LCOMMON§7)! * REGEX-TEST: §D§LHOPPITY'S HUNT §7You found §aPenelope §7(§A§LUNCOMMON§7)! * REGEX-TEST: §D§LHOPPITY'S HUNT §7You found §6Solomon §7(§6§LLEGENDARY§7)! |