From 34ba8c5fb8304e7b568822f8d3f675a0f133c6da Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Sat, 6 Jul 2024 07:57:22 +0200 Subject: Improvement: Estimated Item Value (#2180) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../features/misc/EstimatedItemValueConfig.java | 31 ++++++++++++++++++++++ .../misc/items/EstimatedItemValueCalculator.kt | 25 ++++++++++++++--- 2 files changed, 53 insertions(+), 3 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni') diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/EstimatedItemValueConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/EstimatedItemValueConfig.java index d1d3e2425..dcbb65d15 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/EstimatedItemValueConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/EstimatedItemValueConfig.java @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.config.FeatureToggle; import at.hannibal2.skyhanni.config.core.config.Position; import com.google.gson.annotations.Expose; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDropdown; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorKeybind; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider; import io.github.notenoughupdates.moulconfig.annotations.ConfigLink; @@ -63,6 +64,36 @@ public class EstimatedItemValueConfig { @ConfigEditorBoolean public boolean ignoreRunes = false; + @Expose + @ConfigOption(name = "Bazaar Price Source", desc = "Use Instant Buy or Buy Order.") + @ConfigEditorDropdown + public BazaarPriceSource bazaarPriceSource = BazaarPriceSource.BUY_ORDER; + + public enum BazaarPriceSource { + INSTANT_BUY("Instant Buy"), + BUY_ORDER("Buy Order"), + ; + private final String str; + + BazaarPriceSource(String str) { + this.str = str; + } + + @Override + public String toString() { + return str; + } + } + + @Expose + @ConfigOption( + name = "Use Attribute Price", + desc = "Show composite price for attributes instead of lowest bin. " + + "This will drastically decrease the estimated value but might be correct when buying multiple low tier items and combining them." + ) + @ConfigEditorBoolean + public boolean useAttributeComposite = false; + @Expose @ConfigLink(owner = EstimatedItemValueConfig.class, field = "enabled") public Position itemPriceDataPos = new Position(140, 90, false, true); diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt index 1d6b21d2e..54f8f675e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.misc.items import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.api.ReforgeAPI +import at.hannibal2.skyhanni.config.features.misc.EstimatedItemValueConfig import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.CollectionUtils.sortedDesc import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName @@ -17,7 +18,6 @@ import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NEUItems import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull import at.hannibal2.skyhanni.utils.NEUItems.getNpcPriceOrNull -import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.NEUItems.getPriceOrNull import at.hannibal2.skyhanni.utils.NEUItems.getRawCraftCostOrNull import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat @@ -208,7 +208,8 @@ object EstimatedItemValueCalculator { private fun String.fixMending() = if (this == "MENDING") "VITALITY" else this private fun getPriceOrCompositePriceForAttribute(attributeName: String, level: Int): Double? { - return (1..10).mapNotNull { lowerLevel -> + val intRange = if (config.useAttributeComposite) 1..10 else level..level + return intRange.mapNotNull { lowerLevel -> "$attributeName;$lowerLevel".asInternalName().getPriceOrNull() ?.let { it / (1 shl lowerLevel) * (1 shl level).toDouble() } }.minOrNull() @@ -585,9 +586,10 @@ object EstimatedItemValueCalculator { val map = mutableMapOf() //todo use repo - val tieredEnchants = listOf("compact", "cultivating", "champion", "expertise", "hecatomb") + val tieredEnchants = listOf("compact", "cultivating", "champion", "expertise", "hecatomb", "toxophilite") val onlyTierOnePrices = listOf("ultimate_chimera", "ultimate_fatal_tempo", "smoldering", "ultimate_flash", "divine_gift") + val onlyTierFivePrices = listOf("ferocious_mana", "hardened_mana", "mana_vampire", "strong_mana") val internalName = stack.getInternalName() for ((rawName, rawLevel) in enchantments) { @@ -614,6 +616,16 @@ object EstimatedItemValueCalculator { } level = 1 } + if (rawName in onlyTierFivePrices) { + when (rawLevel) { + 6 -> multiplier = 2 + 7 -> multiplier = 4 + 8 -> multiplier = 8 + 9 -> multiplier = 16 + 10 -> multiplier = 32 + } + level = 5 + } if (internalName.startsWith("ENCHANTED_BOOK_BUNDLE_")) { multiplier = EstimatedItemValue.bookBundleAmount.getOrDefault(rawName, 5) } @@ -743,4 +755,11 @@ object EstimatedItemValueCalculator { list += priceMap.sortedDesc().keys return totalPrice } + + private fun NEUInternalName.getPrice(): Double = getPriceOrNull() ?: -1.0 + + private fun NEUInternalName.getPriceOrNull(): Double? { + val useSellPrice = config.bazaarPriceSource == EstimatedItemValueConfig.BazaarPriceSource.BUY_ORDER + return getPriceOrNull(useSellPrice) + } } -- cgit