diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-23 14:49:44 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-03-23 14:49:44 +0100 |
commit | 39855af4fe066fb4b1b11672aec635157d783e45 (patch) | |
tree | edd02e1172fca21460a210dcdf21f2d0ae594edf /src/main/java/at/hannibal2/skyhanni/features/garden | |
parent | 4f133a119ad4cb02f4ecb60d3bfb474879c75923 (diff) | |
download | skyhanni-39855af4fe066fb4b1b11672aec635157d783e45.tar.gz skyhanni-39855af4fe066fb4b1b11672aec635157d783e45.tar.bz2 skyhanni-39855af4fe066fb4b1b11672aec635157d783e45.zip |
Added CropType.getCounter
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/garden')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/GardenBestCropTime.kt | 17 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt | 11 |
2 files changed, 11 insertions, 17 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenBestCropTime.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenBestCropTime.kt index 976994070..7e2619be1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenBestCropTime.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenBestCropTime.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.GardenCropMilestones +import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.getCounter import at.hannibal2.skyhanni.utils.LorenzUtils.sorted import at.hannibal2.skyhanni.utils.TimeUtils import java.util.* @@ -20,8 +21,7 @@ class GardenBestCropTime { val sorted = if (gardenExp) { val helpMap = mutableMapOf<CropType, Long>() for ((cropName, time) in timeTillNextCrop) { - val crops = GardenCropMilestones.cropCounter[cropName]!! - val currentTier = GardenCropMilestones.getTierForCrops(crops) + val currentTier = GardenCropMilestones.getTierForCrops(cropName.getCounter()) val gardenExpForTier = getGardenExpForTier(currentTier + 1) val fakeTime = time / gardenExpForTier helpMap[cropName] = fakeTime @@ -52,8 +52,7 @@ class GardenBestCropTime { val color = if (isCurrent) "§e" else "§7" val contestFormat = if (GardenNextJacobContest.isNextCrop(crop)) "§n" else "" - val crops = GardenCropMilestones.cropCounter[crop]!! - val nextTier = GardenCropMilestones.getTierForCrops(crops) + 1 + val nextTier = GardenCropMilestones.getTierForCrops(crop.getCounter()) + 1 val cropNameDisplay = "$color$contestFormat${crop.cropName} $nextTier§r" list.add("$cropNameDisplay §b$duration") @@ -68,23 +67,23 @@ class GardenBestCropTime { private fun getGardenExpForTier(gardenLevel: Int) = if (gardenLevel > 30) 300 else gardenLevel * 10 fun updateTimeTillNextCrop() { - for ((cropName, speed) in GardenAPI.cropsPerSecond) { + for ((crop, speed) in GardenAPI.cropsPerSecond) { if (speed == -1) continue - val crops = GardenCropMilestones.cropCounter[cropName]!! - val currentTier = GardenCropMilestones.getTierForCrops(crops) + val counter = crop.getCounter() + val currentTier = GardenCropMilestones.getTierForCrops(counter) val cropsForCurrentTier = GardenCropMilestones.getCropsForTier(currentTier) val nextTier = currentTier + 1 val cropsForNextTier = GardenCropMilestones.getCropsForTier(nextTier) - val have = crops - cropsForCurrentTier + val have = counter - cropsForCurrentTier val need = cropsForNextTier - cropsForCurrentTier val missing = need - have val missingTimeSeconds = missing / speed val millis = missingTimeSeconds * 1000 - timeTillNextCrop[cropName] = millis + timeTillNextCrop[crop] = millis } } }
\ No newline at end of file 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 cd23fc64b..a52e474ff 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.garden import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.GardenCropMilestones +import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.getCounter import at.hannibal2.skyhanni.data.SendTitleHelper import at.hannibal2.skyhanni.events.* import at.hannibal2.skyhanni.utils.LorenzUtils @@ -84,7 +85,7 @@ class GardenCropMilestoneDisplay { val old = cultivatingData[crop]!! val diff = counter - old try { - GardenCropMilestones.cropCounter[crop] = GardenCropMilestones.cropCounter[crop]!! + diff + GardenCropMilestones.cropCounter[crop] = crop.getCounter() + diff } catch (e: NullPointerException) { println("crop: '$crop'") println("GardenCropMilestones.cropCounter: '${GardenCropMilestones.cropCounter.keys}'") @@ -148,13 +149,7 @@ class GardenCropMilestoneDisplay { progressDisplay.clear() bestCropTime.display.clear() currentCrop?.let { - val crops = GardenCropMilestones.cropCounter[it] - if (crops == null) { - println("cropCounter is null for '$it'") - return - } - - drawProgressDisplay(it, crops) + drawProgressDisplay(it, it.getCounter()) if (config.cropMilestoneBestDisplay) { bestCropTime.drawBestDisplay(it) } |