diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-07-15 16:45:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-15 16:45:09 +0200 |
commit | ad7c6dfc824bb7d2b1405ec5f7c0a017612bbf2f (patch) | |
tree | 4a9786dd9c2578d0063ccd179200f04b612d7e35 /src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt | |
parent | a716e5d26a6ae6c79300c298c221382fb73e21a8 (diff) | |
download | skyhanni-ad7c6dfc824bb7d2b1405ec5f7c0a017612bbf2f.tar.gz skyhanni-ad7c6dfc824bb7d2b1405ec5f7c0a017612bbf2f.tar.bz2 skyhanni-ad7c6dfc824bb7d2b1405ec5f7c0a017612bbf2f.zip |
Fix: price source inconsistencies (bz sell/buy and npc price) (#2221)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt index b5d31185a..e392699cd 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt @@ -2,7 +2,6 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigFileType -import at.hannibal2.skyhanni.config.features.inventory.SackDisplayConfig.PriceFrom import at.hannibal2.skyhanni.data.jsonobjects.repo.neu.NeuSacksJson import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent @@ -22,7 +21,6 @@ import at.hannibal2.skyhanni.utils.ItemUtils.itemNameWithoutColor import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName -import at.hannibal2.skyhanni.utils.NEUItems.getNpcPriceOrNull import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.NumberUtil.formatInt import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal @@ -49,15 +47,15 @@ object SackAPI { private val patternGroup = RepoPattern.group("data.sacks") private val sackPattern by patternGroup.pattern( "sack", - "^(.* Sack|Enchanted .* Sack)\$" + "^(.* Sack|Enchanted .* Sack)\$", ) private val numPattern by patternGroup.pattern( "number", - "(?:(?:§[0-9a-f](?<level>I{1,3})§7:)?|(?:§7Stored:)?) (?<color>§[0-9a-f])(?<stored>[0-9.,kKmMbB]+)§7/(?<total>\\d+(?:[0-9.,]+)?[kKmMbB]?)" + "(?:(?:§[0-9a-f](?<level>I{1,3})§7:)?|(?:§7Stored:)?) (?<color>§[0-9a-f])(?<stored>[0-9.,kKmMbB]+)§7/(?<total>\\d+(?:[0-9.,]+)?[kKmMbB]?)", ) private val gemstonePattern by patternGroup.pattern( "gemstone", - " §[0-9a-f](?<gemrarity>[A-z]*): §[0-9a-f](?<stored>\\d+(?:\\.\\d+)?(?:(?:,\\d+)?)+[kKmM]?)(?: §[0-9a-f]\\(\\d+(?:\\.\\d+)?(?:(?:,\\d+)?)+[kKmM]?\\))?" + " §[0-9a-f](?<gemrarity>[A-z]*): §[0-9a-f](?<stored>\\d+(?:\\.\\d+)?(?:(?:,\\d+)?)+[kKmM]?)(?: §[0-9a-f]\\(\\d+(?:\\.\\d+)?(?:(?:,\\d+)?)+[kKmM]?\\))?", ) private var isRuneSack = false @@ -114,21 +112,14 @@ object SackAPI { SackDisplay.update(isNewInventory) } - private fun String.getTrophyRarity(): TrophyRarity? { - return if (this.startsWith("Bronze")) - TrophyRarity.BRONZE - else - if (this.startsWith("Silver")) - TrophyRarity.SILVER - else null + private fun String.getTrophyRarity(): TrophyRarity? = when { + this.startsWith("Bronze") -> TrophyRarity.BRONZE + this.startsWith("Silver") -> TrophyRarity.SILVER + else -> null } private fun NEUInternalName.sackPrice(stored: Int): Long { - return when (sackDisplayConfig.priceFrom) { - PriceFrom.BAZAAR -> (getPrice() * stored).toLong().coerceAtLeast(0) - PriceFrom.NPC -> (getNpcPriceOrNull() ?: 0.0).toLong() * stored - else -> 0L - } + return getPrice(sackDisplayConfig.priceSource).toLong() * stored } fun getSacksData(savingSacks: Boolean) { |