aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralexia <me@alexia.lol>2023-12-09 21:35:21 +0100
committerGitHub <noreply@github.com>2023-12-09 21:35:21 +0100
commit1055c493987469ca143cb6890c6455f45cdf9ac0 (patch)
tree1a343bb6170ceb0fb41aa1c9e858ea56066b017e
parent4131b3423182a1600e3ad903b18de1c5dd1b229c (diff)
downloadskyhanni-1055c493987469ca143cb6890c6455f45cdf9ac0.tar.gz
skyhanni-1055c493987469ca143cb6890c6455f45cdf9ac0.tar.bz2
skyhanni-1055c493987469ca143cb6890c6455f45cdf9ac0.zip
Display Farming Fortune reduction from pests on HUD (#782)
Display Farming Fortune reduction from pests on HUD. #782
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt24
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt6
2 files changed, 28 insertions, 2 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt
index 9fa7d7257..edd91e8c8 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt
@@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.data.CropAccessoryData
import at.hannibal2.skyhanni.data.GardenCropMilestones
import at.hannibal2.skyhanni.data.GardenCropMilestones.getCounter
import at.hannibal2.skyhanni.data.GardenCropUpgrades.Companion.getUpgradeLevel
+import at.hannibal2.skyhanni.data.ScoreboardData
import at.hannibal2.skyhanni.events.GardenToolChangeEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
@@ -13,6 +14,7 @@ import at.hannibal2.skyhanni.events.PreProfileSwitchEvent
import at.hannibal2.skyhanni.events.TabListUpdateEvent
import at.hannibal2.skyhanni.features.garden.CropType.Companion.getTurboCrop
import at.hannibal2.skyhanni.features.garden.GardenAPI.addCropIcon
+import at.hannibal2.skyhanni.features.garden.pests.PestFinder
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.LorenzUtils
@@ -122,6 +124,17 @@ class FarmingFortuneDisplay {
}
})
+ for (line in ScoreboardData.sidebarLinesFormatted) {
+ PestFinder.pestsInScoreboardPattern.matchMatcher(line) {
+ val pests = group("pests").toInt()
+ val ffReduction = getPestFFReduction(pests)
+ if (ffReduction > 0) {
+ updatedDisplay.addAsSingletonList("§cPests are reducing your fortune by §e$ffReduction%§c!")
+ }
+ break
+ }
+ }
+
if (wrongTabCrop) {
var text = "§cBreak §e${GardenAPI.cropInHand?.cropName}§c to see"
if (farmingFortune != -1.0) text += " latest"
@@ -147,6 +160,17 @@ class FarmingFortuneDisplay {
private fun isEnabled(): Boolean = GardenAPI.inGarden() && config.display
+ private fun getPestFFReduction(pests: Int): Int {
+ return when (pests) {
+ in 0..3 -> 0
+ 4 -> 5
+ 5 -> 15
+ 6 -> 30
+ 7 -> 50
+ else -> 75
+ }
+ }
+
companion object {
private val config get() = GardenAPI.config.farmingFortunes
private val latestFF: MutableMap<CropType, Double>? get() = GardenAPI.storage?.latestTrueFarmingFortune
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt
index f2241090d..e1b0e2055 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestFinder.kt
@@ -38,8 +38,6 @@ class PestFinder {
private val config get() = PestAPI.config.pestFinder
- private val pestsInScoreboardPattern = " §7⏣ §[ac]The Garden §4§lൠ§7 x(?<pests>.*)".toPattern()
-
private var display = emptyList<Renderable>()
private var scoreboardPests = 0
private var lastTimeVacuumHold = SimpleTimeMark.farPast()
@@ -233,4 +231,8 @@ class PestFinder {
}
fun isEnabled() = GardenAPI.inGarden() && (config.showDisplay || config.showPlotInWorld)
+
+ companion object {
+ val pestsInScoreboardPattern = " §7⏣ §[ac]The Garden §4§lൠ§7 x(?<pests>.*)".toPattern()
+ }
}