diff options
Diffstat (limited to 'mod/src/main/kotlin/moe/nea')
-rw-r--r-- | mod/src/main/kotlin/moe/nea/ledger/Ledger.kt | 2 | ||||
-rw-r--r-- | mod/src/main/kotlin/moe/nea/ledger/modules/StonksAuctionDetection.kt | 59 |
2 files changed, 61 insertions, 0 deletions
diff --git a/mod/src/main/kotlin/moe/nea/ledger/Ledger.kt b/mod/src/main/kotlin/moe/nea/ledger/Ledger.kt index 6d3c592..87c990c 100644 --- a/mod/src/main/kotlin/moe/nea/ledger/Ledger.kt +++ b/mod/src/main/kotlin/moe/nea/ledger/Ledger.kt @@ -40,6 +40,7 @@ import moe.nea.ledger.modules.MineshaftCorpseDetection import moe.nea.ledger.modules.MinionDetection import moe.nea.ledger.modules.NpcDetection import moe.nea.ledger.modules.PestRepellentDetection +import moe.nea.ledger.modules.StonksAuctionDetection import moe.nea.ledger.modules.UpdateChecker import moe.nea.ledger.modules.VisitorDetection import moe.nea.ledger.telemetry.TelemetryProvider @@ -167,6 +168,7 @@ class Ledger { PestRepellentDetection::class.java, QueryCommand::class.java, RequestUtil::class.java, + StonksAuctionDetection::class.java, TriggerCommand::class.java, UpdateChecker::class.java, VisitorDetection::class.java, diff --git a/mod/src/main/kotlin/moe/nea/ledger/modules/StonksAuctionDetection.kt b/mod/src/main/kotlin/moe/nea/ledger/modules/StonksAuctionDetection.kt new file mode 100644 index 0000000..4f3706c --- /dev/null +++ b/mod/src/main/kotlin/moe/nea/ledger/modules/StonksAuctionDetection.kt @@ -0,0 +1,59 @@ +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.gen.ItemIds +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.Matcher +import java.util.regex.Pattern + +class StonksAuctionDetection { + + val stonksPlacedBid = + Pattern.compile("Successfully placed your Stonk bid of (?<coins>$SHORT_NUMBER_PATTERN) Coins!") + val stonksIncreaseBid = + Pattern.compile("Successfully increased your Stonk bid by (?<coins>$SHORT_NUMBER_PATTERN) Coins!") + val stonksClaim = + Pattern.compile("You claimed (?<count>$SHORT_NUMBER_PATTERN)x Stock of Stonks from the Stonks Auction!") + + @Inject + lateinit var logger: LedgerLogger + + @SubscribeEvent + fun onChat(event: ChatReceived) { + fun Matcher.logBidding() { + logger.logEntry( + LedgerEntry( + TransactionType.STONKS_AUCTION, + event.timestamp, + listOf( + ItemChange.loseCoins(parseShortNumber(group("coins"))), + ) + ) + ) + } + + fun Matcher.logClaim() { + logger.logEntry( + LedgerEntry( + TransactionType.STONKS_AUCTION, + event.timestamp, + listOf( + ItemChange.gain(ItemIds.STOCK_OF_STONKS, parseShortNumber(group("count"))) + ) + ) + ) + } + + stonksPlacedBid.useMatcher(event.message) { logBidding() } + stonksIncreaseBid.useMatcher(event.message) { logBidding() } + stonksClaim.useMatcher(event.message) { logClaim() } + } +} |