aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt
index 264f31bf2..c9e17ee04 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt
@@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
+import at.hannibal2.skyhanni.events.TablistFooterUpdateEvent
import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut
import at.hannibal2.skyhanni.utils.CollectionUtils.equalsOneOf
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
@@ -22,6 +23,7 @@ import at.hannibal2.skyhanni.utils.NumberUtil.formatInt
import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary
import at.hannibal2.skyhanni.utils.StringUtils.matchFirst
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.StringUtils.matches
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.TabListData
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
@@ -62,6 +64,28 @@ object DungeonAPI {
"room",
"§7\\d+\\/\\d+\\/\\d+ §\\w+ (?<roomId>[\\w,-]+)"
)
+ private val blessingPattern by patternGroup.pattern(
+ "blessings",
+ "§r§r§fBlessing of (?<type>\\w+) (?<amount>\\w+)§r"
+ )
+ private val noBlessingPattern by patternGroup.pattern(
+ "noblessings",
+ "§r§r§7No Buffs active. Find them by exploring the Dungeon!§r"
+ )
+
+ enum class DungeonBlessings(var power: Int) {
+ LIFE(0),
+ POWER(0),
+ STONE(0),
+ WISDOM(0),
+ TIME(0);
+
+ companion object {
+ fun reset() {
+ entries.forEach { it.power = 0 }
+ }
+ }
+ }
fun inDungeon() = IslandType.CATACOMBS.isInIsland()
@@ -152,6 +176,26 @@ object DungeonAPI {
}
@SubscribeEvent
+ fun onTabUpdate(event: TablistFooterUpdateEvent) {
+ if (!inDungeon()) return
+ val tabList = event.footer.split("\n")
+ tabList.forEach {
+ if (noBlessingPattern.matches(it)) {
+ DungeonBlessings.reset()
+ return
+ }
+ val matcher = blessingPattern.matcher(it)
+ if (matcher.find()) {
+ val type = matcher.group("type") ?: return@forEach
+ val amount = matcher.group("amount").romanToDecimalIfNecessary()
+ if (DungeonBlessings.valueOf(type.uppercase()).power != amount) {
+ DungeonBlessings.valueOf(type.uppercase()).power = amount
+ }
+ }
+ }
+ }
+
+ @SubscribeEvent
fun onWorldChange(event: LorenzWorldChangeEvent) {
dungeonFloor = null
started = false
@@ -159,6 +203,7 @@ object DungeonAPI {
isUniqueClass = false
playerClass = null
playerClassLevel = -1
+ DungeonBlessings.reset()
}
@SubscribeEvent
@@ -266,6 +311,12 @@ object DungeonAPI {
add("playerClass: $playerClass")
add("isUniqueClass: $isUniqueClass")
add("playerClassLevel: $playerClassLevel")
+ add("")
+ add("Life: ${DungeonBlessings.LIFE.power}")
+ add("Stone: ${DungeonBlessings.STONE.power}")
+ add("Wisdom: ${DungeonBlessings.WISDOM.power}")
+ add("Power: ${DungeonBlessings.POWER.power}")
+ add("Time: ${DungeonBlessings.TIME.power}")
}
}