diff options
author | Linnea Gräf <nea@nea.moe> | 2024-10-30 19:01:07 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-10-30 19:01:16 +0100 |
commit | 3001af7c4277c96f2818ea2efe3c7836b1f1498f (patch) | |
tree | 03003b0de745e71226420e005acefc03fe4d4d48 | |
parent | 6c793e838599fa30494893eccab52f9e86c69d4f (diff) | |
download | LocalTransactionLedger-3001af7c4277c96f2818ea2efe3c7836b1f1498f.tar.gz LocalTransactionLedger-3001af7c4277c96f2818ea2efe3c7836b1f1498f.tar.bz2 LocalTransactionLedger-3001af7c4277c96f2818ea2efe3c7836b1f1498f.zip |
fix: single buy/sell npc detection
-rw-r--r-- | src/main/kotlin/moe/nea/ledger/NpcDetection.kt | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/main/kotlin/moe/nea/ledger/NpcDetection.kt b/src/main/kotlin/moe/nea/ledger/NpcDetection.kt index 656f1d6..65693ef 100644 --- a/src/main/kotlin/moe/nea/ledger/NpcDetection.kt +++ b/src/main/kotlin/moe/nea/ledger/NpcDetection.kt @@ -6,9 +6,9 @@ import java.util.regex.Pattern class NpcDetection(val ledger: LedgerLogger, val ids: ItemIdProvider) { val npcBuyPattern = - Pattern.compile("You bought (?<what>.*?) x(?<count>$SHORT_NUMBER_PATTERN) for (?<coins>$SHORT_NUMBER_PATTERN) Coins!") + Pattern.compile("You bought (?<what>.*?) (x(?<count>$SHORT_NUMBER_PATTERN) )?for (?<coins>$SHORT_NUMBER_PATTERN) Coins!") val npcSellPattern = - Pattern.compile("You sold (?<what>.*) x(?<count>$SHORT_NUMBER_PATTERN) for (?<coins>$SHORT_NUMBER_PATTERN) Coins!") + Pattern.compile("You sold (?<what>.*) (x(?<count>$SHORT_NUMBER_PATTERN) )?for (?<coins>$SHORT_NUMBER_PATTERN) Coins!") @SubscribeEvent fun onNpcBuy(event: ChatReceived) { @@ -19,7 +19,7 @@ class NpcDetection(val ledger: LedgerLogger, val ids: ItemIdProvider) { event.timestamp, parseShortNumber(group("coins")), ids.findForName(group("what")), - parseShortNumber(group("count")).toInt(), + group("count")?.let(::parseShortNumber)?.toInt() ?: 1, ) ) } @@ -30,7 +30,7 @@ class NpcDetection(val ledger: LedgerLogger, val ids: ItemIdProvider) { event.timestamp, parseShortNumber(group("coins")), ids.findForName(group("what")), - parseShortNumber(group("count")).toInt(), + group("count")?.let(::parseShortNumber)?.toInt() ?: 1, ) ) } |