aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-05-02 15:44:04 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-05-02 15:44:04 +0200
commit76b523e1d947e69c5274c110fb32669b6d7b434c (patch)
tree78d39b6775d21cc29bcb5ebd9a17be2d2934878d /src/main/java
parent510c025c11a186254176273a93dcf48535907212 (diff)
downloadskyhanni-76b523e1d947e69c5274c110fb32669b6d7b434c.tar.gz
skyhanni-76b523e1d947e69c5274c110fb32669b6d7b434c.tar.bz2
skyhanni-76b523e1d947e69c5274c110fb32669b6d7b434c.zip
code cleanup
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt132
1 files changed, 67 insertions, 65 deletions
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 7a57e87db..969d39625 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
@@ -258,89 +258,91 @@ object ChocolateFactoryDataLoader {
}
private fun processInventory(inventory: Map<Int, ItemStack>) {
- val profileStorage = profileStorage ?: return
-
ChocolateFactoryAPI.clickRabbitSlot = null
for ((slotIndex, item) in inventory) {
- if (config.rabbitWarning && clickMeRabbitPattern.matches(item.name)) {
- SoundUtils.playBeepSound()
- ChocolateFactoryAPI.clickRabbitSlot = slotIndex
- }
+ processInventory(item, slotIndex)
+ }
+ }
+
+ private fun processInventory(item: ItemStack, slotIndex: Int) {
+ if (config.rabbitWarning && clickMeRabbitPattern.matches(item.name)) {
+ SoundUtils.playBeepSound()
+ ChocolateFactoryAPI.clickRabbitSlot = slotIndex
+ }
+
+ if (slotIndex !in ChocolateFactoryAPI.otherUpgradeSlots && slotIndex !in ChocolateFactoryAPI.rabbitSlots) return
+
+ val itemName = item.name.removeColor()
+ val lore = item.getLore()
+ val upgradeCost = ChocolateFactoryAPI.getChocolateBuyCost(lore)
+
+ val averageChocolate = ChocolateAmount.averageChocPerSecond().round(2)
+ val isMaxed = upgradeCost == null
- if (slotIndex !in ChocolateFactoryAPI.otherUpgradeSlots && slotIndex !in ChocolateFactoryAPI.rabbitSlots) continue
-
- val itemName = item.name.removeColor()
- val lore = item.getLore()
- val upgradeCost = ChocolateFactoryAPI.getChocolateBuyCost(lore)
-
- val averageChocolate = ChocolateAmount.averageChocPerSecond().round(2)
- val isMaxed = upgradeCost == null
-
- var isRabbit = false
- var level: Int? = null
- var newAverageChocolate: Double? = null
-
- when (slotIndex) {
- in ChocolateFactoryAPI.rabbitSlots -> {
- level = rabbitAmountPattern.matchMatcher(itemName) {
- group("amount").formatInt()
- } ?: run {
- unemployedRabbitPattern.matchMatcher(itemName) {
- 0
- }
- } ?: continue
- isRabbit = true
-
- if (isMaxed) {
- val rabbitUpgradeItem = ChocolateFactoryUpgrade(slotIndex, level, null, isRabbit = true)
- ChocolateFactoryAPI.factoryUpgrades.add(rabbitUpgradeItem)
- continue
+ var isRabbit = false
+ var level: Int? = null
+ var newAverageChocolate: Double? = null
+
+ when (slotIndex) {
+ in ChocolateFactoryAPI.rabbitSlots -> {
+ level = rabbitAmountPattern.matchMatcher(itemName) {
+ group("amount").formatInt()
+ } ?: run {
+ unemployedRabbitPattern.matchMatcher(itemName) {
+ 0
}
+ } ?: return
+ isRabbit = true
- val chocolateIncrease = ChocolateFactoryAPI.rabbitSlots[slotIndex] ?: 0
- newAverageChocolate = ChocolateAmount.averageChocPerSecond(rawPerSecondIncrease = chocolateIncrease)
+ if (isMaxed) {
+ val rabbitUpgradeItem = ChocolateFactoryUpgrade(slotIndex, level, null, isRabbit = true)
+ ChocolateFactoryAPI.factoryUpgrades.add(rabbitUpgradeItem)
+ return
}
- in ChocolateFactoryAPI.otherUpgradeSlots -> {
- level = upgradeTierPattern.matchMatcher(itemName) {
- group("tier").romanToDecimal()
- } ?: continue
+ val chocolateIncrease = ChocolateFactoryAPI.rabbitSlots[slotIndex] ?: 0
+ newAverageChocolate = ChocolateAmount.averageChocPerSecond(rawPerSecondIncrease = chocolateIncrease)
+ }
- if (slotIndex == ChocolateFactoryAPI.timeTowerIndex) profileStorage.timeTowerLevel = level
+ in ChocolateFactoryAPI.otherUpgradeSlots -> {
+ level = upgradeTierPattern.matchMatcher(itemName) {
+ group("tier").romanToDecimal()
+ } ?: return
- if (isMaxed) {
- val otherUpgrade = ChocolateFactoryUpgrade(slotIndex, level, null)
- ChocolateFactoryAPI.factoryUpgrades.add(otherUpgrade)
- continue
- }
+ if (slotIndex == ChocolateFactoryAPI.timeTowerIndex) this.profileStorage?.timeTowerLevel = level
- newAverageChocolate = when (slotIndex) {
- ChocolateFactoryAPI.timeTowerIndex -> ChocolateAmount.averageChocPerSecond(
- timeTowerLevelIncrease = 1
- )
+ if (isMaxed) {
+ val otherUpgrade = ChocolateFactoryUpgrade(slotIndex, level, null)
+ ChocolateFactoryAPI.factoryUpgrades.add(otherUpgrade)
+ return
+ }
- ChocolateFactoryAPI.coachRabbitIndex -> ChocolateAmount.averageChocPerSecond(
- baseMultiplierIncrease = 0.01
- )
+ newAverageChocolate = when (slotIndex) {
+ ChocolateFactoryAPI.timeTowerIndex -> ChocolateAmount.averageChocPerSecond(
+ timeTowerLevelIncrease = 1
+ )
- else -> {
- val otherUpgrade = ChocolateFactoryUpgrade(slotIndex, level, upgradeCost)
- ChocolateFactoryAPI.factoryUpgrades.add(otherUpgrade)
- continue
- }
+ ChocolateFactoryAPI.coachRabbitIndex -> ChocolateAmount.averageChocPerSecond(
+ baseMultiplierIncrease = 0.01
+ )
+
+ else -> {
+ val otherUpgrade = ChocolateFactoryUpgrade(slotIndex, level, upgradeCost)
+ ChocolateFactoryAPI.factoryUpgrades.add(otherUpgrade)
+ return
}
}
}
- if (level == null || newAverageChocolate == null || upgradeCost == null) continue
+ }
+ if (level == null || newAverageChocolate == null || upgradeCost == null) return
- val extra = (newAverageChocolate - averageChocolate).round(2)
- val effectiveCost = (upgradeCost / extra).round(2)
+ val extra = (newAverageChocolate - averageChocolate).round(2)
+ val effectiveCost = (upgradeCost / extra).round(2)
- val upgrade =
- ChocolateFactoryUpgrade(slotIndex, level, upgradeCost, extra, effectiveCost, isRabbit = isRabbit)
- ChocolateFactoryAPI.factoryUpgrades.add(upgrade)
- }
+ val upgrade =
+ ChocolateFactoryUpgrade(slotIndex, level, upgradeCost, extra, effectiveCost, isRabbit = isRabbit)
+ ChocolateFactoryAPI.factoryUpgrades.add(upgrade)
}
private fun findBestUpgrades() {