-
-
Notifications
You must be signed in to change notification settings - Fork 205
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
Fix: Item Value Estimation Coloring #3061
Changes from 7 commits
58bb1ad
3686942
d06f5c3
d1ccd11
3b79b90
7429a26
a5002dd
14f2099
8baf50d
edc261e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.features.misc.discordrpc.DiscordRPCManager | ||
import at.hannibal2.skyhanni.features.nether.kuudra.KuudraAPI | ||
import at.hannibal2.skyhanni.features.nether.kuudra.KuudraAPI.getKuudraTier | ||
import at.hannibal2.skyhanni.features.nether.kuudra.KuudraAPI.isKuudraArmor | ||
|
@@ -23,6 +24,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore | |
import at.hannibal2.skyhanni.utils.ItemUtils.getReadableNBTDump | ||
import at.hannibal2.skyhanni.utils.ItemUtils.isRune | ||
import at.hannibal2.skyhanni.utils.ItemUtils.itemName | ||
import at.hannibal2.skyhanni.utils.ItemUtils.itemNameBaseRarityAware | ||
import at.hannibal2.skyhanni.utils.ItemUtils.itemNameWithoutColor | ||
import at.hannibal2.skyhanni.utils.ItemUtils.name | ||
import at.hannibal2.skyhanni.utils.LorenzRarity | ||
|
@@ -120,18 +122,16 @@ object EstimatedItemValueCalculator { | |
::addEnchantments, | ||
) | ||
|
||
val farmingForDummies = "FARMING_FOR_DUMMIES".toInternalName() | ||
val etherwarpConduit = "ETHERWARP_CONDUIT".toInternalName() | ||
val etherwarpMerger = "ETHERWARP_MERGER".toInternalName() | ||
val fumingPotatoBook = "FUMING_POTATO_BOOK".toInternalName() | ||
val hotPotatoBook = "HOT_POTATO_BOOK".toInternalName() | ||
val silex = "SIL_EX".toInternalName() | ||
val transmissionTuner = "TRANSMISSION_TUNER".toInternalName() | ||
val manaDisintegrator = "MANA_DISINTEGRATOR".toInternalName() | ||
private val farmingForDummies = "FARMING_FOR_DUMMIES".toInternalName() | ||
private val etherwarpConduit = "ETHERWARP_CONDUIT".toInternalName() | ||
private val etherwarpMerger = "ETHERWARP_MERGER".toInternalName() | ||
private val fumingPotatoBook = "FUMING_POTATO_BOOK".toInternalName() | ||
private val hotPotatoBook = "HOT_POTATO_BOOK".toInternalName() | ||
private val silex = "SIL_EX".toInternalName() | ||
private val transmissionTuner = "TRANSMISSION_TUNER".toInternalName() | ||
private val manaDisintegrator = "MANA_DISINTEGRATOR".toInternalName() | ||
|
||
val kuudraUpgradeTiers = listOf("HOT_", "BURNING_", "FIERY_", "INFERNAL_") | ||
|
||
fun getTotalPrice(stack: ItemStack): Double = EstimatedItemValueCalculator.calculate(stack, mutableListOf()).first | ||
fun getTotalPrice(stack: ItemStack): Double = calculate(stack, mutableListOf()).first | ||
|
||
fun calculate(stack: ItemStack, list: MutableList<String>): Pair<Double, Double> { | ||
val basePrice = addBaseItem(stack, list) | ||
|
@@ -700,7 +700,7 @@ object EstimatedItemValueCalculator { | |
} | ||
} | ||
|
||
val name = internalName.itemName | ||
val name = stack.itemNameBaseRarityAware | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we dont want to show the recomb color here, and since the reforge name is also not part of the clean item name, i dont see why this line change is necessary |
||
if (internalName.startsWith("ENCHANTED_BOOK_BUNDLE_")) { | ||
list.add("§7Base item: $name") | ||
return 0.0 | ||
|
@@ -710,52 +710,25 @@ object EstimatedItemValueCalculator { | |
return price | ||
} | ||
|
||
// TODO repo | ||
private val hasAlwaysScavenger = listOf( | ||
"CRYPT_DREADLORD_SWORD".toInternalName(), | ||
"ZOMBIE_SOLDIER_CUTLASS".toInternalName(), | ||
"CONJURING_SWORD".toInternalName(), | ||
"EARTH_SHARD".toInternalName(), | ||
"ZOMBIE_KNIGHT_SWORD".toInternalName(), | ||
"SILENT_DEATH".toInternalName(), | ||
"ZOMBIE_COMMANDER_WHIP".toInternalName(), | ||
"ICE_SPRAY_WAND".toInternalName(), | ||
) | ||
|
||
private val hasAlwaysReplenish = listOf( | ||
"ADVANCED_GARDENING_HOE".toInternalName(), | ||
"ADVANCED_GARDENING_AXE".toInternalName(), | ||
) | ||
|
||
private fun addEnchantments(stack: ItemStack, list: MutableList<String>): Double { | ||
val enchantments = stack.getEnchantments() ?: return 0.0 | ||
|
||
var totalPrice = 0.0 | ||
val map = mutableMapOf<String, Double>() | ||
|
||
// todo use repo | ||
val tieredEnchants = listOf("compact", "cultivating", "champion", "expertise", "hecatomb", "toxophilite") | ||
|
||
@Suppress("PropertyWrapping") | ||
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) { | ||
// efficiency 1-5 is cheap, 6-10 is handled by silex | ||
if (rawName == "efficiency") continue | ||
|
||
if (rawName == "scavenger" && rawLevel == 5 && internalName in hasAlwaysScavenger) { | ||
continue | ||
} | ||
|
||
if (rawName == "replenish" && rawLevel == 1 && internalName in hasAlwaysReplenish) { | ||
continue | ||
val isAlwaysActive = EstimatedItemValue.itemValueCalculationData.alwaysActiveEnchants.entries.any { | ||
it.key == rawName && it.value.level == rawLevel && it.value.internalNames.contains(internalName) | ||
} | ||
if (isAlwaysActive) continue | ||
|
||
var level = rawLevel | ||
var multiplier = 1 | ||
if (rawName in onlyTierOnePrices) { | ||
if (rawName in EstimatedItemValue.itemValueCalculationData.onlyTierOnePrices) { | ||
|
||
when (rawLevel) { | ||
2 -> multiplier = 2 | ||
|
@@ -765,7 +738,7 @@ object EstimatedItemValueCalculator { | |
} | ||
level = 1 | ||
} | ||
if (rawName in onlyTierFivePrices) { | ||
if (rawName in EstimatedItemValue.itemValueCalculationData.onlyTierFivePrices) { | ||
when (rawLevel) { | ||
6 -> multiplier = 2 | ||
7 -> multiplier = 4 | ||
|
@@ -780,7 +753,7 @@ object EstimatedItemValueCalculator { | |
if (internalName.startsWith("ENCHANTED_BOOK_BUNDLE_")) { | ||
multiplier = EstimatedItemValue.bookBundleAmount.getOrDefault(rawName, 5) | ||
} | ||
if (rawName in tieredEnchants) level = 1 | ||
if (rawName in DiscordRPCManager.stackingEnchants.keys) level = 1 | ||
|
||
val enchantmentName = "$rawName;$level".uppercase().toInternalName() | ||
val itemStack = enchantmentName.getItemStackOrNull() ?: continue | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule | |
import at.hannibal2.skyhanni.test.command.ErrorManager | ||
import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut | ||
import at.hannibal2.skyhanni.utils.ItemPriceUtils.getPrice | ||
import at.hannibal2.skyhanni.utils.ItemUtils.itemName | ||
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.toInternalName | ||
import at.hannibal2.skyhanni.utils.NEUItems.getItemStackOrNull | ||
import at.hannibal2.skyhanni.utils.NumberUtil.formatInt | ||
|
@@ -344,6 +345,11 @@ object ItemUtils { | |
return data.itemCategory | ||
} | ||
|
||
fun ItemStack.getItemBaseRarityOrNull(): LorenzRarity? { | ||
val rarity = getItemRarityOrNull() ?: return null | ||
return if (isRecombobulated(this)) LorenzRarity.entries.firstOrNull { it.id == rarity.id - 1 } else rarity | ||
} | ||
|
||
fun ItemStack.getItemRarityOrNull(): LorenzRarity? { | ||
val data = cachedData | ||
if (itemRarityLastCheck(data)) { | ||
|
@@ -460,6 +466,28 @@ object ItemUtils { | |
return getInternalNameOrNull()?.itemName ?: "<null>" | ||
} | ||
|
||
/** | ||
* Returns the item name with its base color, i.e. before recombobulation | ||
*/ | ||
val ItemStack.itemNameBaseRarityAware: String | ||
get() { | ||
return getRarityName(getItemBaseRarityOrNull()) | ||
} | ||
|
||
/** | ||
* Returns the item name with its full color, i.e. after recombobulation | ||
*/ | ||
val ItemStack.itemNameFullyRarityAware: String | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is the difference between this and the display name? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if the purpose is to remove the reforge name, maybe its better to have the function be called |
||
get() { | ||
return getRarityName(getItemRarityOrNull()) | ||
} | ||
|
||
private fun ItemStack.getRarityName(rarity: LorenzRarity?): String = | ||
if (rarity == null) itemName | ||
else if (itemName.startsWith("§")) { | ||
itemName.replaceFirst(Regex("§[0-9a-f]"), rarity.color.getChatColor()) | ||
} else itemName | ||
|
||
fun ItemStack.getAttributeFromShard(): Pair<String, Int>? { | ||
if (getInternalName().asString() != "ATTRIBUTE_SHARD") return null | ||
val attributes = getAttributes() ?: return null | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be null, not lateinit. starting with a outdated repo will cause ugly errors instead of clean repo errors