summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/HotmData.kt33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/HotmData.kt b/src/main/java/at/hannibal2/skyhanni/data/HotmData.kt
index 8c6db7df0..c299f5d52 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/HotmData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/HotmData.kt
@@ -37,7 +37,7 @@ import kotlin.math.floor
import kotlin.math.pow
enum class HotmData(
- guiName: String,
+ val guiName: String,
val maxLevel: Int,
val costFun: ((Int) -> (Double?)),
val rewardFun: ((Int) -> (Map<HotmReward, Double>)),
@@ -372,6 +372,10 @@ enum class HotmData(
fun getReward() = rewardFun(activeLevel)
+ fun calculateTotalCost(desiredLevel: Int) = (1 until desiredLevel).sumOf { level -> costFun(level) ?: 0.0 }.toInt()
+
+ val totalCostMaxLevel = calculateTotalCost(maxLevel)
+
// TODO move all object functions into hotm api?
@SkyHanniModule
companion object {
@@ -406,6 +410,11 @@ enum class HotmData(
) // unused for now since the assumption is when enabled isn't found it is disabled,
// but the value might be useful in the future or for debugging
+ val perkCostPattern by patternGroup.pattern(
+ "perk.cost",
+ "(?:§.)*§7Cost",
+ )
+
private val resetChatPattern by patternGroup.pattern(
"reset.chat",
"§aReset your §r§5Heart of the Mountain§r§a! Your Perks and Abilities have been reset.",
@@ -471,6 +480,8 @@ enum class HotmData(
}
}
+ fun getPerkByNameOrNull(name: String): HotmData? = entries.find { it.guiName == name }
+
private fun resetTree() = entries.forEach {
it.activeLevel = 0
it.enabled = false
@@ -574,17 +585,15 @@ enum class HotmData(
private fun handelSkyMall(lore: List<String>) {
if (!SKY_MALL.enabled || !SKY_MALL.isUnlocked) HotmAPI.skymall = null
else {
- val index = (
- lore.indexOfFirstMatch(skyMallCurrentEffect) ?: run {
- ErrorManager.logErrorStateWithData(
- "Could not read the skymall effect from the hotm tree",
- "skyMallCurrentEffect didn't match",
- "lore" to lore,
- )
- return
- }
- ) + 1
- skymallPattern.matchMatcher(lore[index]) {
+ val index = lore.indexOfFirstMatch(skyMallCurrentEffect) ?: run {
+ ErrorManager.logErrorStateWithData(
+ "Could not read the skymall effect from the hotm tree",
+ "skyMallCurrentEffect didn't match",
+ "lore" to lore,
+ )
+ return
+ }
+ skymallPattern.matchMatcher(lore[index + 1]) {
val perk = group("perk")
HotmAPI.skymall = SkymallPerk.entries.firstOrNull { it.itemPattern.matches(perk) } ?: run {
ErrorManager.logErrorStateWithData(