Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Show total amount of chocolate spent in chocolate shop #1921

Merged
merged 2 commits into from
May 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ 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.matchMatcher
Expand All @@ -40,11 +42,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>()

var milestoneIndex = 50
CalMWolfs marked this conversation as resolved.
Show resolved Hide resolved
var chocolateSpent = 0
CalMWolfs marked this conversation as resolved.
Show resolved Hide resolved

@SubscribeEvent
fun onSecondPassed(event: SecondPassedEvent) {
if (inInventory) {
Expand Down Expand Up @@ -74,6 +83,13 @@ object ChocolateShopPrice {
private fun updateProducts() {
val newProducts = mutableListOf<Product>()
for ((slot, item) in inventoryItems) {
if (slot == milestoneIndex) {
for (line in item.getLore()) {
chocolateSpentPattern.matchMatcher(line) {
chocolateSpent = group("amount").formatInt()
}
}
}

val lore = item.getLore()
CalMWolfs marked this conversation as resolved.
Show resolved Hide resolved
val chocolate = ChocolateFactoryAPI.getChocolateBuyCost(lore) ?: continue
Expand Down Expand Up @@ -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
}
Expand Down
Loading