diff options
author | sayomaki <sayomayomaki@gmail.com> | 2024-05-30 05:08:34 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-29 23:08:34 +0200 |
commit | 0ae9e19f99e329858acf1154735b9c32aa72e049 (patch) | |
tree | 3f31aad100f8a671adf74b308eb35a912b13fde0 | |
parent | 2af916371b2edf71fb055a3f8de2bcd7b99b2251 (diff) | |
download | skyhanni-0ae9e19f99e329858acf1154735b9c32aa72e049.tar.gz skyhanni-0ae9e19f99e329858acf1154735b9c32aa72e049.tar.bz2 skyhanni-0ae9e19f99e329858acf1154735b9c32aa72e049.zip |
Feature: Show total amount of chocolate spent in chocolate shop (#1921)
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt index bbd4e6747..8152271fe 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateShopPrice.kt @@ -15,8 +15,11 @@ import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUItems.getPrice import at.hannibal2.skyhanni.utils.NEUItems.getPriceOrNull import at.hannibal2.skyhanni.utils.NumberUtil +import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.formatInt import at.hannibal2.skyhanni.utils.NumberUtil.million import at.hannibal2.skyhanni.utils.RegexUtils.groupOrNull +import at.hannibal2.skyhanni.utils.RegexUtils.matchFirst import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables @@ -40,11 +43,18 @@ object ChocolateShopPrice { "shop.bought", "§aYou bought §r§.(?<item>[\\w ]+)§r(?:§8 x(?<amount>\\d+)§r)?§a!" ) + private val chocolateSpentPattern by ChocolateFactoryAPI.patternGroup.pattern( + "shop.spent", + "§7Chocolate Spent: §6(?<amount>[\\d,]+)" + ) var inInventory = false private var callUpdate = false var inventoryItems = emptyMap<Int, ItemStack>() + private const val MILESTONE_INDEX = 50 + private var chocolateSpent = 0 + @SubscribeEvent fun onSecondPassed(event: SecondPassedEvent) { if (inInventory) { @@ -74,8 +84,14 @@ object ChocolateShopPrice { private fun updateProducts() { val newProducts = mutableListOf<Product>() for ((slot, item) in inventoryItems) { - val lore = item.getLore() + + if (slot == MILESTONE_INDEX) { + lore.matchFirst(chocolateSpentPattern) { + chocolateSpent = group("amount").formatInt() + } + } + val chocolate = ChocolateFactoryAPI.getChocolateBuyCost(lore) ?: continue val internalName = item.getInternalName() val itemPrice = internalName.getPriceOrNull() ?: continue @@ -132,6 +148,8 @@ object ChocolateShopPrice { // TODO update this value every second // TODO add time until can afford newList.add(Renderable.string("§eChocolate available: §6${ChocolateAmount.CURRENT.formatted}")) + // TODO add chocolate spend needed for next milestone + newList.add(Renderable.string("§eChocolate spent: §6${chocolateSpent.addSeparators()}")) newList.add(LorenzUtils.fillTable(table, padding = 5, itemScale = config.itemScale)) display = newList } |