aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-03-09 20:54:50 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-03-09 20:54:50 +0100
commit84d5063ab88d88753861aa70cd4e85e92314e108 (patch)
tree9680517b4039f29e139c36df0d7e3f77aeaba031
parent53f5feafaf799715140119ee4ee360d7c6e1a4f9 (diff)
downloadskyhanni-84d5063ab88d88753861aa70cd4e85e92314e108.tar.gz
skyhanni-84d5063ab88d88753861aa70cd4e85e92314e108.tar.bz2
skyhanni-84d5063ab88d88753861aa70cd4e85e92314e108.zip
deleted timeTillNextCrop
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Hidden.java3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt30
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) {