From 0ae9e19f99e329858acf1154735b9c32aa72e049 Mon Sep 17 00:00:00 2001 From: sayomaki Date: Thu, 30 May 2024 05:08:34 +0800 Subject: Feature: Show total amount of chocolate spent in chocolate shop (#1921) --- .../inventory/chocolatefactory/ChocolateShopPrice.kt | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/main/java/at/hannibal2/skyhanni') 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§.(?[\\w ]+)§r(?:§8 x(?\\d+)§r)?§a!" ) + private val chocolateSpentPattern by ChocolateFactoryAPI.patternGroup.pattern( + "shop.spent", + "§7Chocolate Spent: §6(?[\\d,]+)" + ) var inInventory = false private var callUpdate = false var inventoryItems = emptyMap() + 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() 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 } -- cgit