Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement: Estimated Item Value #2180

Merged
merged 3 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -585,9 +586,10 @@ object EstimatedItemValueCalculator {
val map = mutableMapOf<String, Double>()

//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) {
Expand All @@ -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)
}
Expand Down Expand Up @@ -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)
}
}
Loading