aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/ledger/BankDetection.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/moe/nea/ledger/BankDetection.kt')
-rw-r--r--src/main/kotlin/moe/nea/ledger/BankDetection.kt40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/ledger/BankDetection.kt b/src/main/kotlin/moe/nea/ledger/BankDetection.kt
new file mode 100644
index 0000000..6e54539
--- /dev/null
+++ b/src/main/kotlin/moe/nea/ledger/BankDetection.kt
@@ -0,0 +1,40 @@
+package moe.nea.ledger
+
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import java.util.regex.Pattern
+
+class BankDetection(val ledger: LedgerLogger) {
+
+ /*
+ You have withdrawn 1M coins! You now have 518M coins in your account!
+ You have deposited 519M coins! You now have 519M coins in your account!
+ */
+
+
+ val withdrawPattern =
+ Pattern.compile("^You have withdrawn (?<amount>$SHORT_NUMBER_PATTERN) coins?! You now have (?<newtotal>$SHORT_NUMBER_PATTERN) coins? in your account!$")
+ val depositPattern =
+ Pattern.compile("^You have deposited (?<amount>$SHORT_NUMBER_PATTERN) coins?! You now have (?<newtotal>$SHORT_NUMBER_PATTERN) coins? in your account!$")
+ @SubscribeEvent
+ fun onChat(event: ChatReceived) {
+ withdrawPattern.useMatcher(event.message) {
+ ledger.logEntry(
+ LedgerEntry(
+ "BANK_WITHDRAW",
+ event.timestamp,
+ parseShortNumber(group("amount")),
+ )
+ )
+ }
+ depositPattern.useMatcher(event.message) {
+ ledger.logEntry(
+ LedgerEntry(
+ "BANK_DEPOSIT",
+ event.timestamp,
+ parseShortNumber(group("amount")),
+ )
+ )
+ }
+ }
+
+}