aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--basetypes/src/main/kotlin/moe/nea/ledger/TransactionType.kt1
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/Ledger.kt2
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/modules/BankInterestDetection.kt38
3 files changed, 41 insertions, 0 deletions
diff --git a/basetypes/src/main/kotlin/moe/nea/ledger/TransactionType.kt b/basetypes/src/main/kotlin/moe/nea/ledger/TransactionType.kt
index a3910a0..288ba8c 100644
--- a/basetypes/src/main/kotlin/moe/nea/ledger/TransactionType.kt
+++ b/basetypes/src/main/kotlin/moe/nea/ledger/TransactionType.kt
@@ -8,6 +8,7 @@ enum class TransactionType {
AUCTION_SOLD,
AUTOMERCHANT_PROFIT_COLLECT,
BANK_DEPOSIT,
+ BANK_INTEREST,
BANK_WITHDRAW,
BAZAAR_BUY_INSTANT,
BAZAAR_BUY_ORDER,
diff --git a/mod/src/main/kotlin/moe/nea/ledger/Ledger.kt b/mod/src/main/kotlin/moe/nea/ledger/Ledger.kt
index 5db4346..06ee9c9 100644
--- a/mod/src/main/kotlin/moe/nea/ledger/Ledger.kt
+++ b/mod/src/main/kotlin/moe/nea/ledger/Ledger.kt
@@ -16,6 +16,7 @@ import moe.nea.ledger.modules.AccessorySwapperDetection
import moe.nea.ledger.modules.AllowanceDetection
import moe.nea.ledger.modules.AuctionHouseDetection
import moe.nea.ledger.modules.BankDetection
+import moe.nea.ledger.modules.BankInterestDetection
import moe.nea.ledger.modules.BazaarDetection
import moe.nea.ledger.modules.BazaarOrderDetection
import moe.nea.ledger.modules.BitsDetection
@@ -127,6 +128,7 @@ class Ledger {
AllowanceDetection::class.java,
AuctionHouseDetection::class.java,
BankDetection::class.java,
+ BankInterestDetection::class.java,
BazaarDetection::class.java,
BazaarOrderDetection::class.java,
BitsDetection::class.java,
diff --git a/mod/src/main/kotlin/moe/nea/ledger/modules/BankInterestDetection.kt b/mod/src/main/kotlin/moe/nea/ledger/modules/BankInterestDetection.kt
new file mode 100644
index 0000000..1e8da23
--- /dev/null
+++ b/mod/src/main/kotlin/moe/nea/ledger/modules/BankInterestDetection.kt
@@ -0,0 +1,38 @@
+package moe.nea.ledger.modules
+
+import moe.nea.ledger.ItemChange
+import moe.nea.ledger.LedgerEntry
+import moe.nea.ledger.LedgerLogger
+import moe.nea.ledger.SHORT_NUMBER_PATTERN
+import moe.nea.ledger.TransactionType
+import moe.nea.ledger.events.ChatReceived
+import moe.nea.ledger.parseShortNumber
+import moe.nea.ledger.useMatcher
+import moe.nea.ledger.utils.di.Inject
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import java.util.regex.Pattern
+
+
+class BankInterestDetection {
+
+ val bankInterestPattern =
+ Pattern.compile("You have just received (?<coins>$SHORT_NUMBER_PATTERN) coins as interest in your (co-op|personal) bank account!")
+
+ @Inject
+ lateinit var logger: LedgerLogger
+
+ @SubscribeEvent
+ fun onChat(event: ChatReceived) {
+ bankInterestPattern.useMatcher(event.message) {
+ logger.logEntry(
+ LedgerEntry(
+ TransactionType.BANK_WITHDRAW,
+ event.timestamp,
+ listOf(
+ ItemChange.gainCoins(parseShortNumber(group("coins"))),
+ )
+ )
+ )
+ }
+ }
+}