From 1de910a9ae9ab96fa75044367f9546d671fbcba1 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Mon, 7 Oct 2024 12:09:22 +0200 Subject: Fix: Hoppity > max (#2688) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../skyhanni/config/storage/ProfileSpecificStorage.java | 3 +++ .../features/inventory/chocolatefactory/ChocolateAmount.kt | 1 + .../inventory/chocolatefactory/ChocolateFactoryAPI.kt | 4 ++++ .../inventory/chocolatefactory/ChocolateFactoryDataLoader.kt | 11 +++++++++++ .../inventory/chocolatefactory/ChocolateFactoryStats.kt | 5 ++++- 5 files changed, 23 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java index 754eea3bb..4ccb0823d 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java @@ -102,6 +102,9 @@ public class ProfileSpecificStorage { @Expose public long currentChocolate = 0; + @Expose + public long maxChocolate = 0; + @Expose public long chocolateThisPrestige = 0; diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateAmount.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateAmount.kt index 7f0694e2a..1f1f6d0c0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateAmount.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateAmount.kt @@ -31,6 +31,7 @@ enum class ChocolateAmount(val chocolate: () -> Long) { companion object { fun chocolateSinceUpdate(): Long { + if (ChocolateFactoryAPI.isMax()) return 0L val lastUpdate = profileStorage?.lastDataSave ?: return 0 val currentTime = SimpleTimeMark.now() val secondsSinceUpdate = (currentTime - lastUpdate).inWholeSeconds diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt index 112e8a7a7..195ea51d3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt @@ -239,4 +239,8 @@ object ChocolateFactoryAPI { it.rabbit.removeColor() == rabbitName.removeColor() } } + + fun isMax(): Boolean = profileStorage?.let { + it.maxChocolate == it.currentChocolate + } ?: false } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt index eebbb19e9..64a99a8c9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt @@ -51,6 +51,14 @@ object ChocolateFactoryDataLoader { "chocolate.thisprestige", "§7Chocolate this Prestige: §6(?[\\d,]+)", ) + + /** + * REGEX-TEST: §7Max Chocolate: §660B + */ + private val maxChocolatePattern by ChocolateFactoryAPI.patternGroup.pattern( + "chocolate.max", + "§7Max Chocolate: §6(?.*)", + ) private val chocolateForPrestigePattern by ChocolateFactoryAPI.patternGroup.pattern( "chocolate.forprestige", "§7§cRequires (?\\w+) Chocolate this.*", @@ -230,6 +238,9 @@ object ChocolateFactoryDataLoader { chocolateThisPrestigePattern.matchMatcher(line) { profileStorage.chocolateThisPrestige = group("amount").formatLong() } + maxChocolatePattern.matchMatcher(line) { + profileStorage.maxChocolate = group("max").formatLong() + } chocolateForPrestigePattern.matchMatcher(line) { ChocolateFactoryAPI.chocolateForPrestige = group("amount").formatLong() prestigeCost = ChocolateFactoryAPI.chocolateForPrestige diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStats.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStats.kt index 8d08e485e..36c79728c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStats.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryStats.kt @@ -76,7 +76,10 @@ object ChocolateFactoryStats { val map = buildMap { put(ChocolateFactoryStat.HEADER, "§6§lChocolate Factory ${ChocolateFactoryAPI.currentPrestige.toRoman()}") - put(ChocolateFactoryStat.CURRENT, "§eCurrent Chocolate: §6${ChocolateAmount.CURRENT.formatted}") + val maxSuffix = if (ChocolateFactoryAPI.isMax()) { + " §cMax!" + } else "" + put(ChocolateFactoryStat.CURRENT, "§eCurrent Chocolate: §6${ChocolateAmount.CURRENT.formatted}$maxSuffix") put(ChocolateFactoryStat.THIS_PRESTIGE, "§eThis Prestige: §6${ChocolateAmount.PRESTIGE.formatted}") put(ChocolateFactoryStat.ALL_TIME, "§eAll-time: §6${ChocolateAmount.ALL_TIME.formatted}") -- cgit