diff options
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java | 3 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt | 30 |
2 files changed, 28 insertions, 5 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java b/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java index 315be5382..5bd2b3ba4 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java @@ -37,8 +37,5 @@ public class Hidden { public Map<String, Long> gardenCropCounter = new HashMap<>(); @Expose - public Map<String, Long> gardenTimeTillNextCropMilestone = new HashMap<>(); - - @Expose public Map<String, Integer> gardenCropsPerSecond = new HashMap<>(); } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt index d43d2f428..2585278e5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt @@ -18,7 +18,7 @@ class GardenCropMilestoneDisplay { private val bestCropDisplay = mutableListOf<List<Any>>() private var needsInventory = false private val cultivatingData = mutableMapOf<String, Int>() - private val timeTillNextCrop: MutableMap<String, Long> get() = SkyHanniMod.feature.hidden.gardenTimeTillNextCropMilestone + private val timeTillNextCrop = mutableMapOf<String, Long>() private val config: Garden get() = SkyHanniMod.feature.garden companion object { @@ -29,7 +29,7 @@ class GardenCropMilestoneDisplay { return cropsPerSecond[crop] } - private val cropsPerSecond: MutableMap<String, Int> get() = SkyHanniMod.feature.hidden.gardenCropsPerSecond + private val cropsPerSecond: MutableMap<String, Int> get() = SkyHanniMod.feature.hidden.gardenCropsPerSecond } @SubscribeEvent @@ -57,6 +57,7 @@ class GardenCropMilestoneDisplay { @SubscribeEvent fun onCropMilestoneUpdate(event: CropMilestoneUpdateEvent) { needsInventory = false + updateTimeTillNextCrop() update() } @@ -142,6 +143,10 @@ class GardenCropMilestoneDisplay { } private fun drawBestDisplay(currentCrop: String?) { + if (timeTillNextCrop.size < cropsPerSecond.size) { + updateTimeTillNextCrop() + } + val gardenExp = config.cropMilestoneBestType == 0 val sorted = if (gardenExp) { val helpMap = mutableMapOf<String, Long>() @@ -185,6 +190,27 @@ class GardenCropMilestoneDisplay { } } + private fun updateTimeTillNextCrop() { + for ((cropName, speed) in cropsPerSecond) { + if (speed == -1) continue + + val crops = GardenCropMilestones.cropCounter[cropName]!! + val currentTier = GardenCropMilestones.getTierForCrops(crops) + + val cropsForCurrentTier = GardenCropMilestones.getCropsForTier(currentTier) + val nextTier = currentTier + 1 + val cropsForNextTier = GardenCropMilestones.getCropsForTier(nextTier) + + val have = crops - cropsForCurrentTier + val need = cropsForNextTier - cropsForCurrentTier + + val missing = need - have + val missingTimeSeconds = missing / speed + val millis = missingTimeSeconds * 1000 + timeTillNextCrop[cropName] = millis + } + } + private fun getGardenExpForTier(gardenLevel: Int) = if (gardenLevel > 30) 300 else gardenLevel * 10 private fun drawProgressDisplay(it: String, crops: Long) { |