aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2024-05-03 22:13:31 +1000
committerGitHub <noreply@github.com>2024-05-03 14:13:31 +0200
commite764894667a52c0774d9fee5ecf84bb00772b73d (patch)
tree608616cc075ecd488758ba1508be35f80fc92d29 /src/main/java/at/hannibal2
parent37a9fd7df3695fcc0fb4dd5427a91b73bdadefbb (diff)
downloadskyhanni-e764894667a52c0774d9fee5ecf84bb00772b73d.tar.gz
skyhanni-e764894667a52c0774d9fee5ecf84bb00772b73d.tar.bz2
skyhanni-e764894667a52c0774d9fee5ecf84bb00772b73d.zip
Improvement: Update saved chocolate when getting a duplicate rabbit (#1665)
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateAmount.kt16
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBarnManager.kt7
2 files changed, 21 insertions, 2 deletions
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\\+(?<amount>[\\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\\+(?<amount>[\\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())
}
}