aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/ledger/ItemIdProvider.kt
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-12-21 01:54:06 +0100
committerLinnea Gräf <nea@nea.moe>2024-12-21 01:54:06 +0100
commit2cd351d816b7dad8c3251fcd640ff697335598a6 (patch)
tree6b84c071ae75925b760d55872f85636541b5d209 /src/main/kotlin/moe/nea/ledger/ItemIdProvider.kt
parent96d27f0cee274c6a687266c3e0aa315742094929 (diff)
downloadLocalTransactionLedger-2cd351d816b7dad8c3251fcd640ff697335598a6.tar.gz
LocalTransactionLedger-2cd351d816b7dad8c3251fcd640ff697335598a6.tar.bz2
LocalTransactionLedger-2cd351d816b7dad8c3251fcd640ff697335598a6.zip
feat: Add support for chocolate and copper to npc buys
Diffstat (limited to 'src/main/kotlin/moe/nea/ledger/ItemIdProvider.kt')
-rw-r--r--src/main/kotlin/moe/nea/ledger/ItemIdProvider.kt9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/ledger/ItemIdProvider.kt b/src/main/kotlin/moe/nea/ledger/ItemIdProvider.kt
index 72f1d09..7fe0206 100644
--- a/src/main/kotlin/moe/nea/ledger/ItemIdProvider.kt
+++ b/src/main/kotlin/moe/nea/ledger/ItemIdProvider.kt
@@ -106,6 +106,7 @@ class ItemIdProvider {
private val coinRegex = "(?<amount>$SHORT_NUMBER_PATTERN) Coins?".toPattern()
private val stackedItemRegex = "(?<name>.*) x(?<count>$SHORT_NUMBER_PATTERN)".toPattern()
private val essenceRegex = "(?<essence>.*) Essence x(?<count>$SHORT_NUMBER_PATTERN)".toPattern()
+ private val numberedItemRegex = "(?<count>$SHORT_NUMBER_PATTERN) (?<what>.*)".toPattern()
fun findCostItemsFromSpan(lore: List<String>): List<Pair<ItemId, Double>> {
return lore.iterator().asSequence()
@@ -161,6 +162,14 @@ class ItemIdProvider {
return Pair(item, count)
}
}
+ numberedItemRegex.useMatcher(properName) {
+ val item = findForName(group("what"), fallbackToGenerated)
+ if (item != null) {
+ val count = parseShortNumber(group("count"))
+ return Pair(item, count)
+ }
+ }
+
return findForName(properName, fallbackToGenerated)?.let { Pair(it, 1.0) }
}