aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorWalker Selby <git@walkerselby.com>2024-01-16 09:23:55 -0600
committerGitHub <noreply@github.com>2024-01-16 16:23:55 +0100
commit69cfa25c720884f44d6ed99e24d2eb4176f09e37 (patch)
tree02d2899d6a9719ec4a12de34ee20fb487e8e9e13 /src/main/java
parent59366daaa6ccdad237ab5f8949aef45a686e048f (diff)
downloadskyhanni-69cfa25c720884f44d6ed99e24d2eb4176f09e37.tar.gz
skyhanni-69cfa25c720884f44d6ed99e24d2eb4176f09e37.tar.bz2
skyhanni-69cfa25c720884f44d6ed99e24d2eb4176f09e37.zip
Cleanup calculate() (#689)
Cleanup calculate() in Estimated Item Value. #689
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValueCalculator.kt67
1 files changed, 33 insertions, 34 deletions
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 c7a70f12c..601413065 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
@@ -56,48 +56,47 @@ import java.util.Locale
object EstimatedItemValueCalculator {
private val config get() = SkyHanniMod.feature.misc.estimatedItemValues
-
- fun calculate(stack: ItemStack, list: MutableList<String>): Pair<Double, Double> {
- var totalPrice = 0.0
- val basePrice = addBaseItem(stack, list)
- totalPrice += basePrice
-
- totalPrice += addAttributeCost(stack, list)
-
- totalPrice += addReforgeStone(stack, list)
+ private val additionalCostFunctions = listOf(
+ ::addAttributeCost,
+ ::addReforgeStone,
// once
- totalPrice += addRecomb(stack, list)
- totalPrice += addArtOfWar(stack, list)
- totalPrice += addArtOfPeace(stack, list)
- totalPrice += addEtherwarp(stack, list)
- totalPrice += addPowerScrolls(stack, list)
- totalPrice += addWoodSingularity(stack, list)
- totalPrice += addJalapenoBook(stack, list)
- totalPrice += addStatsBook(stack, list)
- totalPrice += addEnrichment(stack, list)
+ ::addRecomb,
+ ::addArtOfWar,
+ ::addArtOfPeace,
+ ::addEtherwarp,
+ ::addPowerScrolls,
+ ::addWoodSingularity,
+ ::addJalapenoBook,
+ ::addStatsBook,
+ ::addEnrichment,
// counted
- totalPrice += addMasterStars(stack, list)
- totalPrice += addHotPotatoBooks(stack, list)
- totalPrice += addFarmingForDummies(stack, list)
- totalPrice += addSilex(stack, list)
- totalPrice += addTransmissionTuners(stack, list)
- totalPrice += addManaDisintegrators(stack, list)
- totalPrice += addPolarvoidBook(stack, list)
- totalPrice += addBookwormBook(stack, list)
+ ::addMasterStars,
+ ::addHotPotatoBooks,
+ ::addFarmingForDummies,
+ ::addSilex,
+ ::addTransmissionTuners,
+ ::addManaDisintegrators,
+ ::addPolarvoidBook,
+ ::addBookwormBook,
// cosmetic
- totalPrice += addHelmetSkin(stack, list)
- totalPrice += addArmorDye(stack, list)
- totalPrice += addRune(stack, list)
+ ::addHelmetSkin,
+ ::addArmorDye,
+ ::addRune,
// dynamic
- totalPrice += addAbilityScrolls(stack, list)
- totalPrice += addDrillUpgrades(stack, list)
- totalPrice += addGemstoneSlotUnlockCost(stack, list)
- totalPrice += addGemstones(stack, list)
- totalPrice += addEnchantments(stack, list)
+ ::addAbilityScrolls,
+ ::addDrillUpgrades,
+ ::addGemstoneSlotUnlockCost,
+ ::addGemstones,
+ ::addEnchantments
+ )
+
+ fun calculate(stack: ItemStack, list: MutableList<String>): Pair<Double, Double> {
+ val basePrice = addBaseItem(stack, list)
+ val totalPrice = additionalCostFunctions.fold(basePrice) { total, function -> total + function(stack, list) }
return Pair(totalPrice, basePrice)
}