From 305178f5511bbf7b4499d7cf4142a067ab42e2fc Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Thu, 16 Jan 2025 21:49:20 +0100 Subject: refactor: Extract database models to own modules --- .../src/main/kotlin/moe/nea/ledger/ItemChange.kt | 43 ++++++++++++++++++++++ .../main/kotlin/moe/nea/ledger/TransactionType.kt | 35 ++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 basetypes/src/main/kotlin/moe/nea/ledger/ItemChange.kt create mode 100644 basetypes/src/main/kotlin/moe/nea/ledger/TransactionType.kt (limited to 'basetypes') 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): ItemChange { + return ItemChange(pair.first, pair.second, direction) + } + + fun unpairGain(pair: Pair) = unpair(ChangeDirection.GAINED, pair) + fun unpairLose(pair: Pair) = 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 -- cgit