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
commitcea66fb45be6d0878da2985e65b3ab9869455fe6 (patch)
treee681416b4dbaa4cc9749235e02d3eebf78b0b7e7
parent5ddccce30b3e285581b42eb1274d98b581635faa (diff)
downloadskyhanni-cea66fb45be6d0878da2985e65b3ab9869455fe6.tar.gz
skyhanni-cea66fb45be6d0878da2985e65b3ab9869455fe6.tar.bz2
skyhanni-cea66fb45be6d0878da2985e65b3ab9869455fe6.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,