diff options
author | Linnea Gräf <nea@nea.moe> | 2025-01-16 21:49:20 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2025-01-16 21:49:20 +0100 |
commit | 305178f5511bbf7b4499d7cf4142a067ab42e2fc (patch) | |
tree | 845b3cca6490fb9c1252215aa310eec108316bf1 /basetypes | |
parent | 40ed3a1f667d58501fc43fb45f53585315c013d1 (diff) | |
download | LocalTransactionLedger-305178f5511bbf7b4499d7cf4142a067ab42e2fc.tar.gz LocalTransactionLedger-305178f5511bbf7b4499d7cf4142a067ab42e2fc.tar.bz2 LocalTransactionLedger-305178f5511bbf7b4499d7cf4142a067ab42e2fc.zip |
refactor: Extract database models to own modules
Diffstat (limited to 'basetypes')
-rw-r--r-- | basetypes/src/main/kotlin/moe/nea/ledger/ItemChange.kt | 43 | ||||
-rw-r--r-- | basetypes/src/main/kotlin/moe/nea/ledger/TransactionType.kt | 35 |
2 files changed, 78 insertions, 0 deletions
diff --git a/basetypes/src/main/kotlin/moe/nea/ledger/ItemChange.kt b/basetypes/src/main/kotlin/moe/nea/ledger/ItemChange.kt new file mode 100644 index 0000000..6cadf27 --- /dev/null +++ b/basetypes/src/main/kotlin/moe/nea/ledger/ItemChange.kt @@ -0,0 +1,43 @@ +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 unpair(direction: ChangeDirection, pair: Pair<ItemId, Double>): ItemChange { + return ItemChange(pair.first, pair.second, direction) + } + + fun unpairGain(pair: Pair<ItemId, Double>) = unpair(ChangeDirection.GAINED, pair) + fun unpairLose(pair: Pair<ItemId, Double>) = unpair(ChangeDirection.LOST, pair) + + 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 diff --git a/basetypes/src/main/kotlin/moe/nea/ledger/TransactionType.kt b/basetypes/src/main/kotlin/moe/nea/ledger/TransactionType.kt new file mode 100644 index 0000000..33c633d --- /dev/null +++ b/basetypes/src/main/kotlin/moe/nea/ledger/TransactionType.kt @@ -0,0 +1,35 @@ +package moe.nea.ledger + +enum class TransactionType { + ACCESSORIES_SWAPPING, + ALLOWANCE_GAIN, + AUCTION_BOUGHT, + AUCTION_LISTING_CHARGE, + AUCTION_SOLD, + AUTOMERCHANT_PROFIT_COLLECT, + BANK_DEPOSIT, + BANK_WITHDRAW, + BAZAAR_BUY_INSTANT, + BAZAAR_BUY_ORDER, + BAZAAR_SELL_INSTANT, + BAZAAR_SELL_ORDER, + BITS_PURSE_STATUS, + BOOSTER_COOKIE_ATE, + CAPSAICIN_EYEDROPS_USED, + COMMUNITY_SHOP_BUY, + CORPSE_DESECRATED, + DIE_ROLLED, + DRACONIC_SACRIFICE, + DUNGEON_CHEST_OPEN, + FORGED, + GOD_POTION_DRANK, + GOD_POTION_MIXIN_DRANK, + KAT_TIMESKIP, + KAT_UPGRADE, + KISMET_REROLL, + KUUDRA_CHEST_OPEN, + NPC_BUY, + NPC_SELL, + VISITOR_BARGAIN, + WYRM_EVOKED, +}
\ No newline at end of file |