aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-09-26 10:25:40 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-09-26 10:25:40 +0200
commit768cb23a7fd6aa82af60129f7f3c9d17169f16bd (patch)
tree8fcb09ec3368ec49ec2e75c0aab8e39f3f86d1f4
parent7e1b3cab73cb3f1c6131db3125736af86daa0e30 (diff)
downloadskyhanni-768cb23a7fd6aa82af60129f7f3c9d17169f16bd.tar.gz
skyhanni-768cb23a7fd6aa82af60129f7f3c9d17169f16bd.tar.bz2
skyhanni-768cb23a7fd6aa82af60129f7f3c9d17169f16bd.zip
showing mm floor in rcp
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt29
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt14
2 files changed, 15 insertions, 28 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 4d00de168..fa627eec0 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt
@@ -3,7 +3,6 @@ package at.hannibal2.skyhanni.features.dungeon
import at.hannibal2.skyhanni.data.ProfileStorageData
import at.hannibal2.skyhanni.data.ScoreboardData
import at.hannibal2.skyhanni.events.*
-import at.hannibal2.skyhanni.features.dungeon.DungeonAPI.DungeonFloor.Companion.toFloor
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
@@ -39,7 +38,6 @@ class DungeonAPI {
var isUniqueClass = false
val bossStorage: MutableMap<DungeonFloor, Int>? get() = ProfileStorageData.profileSpecific?.dungeons?.bosses
- private val areaPattern = "The Catacombs \\((?<floor>.+)\\)".toPattern()
private val timePattern =
"Time Elapsed:( )?(?:(?<minutes>\\d+)m)? (?<seconds>\\d+)s".toPattern() // Examples: Time Elapsed: 10m 10s, Time Elapsed: 2s
@@ -76,14 +74,6 @@ class DungeonAPI {
return bossName.endsWith(correctBoss)
}
- fun getFloor(): Int? {
- val area = LorenzUtils.skyBlockArea
- areaPattern.matchMatcher(area) {
- if (matches()) return group("floor").last().digitToInt()
- }
- return null
- }
-
fun getTime(): String {
loop@ for (line in ScoreboardData.sidebarLinesFormatted) {
timePattern.matchMatcher(line.removeColor()) {
@@ -93,6 +83,11 @@ class DungeonAPI {
}
return ""
}
+
+ fun getCurrentBoss(): DungeonFloor? {
+ val floor = dungeonFloor ?: return null
+ return DungeonFloor.valueOf(floor.replace("M", "F"))
+ }
}
@SubscribeEvent
@@ -168,7 +163,7 @@ class DungeonAPI {
item.getLore().getOrNull(0)?.let { firstLine ->
if (firstLine == "ยง7To Boss Collections") {
val name = inventoryName.split(" ").dropLast(1).joinToString(" ")
- val floor = name.toFloor() ?: return
+ val floor = DungeonFloor.byBossName(name) ?: return
val lore = inventoryItems[4]?.getLore() ?: return
val line = lore.find { it.contains("Total Kills:") } ?: return
val kills = totalKillsPattern.matchMatcher(line) {
@@ -202,7 +197,7 @@ class DungeonAPI {
}
}
}
- val floor = name.toFloor() ?: continue
+ val floor = DungeonFloor.byBossName(name) ?: continue
bossCollections[floor] = kills
}
}
@@ -212,7 +207,7 @@ class DungeonAPI {
if (!LorenzUtils.inDungeons) return
killPattern.matchMatcher(event.message.removeColor()) {
val bossCollections = bossStorage ?: return
- val boss = group("boss").toFloor()
+ val boss = DungeonFloor.byBossName(group("boss"))
if (matches() && boss != null && boss !in bossCollections) {
bossCollections.addOrPut(boss, 1)
}
@@ -230,13 +225,7 @@ class DungeonAPI {
F7("Necron");
companion object {
- fun Int.toBoss(): DungeonFloor {
- return entries[this]
- }
-
- fun String.toFloor(): DungeonFloor? {
- return entries.firstOrNull { it.bossName == this }
- }
+ fun byBossName(bossName: String) = DungeonFloor.entries.firstOrNull { it.bossName == bossName }
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt
index b07fc5eb1..3537e2406 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt
@@ -9,8 +9,6 @@ import at.hannibal2.skyhanni.data.GardenCropMilestones.getTierForCropCount
import at.hannibal2.skyhanni.data.GardenCropMilestones.isMaxed
import at.hannibal2.skyhanni.data.GardenCropMilestones.progressToNextLevel
import at.hannibal2.skyhanni.features.dungeon.DungeonAPI
-import at.hannibal2.skyhanni.features.dungeon.DungeonAPI.DungeonFloor
-import at.hannibal2.skyhanni.features.dungeon.DungeonAPI.DungeonFloor.Companion.toBoss
import at.hannibal2.skyhanni.features.garden.GardenAPI.getCropType
import at.hannibal2.skyhanni.features.rift.RiftAPI
import at.hannibal2.skyhanni.utils.InventoryUtils
@@ -351,14 +349,14 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?)
}),
DUNGEONS({
- val floor = DungeonAPI.getFloor() ?: -1 // -1 if not in dungeons/failed to find a floor
- val boss: DungeonFloor? = if (floor != -1) floor.toBoss() else null
- if (floor == -1) AutoStatus.DUNGEONS.placeholderText
- else if (boss == null) "Unknown boss"
- else {
+ val boss = DungeonAPI.getCurrentBoss()
+ if (boss == null) {
+ "Unknown boss"
+ } else {
+ val floor = DungeonAPI.dungeonFloor ?: AutoStatus.DUNGEONS.placeholderText
val amountKills = DungeonAPI.bossStorage?.get(boss)?.addSeparators() ?: "Unknown"
val time = DungeonAPI.getTime()
- "$boss Kills: $amountKills ($time)"
+ "$floor Kills: $amountKills ($time)"
}
})
;