aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateAmount.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt25
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryInventory.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltip.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryUpgrade.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryUpgradeWarning.kt11
6 files changed, 30 insertions, 19 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 2c7c056ff..679001939 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
@@ -63,18 +63,18 @@ enum class ChocolateAmount(val chocolate: () -> Long) {
fun averageChocPerSecond(
baseMultiplierIncrease: Double = 0.0,
rawPerSecondIncrease: Int = 0,
- timeTowerLevelIncrease: Int = 0,
+ includeTower: Boolean = false,
): Double {
val profileStorage = profileStorage ?: return 0.0
val baseMultiplier = profileStorage.rawChocolateMultiplier + baseMultiplierIncrease
val rawPerSecond = profileStorage.rawChocPerSecond + rawPerSecondIncrease
- val timeTowerLevel = profileStorage.timeTowerLevel + timeTowerLevelIncrease
val timeTowerCooldown = profileStorage.timeTowerCooldown
val basePerSecond = rawPerSecond * baseMultiplier
- val towerCalc = (rawPerSecond * timeTowerLevel * .1) / timeTowerCooldown
+ if (!includeTower) return basePerSecond
+ val towerCalc = (rawPerSecond * .1) / timeTowerCooldown
return basePerSecond + towerCalc
}
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 e584537fd..6bf8850c2 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
@@ -91,6 +91,12 @@ object ChocolateFactoryDataLoader {
"Rabbit \\w+ - Unemployed"
)
+ // todo get coach jackrabbit when prestige 4
+ private val otherUpgradePattern by ChocolateFactoryAPI.patternGroup.pattern(
+ "other.upgrade",
+ "Rabbit Shrine"
+ )
+
@SubscribeEvent
fun onInventoryUpdated(event: InventoryUpdatedEvent) {
if (!ChocolateFactoryAPI.inChocolateFactory) return
@@ -126,6 +132,8 @@ object ChocolateFactoryDataLoader {
val barnItem = InventoryUtils.getItemAtSlotIndex(ChocolateFactoryAPI.barnIndex) ?: return
val timeTowerItem = InventoryUtils.getItemAtSlotIndex(ChocolateFactoryAPI.timeTowerIndex) ?: return
+ ChocolateFactoryAPI.factoryUpgrades.clear()
+
processChocolateItem(chocolateItem)
processPrestigeItem(prestigeItem)
processProductionItem(productionInfoItem)
@@ -133,8 +141,6 @@ object ChocolateFactoryDataLoader {
processBarnItem(barnItem)
processTimeTowerItem(timeTowerItem)
- ChocolateFactoryAPI.factoryUpgrades.clear()
-
profileStorage.rawChocPerSecond =
(ChocolateFactoryAPI.chocolatePerSecond / profileStorage.chocolateMultiplier).toInt()
profileStorage.lastDataSave = SimpleTimeMark.now().toMillis()
@@ -244,6 +250,8 @@ object ChocolateFactoryDataLoader {
val activeDuration = TimeUtils.getDuration(formattedGroup)
val activeUntil = SimpleTimeMark.now() + activeDuration
profileStorage.currentTimeTowerEnds = activeUntil.toMillis()
+ } else {
+ profileStorage.currentTimeTowerEnds = 0
}
}
timeTowerRechargePattern.matchMatcher(line) {
@@ -266,6 +274,7 @@ object ChocolateFactoryDataLoader {
}
private fun processItem(item: ItemStack, slotIndex: Int) {
+ if (slotIndex == ChocolateFactoryAPI.prestigeIndex) return
if (config.rabbitWarning && clickMeRabbitPattern.matches(item.name)) {
SoundUtils.playBeepSound()
ChocolateFactoryAPI.clickRabbitSlot = slotIndex
@@ -289,9 +298,7 @@ object ChocolateFactoryDataLoader {
level = rabbitAmountPattern.matchMatcher(itemName) {
group("amount").formatInt()
} ?: run {
- unemployedRabbitPattern.matchMatcher(itemName) {
- 0
- }
+ if (unemployedRabbitPattern.matches(itemName)) 0 else null
} ?: return
isRabbit = true
@@ -308,6 +315,8 @@ object ChocolateFactoryDataLoader {
in ChocolateFactoryAPI.otherUpgradeSlots -> {
level = upgradeTierPattern.matchMatcher(itemName) {
group("tier").romanToDecimal()
+ } ?: run {
+ if (otherUpgradePattern.matches(itemName)) 0 else null
} ?: return
if (slotIndex == ChocolateFactoryAPI.timeTowerIndex) this.profileStorage?.timeTowerLevel = level
@@ -320,7 +329,7 @@ object ChocolateFactoryDataLoader {
newAverageChocolate = when (slotIndex) {
ChocolateFactoryAPI.timeTowerIndex -> ChocolateAmount.averageChocPerSecond(
- timeTowerLevelIncrease = 1
+ includeTower = true
)
ChocolateFactoryAPI.coachRabbitIndex -> ChocolateAmount.averageChocPerSecond(
@@ -348,7 +357,9 @@ object ChocolateFactoryDataLoader {
private fun findBestUpgrades() {
val profileStorage = profileStorage ?: return
- val notMaxed = ChocolateFactoryAPI.factoryUpgrades.filter { !it.isMaxed }
+ // removing time tower here as people like to determine when to buy it themselves
+ val notMaxed = ChocolateFactoryAPI.factoryUpgrades
+ .filter { !it.isMaxed && it.slotIndex != ChocolateFactoryAPI.timeTowerIndex }
val bestUpgrade = notMaxed.minByOrNull { it.effectiveCost ?: Double.MAX_VALUE }
profileStorage.bestUpgradeAvailableAt = bestUpgrade?.canAffordAt?.toMillis() ?: 0
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryInventory.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryInventory.kt
index 45b6bde86..42dcdae8a 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryInventory.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryInventory.kt
@@ -44,7 +44,8 @@ object ChocolateFactoryInventory {
if (slot.stack == null) continue
val slotIndex = slot.slotNumber
- ChocolateFactoryAPI.factoryUpgrades.find { it.slotIndex == slotIndex }?.let { upgrade ->
+ val currentUpdates = ChocolateFactoryAPI.factoryUpgrades
+ currentUpdates.find { it.slotIndex == slotIndex }?.let { upgrade ->
if (upgrade.canAfford()) {
slot highlight LorenzColor.GREEN.addOpacity(75)
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltip.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltip.kt
index 4abc48561..b418c5ec2 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltip.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryTooltip.kt
@@ -34,7 +34,7 @@ object ChocolateFactoryTooltip {
if (upgradeInfo.effectiveCost == null) return
event.toolTip.add("§7Extra: §6${upgradeInfo.extraPerSecond?.round(2) ?: "N/A"} §7choc/s")
- event.toolTip.add("§7Effective Cost: §6${upgradeInfo.effectiveCost?.addSeparators() ?: "N/A"}")
+ event.toolTip.add("§7Effective Cost: §6${upgradeInfo.effectiveCost.addSeparators() ?: "N/A"}")
if (slotIndex == ChocolateFactoryAPI.timeTowerIndex) {
event.toolTip.add("§7One charge will give: §6${chocPerTimeTower().addSeparators()}")
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryUpgrade.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryUpgrade.kt
index 1358e197d..057dd4ae7 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryUpgrade.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryUpgrade.kt
@@ -12,7 +12,7 @@ data class ChocolateFactoryUpgrade(
val isPrestige: Boolean = false,
) {
private var chocolateAmountType = ChocolateAmount.CURRENT
- var isMaxed = price == null
+ val isMaxed = price == null
var canAffordAt: SimpleTimeMark? = null
init {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryUpgradeWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryUpgradeWarning.kt
index 93581401c..28e89855c 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryUpgradeWarning.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryUpgradeWarning.kt
@@ -37,17 +37,16 @@ object ChocolateFactoryUpgradeWarning {
if (ReminderUtils.isBusy()) return
if (lastUpgradeWarning.passedSince() < config.timeBetweenWarnings.minutes) return
lastUpgradeWarning = SimpleTimeMark.now()
-
+ if (config.upgradeWarningSound) {
+ SoundUtils.playBeepSound()
+ }
+ if (ChocolateFactoryAPI.inChocolateFactory) return
ChatUtils.clickableChat(
"You have a Chocolate factory upgrade available to purchase!",
onClick = {
HypixelCommands.chocolateFactory()
}
)
- if (config.upgradeWarningSound) {
- SoundUtils.playBeepSound()
- }
-
}
@SubscribeEvent
@@ -57,7 +56,7 @@ object ChocolateFactoryUpgradeWarning {
fun checkUpgradeChange(slot: Int, level: Int) {
if (slot != lastUpgradeSlot || level != lastUpgradeLevel) {
- lastUpgradeWarning = SimpleTimeMark.farPast()
+ lastUpgradeWarning = SimpleTimeMark.now()
lastUpgradeSlot = slot
lastUpgradeLevel = level
}