From e9b394d93acc878ae50bed56f8f97ae335ac655c Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Mon, 1 Jul 2024 12:27:24 +0200 Subject: [PATCH 1/2] estimated item value update --- .../misc/EstimatedItemValueConfig.java | 31 +++++++++++++++++++ .../items/EstimatedItemValueCalculator.kt | 25 +++++++++++++-- 2 files changed, 53 insertions(+), 3 deletions(-) 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 d1d3e242551e..dcbb65d15862 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.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 05d53fa657d7..c31195581a41 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 @@ -16,7 +17,6 @@ import at.hannibal2.skyhanni.utils.NEUInternalName 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.getPrice import at.hannibal2.skyhanni.utils.NEUItems.getPriceOrNull import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils @@ -206,7 +206,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() @@ -572,9 +573,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) { @@ -601,6 +603,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) } @@ -730,4 +742,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) + } } From e4724eb178e1379463005d4b4a510673168bfcfd Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 2 Jul 2024 09:08:41 +0200 Subject: [PATCH 2/2] fixed merge conflicts --- .../skyhanni/features/misc/items/EstimatedItemValueCalculator.kt | 1 - 1 file changed, 1 deletion(-) 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 b9cc26e392a9..54f8f675eb55 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 @@ -18,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