diff options
Diffstat (limited to 'src/main')
-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 } |