aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-03-23 14:58:08 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-03-23 14:58:08 +0100
commit6d2343b39b1def411c072be3dec7e3ca1bafe93d (patch)
treee681416b4dbaa4cc9749235e02d3eebf78b0b7e7
parentd440b058aa5ef53f40e14e1f1917ed8e3d64997b (diff)
downloadSkyHanni-6d2343b39b1def411c072be3dec7e3ca1bafe93d.tar.gz
SkyHanni-6d2343b39b1def411c072be3dec7e3ca1bafe93d.tar.bz2
SkyHanni-6d2343b39b1def411c072be3dec7e3ca1bafe93d.zip
Added CropType.getFactor
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/EliteFarmingWeight.kt12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/EliteFarmingWeight.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/EliteFarmingWeight.kt
index d94735ba7..76561f35a 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/EliteFarmingWeight.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/EliteFarmingWeight.kt
@@ -270,10 +270,10 @@ class EliteFarmingWeight {
private fun calculateCollectionWeight(round: Boolean = true): MutableMap<CropType, Double> {
val weightPerCrop = mutableMapOf<CropType, Double>()
var totalWeight = 0.0
- for ((cropName, factor) in factorPerCrop) {
- val collection = getLocalCollection(cropName)
- val weight = (collection / factor).also { if (round) weight.round(2) else weight }
- weightPerCrop[cropName] = weight
+ for (crop in CropType.values()) {
+ val collection = getLocalCollection(crop)
+ val weight = (collection / crop.getFactor()).also { if (round) weight.round(2) else weight }
+ weightPerCrop[crop] = weight
totalWeight += weight
}
if (totalWeight > 0) {
@@ -288,7 +288,7 @@ class EliteFarmingWeight {
val doubleBreakRatio = (cactusWeight + sugarCaneWeight) / totalWeight;
val normalRatio = (totalWeight - cactusWeight - sugarCaneWeight) / totalWeight;
- val mushroomFactor = factorPerCrop[CropType.MUSHROOM]!!
+ val mushroomFactor = CropType.MUSHROOM.getFactor()
val mushroomCollection = getLocalCollection(CropType.MUSHROOM)
return doubleBreakRatio * (mushroomCollection / (2 * mushroomFactor)) + normalRatio * (mushroomCollection / mushroomFactor)
}
@@ -297,6 +297,8 @@ class EliteFarmingWeight {
return localCollection[crop] ?: 0L
}
+ private fun CropType.getFactor() = factorPerCrop[this]!!
+
private val factorPerCrop by lazy {
mapOf(
CropType.WHEAT to 100_000.0,