Skip to content

Commit

Permalink
Fix: El Dorado HoppityAPI (#2742)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidArthurCole authored Oct 16, 2024
1 parent 707959f commit d8a4d6c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactor
import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryStrayTracker
import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryStrayTracker.duplicateDoradoStrayPattern
import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryStrayTracker.duplicatePseudoStrayPattern
import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryStrayTracker.formLoreToSingleLine
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
Expand Down Expand Up @@ -117,16 +118,19 @@ object HoppityAPI {
duplicate = it.stack.getLore().any { line -> duplicatePseudoStrayPattern.matches(line) }
attemptFireRabbitFound()
}
"El Dorado" -> {
EggFoundEvent(STRAY, it.slotNumber).post()
lastName = "§6El Dorado"
lastMeal = STRAY
duplicate = it.stack.getLore().any { line -> duplicateDoradoStrayPattern.matches(line) }
attemptFireRabbitFound()
}
else -> return@matchMatcher
}
}
ChocolateFactoryStrayTracker.strayDoradoPattern.matchMatcher(formLoreToSingleLine(it.stack.getLore())) {
// We don't need to do a handleStrayClicked here - the lore from El Dorado is already:
// §6§lGolden Rabbit §d§lCAUGHT!
// Which will trigger the above matcher. We only need to check name here to fire the found event for Dorado.
EggFoundEvent(STRAY, it.slotNumber).post()
lastName = "§6El Dorado"
lastMeal = STRAY
duplicate = it.stack.getLore().any { line -> duplicateDoradoStrayPattern.matches(line) }
attemptFireRabbitFound()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ object ChocolateFactoryStrayTracker {
* 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 strayDoradoPattern by ChocolateFactoryAPI.patternGroup.pattern(
val strayDoradoPattern by ChocolateFactoryAPI.patternGroup.pattern(
"stray.dorado",
".*§6El Dorado(?:.*?§6\\+?(?<amount>[\\d,]+) Chocolate)?.*",
)
Expand Down Expand Up @@ -147,7 +147,7 @@ object ChocolateFactoryStrayTracker {
var goldenTypesCaught: MutableMap<String, Int> = mutableMapOf()
}

private fun formLoreToSingleLine(lore: List<String>): String {
fun formLoreToSingleLine(lore: List<String>): String {
val notEmptyLines = lore.filter { it.isNotEmpty() }
return notEmptyLines.joinToString(" ")
}
Expand Down

0 comments on commit d8a4d6c

Please sign in to comment.