1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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)
}
}
}
|