diff options
author | Linnea Gräf <nea@nea.moe> | 2025-01-08 19:25:29 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2025-01-08 19:25:29 +0100 |
commit | d1e16a47819509ed645bb93e1a173e0a97025cef (patch) | |
tree | efbe886d9ac1ab4ea01788cb4842812fd0af9079 /src/main/kotlin/moe/nea/ledger/ItemChange.kt | |
parent | f694daf322bbb4ff530a9332547c5c8337c3e0c0 (diff) | |
download | LocalTransactionLedger-d1e16a47819509ed645bb93e1a173e0a97025cef.tar.gz LocalTransactionLedger-d1e16a47819509ed645bb93e1a173e0a97025cef.tar.bz2 LocalTransactionLedger-d1e16a47819509ed645bb93e1a173e0a97025cef.zip |
build: Move mod to subproject
Diffstat (limited to 'src/main/kotlin/moe/nea/ledger/ItemChange.kt')
-rw-r--r-- | src/main/kotlin/moe/nea/ledger/ItemChange.kt | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/src/main/kotlin/moe/nea/ledger/ItemChange.kt b/src/main/kotlin/moe/nea/ledger/ItemChange.kt deleted file mode 100644 index fda709c..0000000 --- a/src/main/kotlin/moe/nea/ledger/ItemChange.kt +++ /dev/null @@ -1,84 +0,0 @@ -package moe.nea.ledger - -import moe.nea.ledger.database.DBItemEntry -import moe.nea.ledger.database.ResultRow -import net.minecraft.event.HoverEvent -import net.minecraft.util.ChatComponentText -import net.minecraft.util.ChatStyle -import net.minecraft.util.EnumChatFormatting -import net.minecraft.util.IChatComponent - -data class ItemChange( - val itemId: ItemId, - val count: Double, - val direction: ChangeDirection, -) { - fun formatChat(): IChatComponent { - return ChatComponentText(" ") - .appendSibling(direction.chatFormat) - .appendText(" ") - .appendSibling(ChatComponentText("$count").setChatStyle(ChatStyle().setColor(EnumChatFormatting.WHITE))) - .appendSibling(ChatComponentText("x").setChatStyle(ChatStyle().setColor(EnumChatFormatting.DARK_GRAY))) - .appendText(" ") - .appendSibling(ChatComponentText(itemId.string).setChatStyle(ChatStyle().setParentStyle(ChatStyle().setColor( - EnumChatFormatting.WHITE)))) - } - - enum class ChangeDirection { - GAINED, - TRANSFORM, - SYNC, - CATALYST, - LOST; - - val chatFormat by lazy { formatChat0() } - private fun formatChat0(): IChatComponent { - val (text, color) = when (this) { - GAINED -> "+" to EnumChatFormatting.GREEN - TRANSFORM -> "~" to EnumChatFormatting.YELLOW - SYNC -> "=" to EnumChatFormatting.BLUE - CATALYST -> "*" to EnumChatFormatting.DARK_PURPLE - LOST -> "-" to EnumChatFormatting.RED - } - return ChatComponentText(text) - .setChatStyle( - ChatStyle() - .setColor(color) - .setChatHoverEvent(HoverEvent(HoverEvent.Action.SHOW_TEXT, - ChatComponentText(name).setChatStyle(ChatStyle().setColor(color))))) - } - } - - 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) - } - - fun from(result: ResultRow): ItemChange { - return ItemChange( - result[DBItemEntry.itemId], - result[DBItemEntry.size], - result[DBItemEntry.mode], - ) - } - } -}
\ No newline at end of file |