diff options
author | martimavocado <39881008+martimavocado@users.noreply.github.com> | 2024-04-27 12:19:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-27 13:19:32 +0200 |
commit | 80cfdbefef4c19fe952a2913b7a465efbddfcecf (patch) | |
tree | d7e4380afb77145b9815e4ef326fa125edcf5ec7 /src/main/java/at/hannibal2 | |
parent | 6bb7d33f40ab6b074c7ae3c30d9613fa3e42edf4 (diff) | |
download | skyhanni-80cfdbefef4c19fe952a2913b7a465efbddfcecf.tar.gz skyhanni-80cfdbefef4c19fe952a2913b7a465efbddfcecf.tar.bz2 skyhanni-80cfdbefef4c19fe952a2913b7a465efbddfcecf.zip |
Backend: Add blessings to DungeonAPI (#1326)
Co-authored-by: Cal <cwolfson58@gmail.com>
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt | 51 |
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}") } } |