diff options
| author | J10a1n15 <45315647+j10a1n15@users.noreply.github.com> | 2024-06-13 20:14:16 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-13 20:14:16 +0200 |
| commit | 045c39701411b5c9a5ffcbffb45ce34c09f1c2c6 (patch) | |
| tree | d32d2be8fbea11ef307891a8778b57e8b4d69789 /src/main/java/at/hannibal2/skyhanni/data | |
| parent | 9eee8c80ee5877ca627c8b545936bf37454fa17e (diff) | |
| download | skyhanni-045c39701411b5c9a5ffcbffb45ce34c09f1c2c6.tar.gz skyhanni-045c39701411b5c9a5ffcbffb45ce34c09f1c2c6.tar.bz2 skyhanni-045c39701411b5c9a5ffcbffb45ce34c09f1c2c6.zip | |
Feature: Total Powder Cost in Perk Lore (#1460)
Co-authored-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com>
Co-authored-by: Empa <42304516+ItsEmpa@users.noreply.github.com>
Co-authored-by: martimavocado <39881008+martimavocado@users.noreply.github.com>
Co-authored-by: Thunderblade73 <gaidermarkus@gmail.com>
Co-authored-by: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com>
Co-authored-by: martimavocado <martim.cavaco@tutanota.com>
Co-authored-by: Cal <cwolfson58@gmail.com>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/HotmData.kt | 33 |
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( |
