Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: HotmData Level Detection with Blue Egg #2295

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/main/java/at/hannibal2/skyhanni/data/HotmData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()) }
Expand All @@ -542,15 +542,15 @@ 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
}

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

Expand Down Expand Up @@ -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
}
}
}
Expand Down
Loading