From e764894667a52c0774d9fee5ecf84bb00772b73d Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Fri, 3 May 2024 22:13:31 +1000 Subject: Improvement: Update saved chocolate when getting a duplicate rabbit (#1665) --- .../inventory/chocolatefactory/ChocolateAmount.kt | 16 ++++++++++++++++ .../chocolatefactory/ChocolateFactoryBarnManager.kt | 7 +++++-- 2 files changed, 21 insertions(+), 2 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni') 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 679001939..9351dac40 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 @@ -78,5 +78,21 @@ enum class ChocolateAmount(val chocolate: () -> Long) { return basePerSecond + towerCalc } + + fun addToAll(amount: Long) { + profileStorage?.let { + it.currentChocolate += amount + it.chocolateThisPrestige += amount + it.chocolateAllTime += amount + updateBestUpgrade(amount) + } + } + + private fun updateBestUpgrade(price: Long) { + profileStorage?.let { + val canAffordAt = SimpleTimeMark.now() + CURRENT.timeUntilGoal(it.bestUpgradeCost) + it.bestUpgradeAvailableAt = canAffordAt.toMillis() + } + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBarnManager.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBarnManager.kt index 10440ee96..5d0a5c817 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBarnManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBarnManager.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggsManager import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.NumberUtil.formatLong import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher @@ -22,7 +23,7 @@ object ChocolateFactoryBarnManager { ) private val rabbitDuplicatePattern by ChocolateFactoryAPI.patternGroup.pattern( "rabbit.duplicate", - "§7§lDUPLICATE RABBIT! §6\\+[\\d,]+ Chocolate" + "§7§lDUPLICATE RABBIT! §6\\+(?[\\d,]+) Chocolate" ) /** @@ -30,7 +31,7 @@ object ChocolateFactoryBarnManager { */ private val rabbitCrashedPattern by ChocolateFactoryAPI.patternGroup.pattern( "rabbit.crushed", - "§c§lBARN FULL! §f\\D+ §7got §ccrushed§7! §6.+ Chocolate" + "§c§lBARN FULL! §f\\D+ §7got §ccrushed§7! §6\\+(?[\\d,]+) Chocolate" ) var barnFull = false @@ -49,10 +50,12 @@ object ChocolateFactoryBarnManager { rabbitDuplicatePattern.matchMatcher(event.message) { HoppityEggsManager.shareWaypointPrompt() + ChocolateAmount.addToAll(group("amount").formatLong()) } rabbitCrashedPattern.matchMatcher(event.message) { HoppityEggsManager.shareWaypointPrompt() + ChocolateAmount.addToAll(group("amount").formatLong()) } } -- cgit