From 5459fc8aa33915e8d4be0c538dbb19a5e80d29db Mon Sep 17 00:00:00 2001 From: minhperry <46137516+minhperry@users.noreply.github.com> Date: Thu, 12 Sep 2024 02:15:38 +0200 Subject: Improvement: Chocolate Factory time to next instead of max milestone (#2503) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../jsonobjects/repo/HoppityEggLocationsJson.kt | 3 ++- .../chocolatefactory/ChocolateFactoryAPI.kt | 29 +++++++++++----------- .../chocolatefactory/ChocolateFactoryStats.kt | 13 +++++----- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/HoppityEggLocationsJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/HoppityEggLocationsJson.kt index 5e601ed32..4ad81b06a 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/HoppityEggLocationsJson.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/HoppityEggLocationsJson.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.data.jsonobjects.repo import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.utils.LorenzVec import com.google.gson.annotations.Expose +import java.util.TreeSet data class HoppityEggLocationsJson( @Expose val eggLocations: Map>, @@ -21,7 +22,7 @@ data class HoppityEggLocationsJson( @Expose val coachRabbitIndex: Int, @Expose val maxRabbits: Int, @Expose val maxPrestige: Int, - @Expose val maxMilestoneChocolate: Long, + @Expose val chocolateMilestones: TreeSet, @Expose val apiEggLocations: Map>, @Expose val specialRabbits: List, ) 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 59a119bf5..40cd700c4 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 @@ -20,13 +20,13 @@ import at.hannibal2.skyhanni.utils.RegexUtils.firstMatcher import at.hannibal2.skyhanni.utils.RegexUtils.groupOrNull import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matches -import at.hannibal2.skyhanni.utils.SkyblockSeason import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.UtilsPatterns import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraft.item.ItemStack import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.util.TreeSet import kotlin.time.Duration import kotlin.time.Duration.Companion.hours import kotlin.time.Duration.Companion.seconds @@ -80,7 +80,7 @@ object ChocolateFactoryAPI { var shrineIndex = 41 var coachRabbitIndex = 42 var maxRabbits = 395 - var maxMilestoneChocolate = 700_000_000_000L + var chocolateMilestones = TreeSet() private var maxPrestige = 5 var inChocolateFactory = false @@ -142,7 +142,7 @@ object ChocolateFactoryAPI { coachRabbitIndex = data.coachRabbitIndex maxRabbits = data.maxRabbits maxPrestige = data.maxPrestige - maxMilestoneChocolate = data.maxMilestoneChocolate + chocolateMilestones = data.chocolateMilestones specialRabbitTextures = data.specialRabbits ChocolateFactoryUpgrade.updateIgnoredSlots() @@ -179,23 +179,24 @@ object ChocolateFactoryAPI { } } - fun getNextLevelName(stack: ItemStack): String? = - upgradeLorePattern.firstMatcher(stack.getLore()) { - val upgradeName = if (stack.getLore().any { it == "§8Employee" }) employeeNamePattern.matchMatcher(stack.name) { - groupOrNull("employee") - } else groupOrNull("upgradename") - val nextLevel = groupOrNull("nextlevel") ?: groupOrNull("nextlevelalt") - if (upgradeName == null || nextLevel == null) null - else "$upgradeName $nextLevel" - } + fun getNextLevelName(stack: ItemStack): String? = upgradeLorePattern.firstMatcher(stack.getLore()) { + val upgradeName = if (stack.getLore().any { it == "§8Employee" }) employeeNamePattern.matchMatcher(stack.name) { + groupOrNull("employee") + } else groupOrNull("upgradename") + val nextLevel = groupOrNull("nextlevel") ?: groupOrNull("nextlevelalt") + if (upgradeName == null || nextLevel == null) null + else "$upgradeName $nextLevel" + } + fun getNextMilestoneChocolate(amount: Long): Long { + return chocolateMilestones.higher(amount) ?: 0 + } fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled fun isMaxPrestige() = currentPrestige >= maxPrestige - fun timeTowerChargeDuration() = - if (HoppityCollectionStats.hasFoundRabbit("Einstein")) 7.hours else 8.hours + fun timeTowerChargeDuration() = if (HoppityCollectionStats.hasFoundRabbit("Einstein")) 7.hours else 8.hours fun timeTowerMultiplier(): Double { var multiplier = (profileStorage?.timeTowerLevel ?: 0) * 0.1 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 cc193f2ef..8d08e485e 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 @@ -113,15 +113,16 @@ object ChocolateFactoryStats { ) if (ChocolateFactoryAPI.isMaxPrestige()) { - val chocolateUntilMaxMilestone = ChocolateFactoryAPI.maxMilestoneChocolate - val amountUntilMaxMilestone = chocolateUntilMaxMilestone - ChocolateAmount.ALL_TIME.chocolate() - val maxMilestoneEstimate = ChocolateAmount.ALL_TIME.formattedTimeUntilGoal(chocolateUntilMaxMilestone) + val allTime = ChocolateAmount.ALL_TIME.chocolate() + val nextChocolateMilestone = ChocolateFactoryAPI.getNextMilestoneChocolate(allTime) + val amountUntilNextMilestone = nextChocolateMilestone - allTime + val maxMilestoneEstimate = ChocolateAmount.ALL_TIME.formattedTimeUntilGoal(nextChocolateMilestone) - if (amountUntilMaxMilestone >= 0) { - put(ChocolateFactoryStat.TIME_TO_PRESTIGE, "§eTime To Max Milestone: $maxMilestoneEstimate") + if (amountUntilNextMilestone >= 0) { + put(ChocolateFactoryStat.TIME_TO_PRESTIGE, "§eTime To Next Milestone: $maxMilestoneEstimate") put( ChocolateFactoryStat.CHOCOLATE_UNTIL_PRESTIGE, - "§eChocolate To Max Milestone: §6${amountUntilMaxMilestone.addSeparators()}", + "§eChocolate To Next Milestone: §6${amountUntilNextMilestone.addSeparators()}", ) } } else { -- cgit