From fa72dd4ce107190cda7bc56234fed650f20e3aa9 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Sun, 8 Dec 2024 00:42:01 +0100 Subject: feat: Add visitor trading detection --- src/main/kotlin/moe/nea/ledger/ItemChange.kt | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/main/kotlin/moe/nea/ledger/ItemChange.kt (limited to 'src/main/kotlin/moe/nea/ledger/ItemChange.kt') diff --git a/src/main/kotlin/moe/nea/ledger/ItemChange.kt b/src/main/kotlin/moe/nea/ledger/ItemChange.kt new file mode 100644 index 0000000..a8bb7e8 --- /dev/null +++ b/src/main/kotlin/moe/nea/ledger/ItemChange.kt @@ -0,0 +1,33 @@ +package moe.nea.ledger + +data class ItemChange( + val itemId: ItemId, + val count: Double, + val direction: ChangeDirection, +) { + enum class ChangeDirection { + GAINED, + TRANSFORM, + SYNC, + CATALYST, + LOST; + } + + companion object { + fun gainCoins(number: Double): ItemChange { + return gain(ItemId.COINS, number) + } + + fun gain(itemId: ItemId, amount: Number): ItemChange { + return ItemChange(itemId, amount.toDouble(), ChangeDirection.GAINED) + } + + fun lose(itemId: ItemId, amount: Number): ItemChange { + return ItemChange(itemId, amount.toDouble(), ChangeDirection.LOST) + } + + fun loseCoins(number: Double): ItemChange { + return lose(ItemId.COINS, number) + } + } +} \ No newline at end of file -- cgit