diff options
Diffstat (limited to 'src/main/kotlin/moe/nea/ledger/modules/MinionDetection.kt')
-rw-r--r-- | src/main/kotlin/moe/nea/ledger/modules/MinionDetection.kt | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/main/kotlin/moe/nea/ledger/modules/MinionDetection.kt b/src/main/kotlin/moe/nea/ledger/modules/MinionDetection.kt index 73d06fa..1b48095 100644 --- a/src/main/kotlin/moe/nea/ledger/modules/MinionDetection.kt +++ b/src/main/kotlin/moe/nea/ledger/modules/MinionDetection.kt @@ -1,12 +1,15 @@ package moe.nea.ledger.modules -import moe.nea.ledger.events.BeforeGuiAction -import moe.nea.ledger.events.ChatReceived import moe.nea.ledger.ExpiringValue +import moe.nea.ledger.ItemChange +import moe.nea.ledger.ItemId import moe.nea.ledger.LedgerEntry import moe.nea.ledger.LedgerLogger import moe.nea.ledger.ROMAN_NUMBER_PATTERN import moe.nea.ledger.SHORT_NUMBER_PATTERN +import moe.nea.ledger.TransactionType +import moe.nea.ledger.events.BeforeGuiAction +import moe.nea.ledger.events.ChatReceived import moe.nea.ledger.parseRomanNumber import moe.nea.ledger.parseShortNumber import moe.nea.ledger.unformattedString @@ -23,7 +26,7 @@ class MinionDetection @Inject constructor(val ledger: LedgerLogger) { val hopperCollectPattern = "You received (?<amount>$SHORT_NUMBER_PATTERN) coins?!".toPattern() val minionNamePattern = "(?<name>.*) Minion (?<level>$ROMAN_NUMBER_PATTERN)".toPattern() - var lastOpenedMinion = ExpiringValue.empty<String>() + var lastOpenedMinion = ExpiringValue.empty<ItemId>() @SubscribeEvent fun onBeforeClaim(event: BeforeGuiAction) { @@ -33,7 +36,9 @@ class MinionDetection @Inject constructor(val ledger: LedgerLogger) { minionNamePattern.useMatcher(invName) { val name = group("name") val level = parseRomanNumber(group("level")) - lastOpenedMinion = ExpiringValue(name.uppercase().replace(" ", "_") + "_" + level) + lastOpenedMinion = ExpiringValue( + ItemId(name.uppercase().replace(" ", "_") + .replace("MINION", "GENERATOR") + "_" + level)) } } @@ -43,10 +48,12 @@ class MinionDetection @Inject constructor(val ledger: LedgerLogger) { hopperCollectPattern.useMatcher(event.message) { val minionName = lastOpenedMinion.consume(3.seconds) ledger.logEntry(LedgerEntry( - "AUTOMERCHANT_PROFIT_COLLECT", + TransactionType.AUTOMERCHANT_PROFIT_COLLECT, Instant.now(), - parseShortNumber(group("amount")), - minionName, // TODO: switch to its own column idk + listOf( + ItemChange.gainCoins(parseShortNumber(group("amount"))), + ItemChange(minionName ?: ItemId.NIL, 1.0, ItemChange.ChangeDirection.CATALYST) + ), )) } } |