aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt67
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt9
2 files changed, 75 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt
index c9e0924e2..3cca7d132 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt
@@ -16,6 +16,7 @@ import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getAbilityScrolls
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getArmorDye
+import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getAttributes
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getDrillUpgrades
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getDungeonStarCount
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEnchantments
@@ -37,6 +38,7 @@ import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.hasEtherwarp
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.hasJalapenoBook
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.hasWoodSingularity
import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.isRecombobulated
+import at.hannibal2.skyhanni.utils.StringUtils.firstLetterUppercase
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import io.github.moulberry.moulconfig.internal.KeybindHelper
import io.github.moulberry.notenoughupdates.util.Constants
@@ -73,7 +75,7 @@ object EstimatedItemValue {
val item = event.stack
val oldData = cache[item]
- if (oldData != null) {
+ if (oldData != null && false) {
display = oldData
lastToolTipTime = System.currentTimeMillis()
return
@@ -138,6 +140,9 @@ object EstimatedItemValue {
var totalPrice = 0.0
val basePrice = addBaseItem(stack, list)
totalPrice += basePrice
+
+ totalPrice += addAttributeCost(stack, list)
+
totalPrice += addReforgeStone(stack, list)
// once
@@ -172,6 +177,66 @@ object EstimatedItemValue {
return Pair(totalPrice, basePrice)
}
+ private fun addAttributeCost(stack: ItemStack, list: MutableList<String>): Double {
+ val attributes = stack.getAttributes() ?: return 0.0
+ var internalName = stack.getInternalName().removePrefix("VANQUISHED_")
+ val kuudraSets = listOf("AURORA", "CRIMSON", "TERROR", "HOLLOW")
+ var genericName = internalName
+ if (kuudraSets.any { internalName.contains(it) }
+ && listOf("CHESTPLATE", "LEGGINGS", "HELMET", "BOOTS").any { internalName.endsWith(it) }) {
+ for (prefix in listOf("HOT_", "BURNING_", "FIERY_", "INFERNAL_")) {
+ internalName = internalName.removePrefix(prefix)
+ }
+ genericName = kuudraSets.fold(internalName) { acc, part -> acc.replace(part, "GENERIC_KUUDRA") }
+ }
+ if (internalName == "ATTRIBUTE_SHARD" && attributes.size == 1) {
+ val price =
+ getPriceOrCompositePriceForAttribute(
+ "ATTRIBUTE_SHARD+ATTRIBUTE_" + attributes[0].first,
+ attributes[0].second
+ )
+ if (price != null) {
+ list.add(
+ "§7Attribute §9${
+ attributes[0].first.split("_").joinToString(" ") { it.firstLetterUppercase() }
+ } ${attributes[0].second}§7: (§6${NumberUtil.format(price)}§7)"
+ )
+ return price
+ }
+ }
+ if (attributes.size != 2) return 0.0
+ val basePrice = NEUItems.getPriceOrNull(internalName) ?: 0.0
+ var subTotal = 0.0
+ val combo = internalName + "+ATTRIBUTE_" + attributes[0].first + "+ATTRIBUTE_" + attributes[1].first
+ val comboPrice = NEUItems.getPriceOrNull(combo)
+ if (comboPrice != null && comboPrice > basePrice) {
+ list.add("§7Attribute Combo: (§6${NumberUtil.format(comboPrice)}§7)")
+ subTotal += comboPrice - basePrice
+ } else {
+ list.add("§7Attributes:")
+ }
+ for (attr in attributes) {
+ val price =
+ getPriceOrCompositePriceForAttribute("$genericName+ATTRIBUTE_${attr.first}", attr.second)
+ if (price != null) {
+ subTotal += price
+ }
+ list.add(
+ " §9${
+ attr.first.split("_").joinToString(" ") { it.firstLetterUppercase() }
+ } ${attr.second}§7: §6${if (price != null) NumberUtil.format(price) else "Unknown"}"
+ )
+ }
+ return subTotal
+ }
+
+ private fun getPriceOrCompositePriceForAttribute(attributeName: String, level: Int): Double? {
+ return (1..10).mapNotNull { lowerLevel ->
+ NEUItems.getPriceOrNull("$attributeName;$lowerLevel")
+ ?.let { it * (1 shl lowerLevel) / (1 shl level).toDouble() }
+ }.minOrNull()
+ }
+
private fun addReforgeStone(stack: ItemStack, list: MutableList<String>): Double {
val rawReforgeName = stack.getReforgeName() ?: return 0.0
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt
index 4df582ca6..6292bf7e0 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/SkyBlockItemModifierUtils.kt
@@ -113,6 +113,15 @@ object SkyBlockItemModifierUtils {
list.toList()
}
+ fun ItemStack.getAttributes() = getExtraAttributes()
+ ?.takeIf { it.hasKey("attributes", 10) }
+ ?.getCompoundTag("attributes")
+ ?.let { attr ->
+ attr.keySet.map {
+ it.uppercase() to attr.getInteger(it)
+ }.sortedBy { it.first }
+ }
+
fun ItemStack.getReforgeName() = getAttributeString("modifier")
fun ItemStack.isRecombobulated() = getAttributeBoolean("rarity_upgrades")