From b0fb9180d1d47c5bd01de536965cf3f630bfc1ba Mon Sep 17 00:00:00 2001 From: alexia Date: Thu, 11 Jan 2024 13:38:45 +0100 Subject: Add ability to get unique visitors served without Green Thumb (#832) Added ability to get unique visitors served without Green Thumb. #832 --- .../features/garden/FarmingFortuneDisplay.kt | 6 ++++ .../garden/fortuneguide/CaptureFarmingGear.kt | 33 ++++++++++++++++++++++ 2 files changed, 39 insertions(+) (limited to 'src/main/java/at/hannibal2') 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 d40d02718..c7f05d807 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt @@ -139,6 +139,12 @@ class FarmingFortuneDisplay { if (upgradeFortune == null) { updatedDisplay.addAsSingletonList("§cOpen §e/cropupgrades§c for more exact data!") } + + val uniqueVisitors = GardenAPI.storage?.uniqueVisitors?.toDouble() ?: 0.0 + if (uniqueVisitors == 0.0) { + updatedDisplay.addAsSingletonList("§cOpen §e/visitormilestones§c for more exact data!") + } + if (accessoryFortune == null) { updatedDisplay.addAsSingletonList("§cOpen Accessory Bag for more exact data!") if (CropAccessoryData.isLoadingAccessories) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt index 3f39ac198..2b3e5d04a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt @@ -18,6 +18,7 @@ import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEnchantments import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TabListData +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.math.round import kotlin.time.Duration.Companion.days @@ -37,6 +38,9 @@ class CaptureFarmingGear { private val cakePattern = "(?:Big )?Yum! You (?:gain|refresh) [+]5☘ Farming Fortune for 48 hours!".toPattern() + private val tierPattern by RepoPattern.pattern("garden.uniqueVisitors.tier", "§7Progress to Tier (?\\d+):.*") + private val tierProgressPattern by RepoPattern.pattern("garden.uniqueVisitors.tierProgress", ".* §e(?.*)§6/(?.*)") + companion object { private val strengthPattern = " Strength: §r§c❁(?.*)".toPattern() private val farmingSets = arrayListOf( @@ -90,6 +94,16 @@ class CaptureFarmingGear { storage.pumpkinFortune = !storage.pumpkinFortune LorenzUtils.chat("Toggled expired pumpkin fortune to: ${storage.pumpkinFortune}") } + + private fun getUniqueVisitorsForTier(tier: Int): Int { + return when { + tier == 0 -> 0 + tier == 1 -> 1 + tier == 2 -> 5 + tier >= 3 -> 10 * (tier - 2) + else -> throw IllegalStateException("Unexpected unique visitors tier: $tier") + } + } } @SubscribeEvent @@ -214,6 +228,25 @@ class CaptureFarmingGear { storage.anitaUpgrade = level } } + if (event.inventoryName.contains("Visitor Milestones")) { + for ((_, item) in event.inventoryItems) { + if (item.displayName != "§aUnique Visitors Served") continue + + var tier = -1 + var tierProgress = -1 + for (line in item.getLore()) { + tierPattern.matchMatcher(line) { + tier = group("nextTier").toInt() - 1 + } + tierProgressPattern.matchMatcher(line) { + tierProgress = group("having").toInt() + } + } + if (tier > -1 && tierProgress > -1) { + GardenAPI.storage?.uniqueVisitors = getUniqueVisitorsForTier(tier) + tierProgress + } + } + } } @SubscribeEvent -- cgit