From a6b7559cec69bda9e8202de6440da784d3f8925a Mon Sep 17 00:00:00 2001 From: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> Date: Fri, 2 Aug 2024 10:56:49 +0200 Subject: Fix: HotmData Level Detection with Blue Egg (#2295) --- src/main/java/at/hannibal2/skyhanni/data/HotmData.kt | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/data/HotmData.kt') diff --git a/src/main/java/at/hannibal2/skyhanni/data/HotmData.kt b/src/main/java/at/hannibal2/skyhanni/data/HotmData.kt index c66d2fa84..e82ddd4ae 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HotmData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HotmData.kt @@ -357,16 +357,16 @@ enum class HotmData( val printName = name.allLettersFirstUppercase() - /** Level which are actually paid with powder (does exclude [blueEgg]*/ - val rawLevel: Int + /** Level which are actually paid with powder (does exclude [blueEgg])*/ + var rawLevel: Int get() = storage?.perks?.get(this.name)?.level ?: 0 + private set(value) { + storage?.perks?.computeIfAbsent(this.name) { HotmTree.HotmPerk() }?.level = value + } /** Level for which the effect that is present (considers [enabled] and [blueEgg])*/ - var activeLevel: Int + val activeLevel: Int get() = if (enabled) effectivLevel else 0 - private set(value) { - storage?.perks?.computeIfAbsent(this.name) { HotmTree.HotmPerk() }?.level = value.minus(blueEgg()) - } /** Level that considering [blueEgg]*/ val effectivLevel: Int get() = storage?.perks?.get(this.name)?.level?.plus(blueEgg()) ?: 0 @@ -524,7 +524,7 @@ enum class HotmData( fun getPerkByNameOrNull(name: String): HotmData? = entries.find { it.guiName == name } private fun resetTree() = entries.forEach { - it.activeLevel = 0 + it.rawLevel = 0 it.enabled = false it.isUnlocked = false HotmAPI.Powder.entries.forEach { it.setCurrent(it.getTotal()) } @@ -542,7 +542,7 @@ enum class HotmData( val lore = item.getLore().takeIf { it.isNotEmpty() } ?: return if (entry != PEAK_OF_THE_MOUNTAIN && notUnlockedPattern.matches(lore.last())) { - entry.activeLevel = 0 + entry.rawLevel = 0 entry.enabled = false entry.isUnlocked = false return @@ -550,7 +550,7 @@ enum class HotmData( entry.isUnlocked = true - entry.activeLevel = levelPattern.matchMatcher(lore.first()) { + entry.rawLevel = levelPattern.matchMatcher(lore.first()) { group("level").toInt().transformIf({ group("color") == "b" }, { this.minus(1) }) } ?: entry.maxLevel @@ -681,7 +681,7 @@ enum class HotmData( DelayedRun.runNextTick { InventoryUtils.getItemsInOpenChest().forEach { it.parse() } abilities.filter { it.isUnlocked }.forEach { - it.activeLevel = if (PEAK_OF_THE_MOUNTAIN.rawLevel >= 1) 2 else 1 + it.rawLevel = if (PEAK_OF_THE_MOUNTAIN.rawLevel >= 1) 2 else 1 } } } -- cgit