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

Backend: EstimatedItemValueCalculator cleanup #3255

Merged
merged 21 commits into from
Jan 21, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add gray color support
  • Loading branch information
hannibal002 committed Jan 19, 2025
commit 374a7528795bd7b8547195b6eb3f6bf36e0103f7
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ object EstimatedItemValueCalculator {

if (comboPrice != null) {
val useless = isUselessAttribute(combo)
val color = if (comboPrice > basePrice && !useless) "§6" else "§7"
list.add("§7Attribute Combo: ($color${comboPrice.shortFormat()}§7)")
val gray = comboPrice <= basePrice || useless
list.add("§7Attribute Combo: ${comboPrice.formatWithBrackets(gray)}")
if (!useless) {
subTotal += addAttributePrice(comboPrice, basePrice)
}
Expand All @@ -183,21 +183,21 @@ object EstimatedItemValueCalculator {
for (attr in attributes) {
val attributeName = "$genericName+ATTRIBUTE_${attr.first}"
val price = getPriceOrCompositePriceForAttribute(attributeName, attr.second)
var priceColor = "§7"
var gray = true
val useless = isUselessAttribute(attributeName)
val nameColor = if (!useless) "§9" else "§7"
if (price != null) {
if (price > basePrice && !useless) {
subTotal += addAttributePrice(price, basePrice)
priceColor = "§6"
gray = false
}

}
val displayName = attr.first.fixMending()
list.add(
" $nameColor${
displayName.allLettersFirstUppercase()
} ${attr.second}§7: $priceColor${price?.shortFormat() ?: "Unknown"}",
} ${attr.second}§7: ${price?.format(gray) ?: "Unknown"}",
)
}
// Adding 0.1 so that we always show the estimated item value overlay
Expand Down Expand Up @@ -622,8 +622,13 @@ object EstimatedItemValueCalculator {
return list.formatHaving(name, internalName)
}

private fun Number.formatWithBrackets(): String {
return "§7(§6" + this.shortFormat() + "§7)"
private fun Number.formatWithBrackets(gray: Boolean = false): String {
return "§7(§6" + format(gray) + "§7)"
}

fun Number.format(gray: Boolean = false): String {
val color = if (gray) "§7" else "§6"
return color + shortFormat()
}

private fun addHelmetSkin(stack: ItemStack, list: MutableList<String>): Double {
Expand All @@ -645,8 +650,9 @@ object EstimatedItemValueCalculator {
val price = internalName.getPrice()
val name = internalName.getNameOrRepoError()
val displayName = name ?: "§c${internalName.asString()}"
val color = if (shouldIgnorePrice.get()) "§7" else "§6"
list.add("§7$label: $displayName §7($color" + price.shortFormat() + "§7)")
val gray = shouldIgnorePrice.get()

list.add("§7$label: $displayName " + price.formatWithBrackets(gray))
if (name == null) {
list.add(" §8(Not yet in NEU Repo)")
}
Expand Down
Loading