From 3c8eecdab507c68c6e0f4f3df80628ba43d16bc5 Mon Sep 17 00:00:00 2001 From: Thomas Andres Gomez Date: Fri, 21 Feb 2025 14:53:52 +0100 Subject: [PATCH] Add roll values to the new UI --- composeApp/compose-desktop.pro | 5 +- .../kotlin/com/pixelized/desktop/lwa/App.kt | 1 + .../repository/network/NetworkRepository.kt | 6 +- .../roll_history/RollHistoryRepository.kt | 31 +++-- .../screen/campaign/player/CampaignScreen.kt | 7 + .../player/ribbon/PlayerPortraitRoll.kt | 129 ++++++++++++++++++ .../campaign/player/ribbon/PlayerRibbon.kt | 19 ++- .../player/ribbon/PlayerRibbonViewModel.kt | 42 +++++- .../desktop/lwa/ui/screen/roll/RollPage.kt | 13 +- .../lwa/ui/screen/roll/RollViewModel.kt | 1 + .../ui/screen/rollhistory/RollHistoryItem.kt | 4 +- .../rollhistory/RollHistoryViewModel.kt | 38 +++--- .../pixelized/server/lwa/protocol/Message.kt | 3 +- .../server/lwa/protocol/MessageContent.kt | 6 - .../server/lwa/protocol/MessageType.kt | 5 + .../lwa/protocol/{ => roll}/RollMessage.kt | 5 +- 16 files changed, 262 insertions(+), 53 deletions(-) create mode 100644 composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/campaign/player/ribbon/PlayerPortraitRoll.kt delete mode 100644 shared/src/commonMain/kotlin/com/pixelized/server/lwa/protocol/MessageContent.kt create mode 100644 shared/src/commonMain/kotlin/com/pixelized/server/lwa/protocol/MessageType.kt rename shared/src/commonMain/kotlin/com/pixelized/server/lwa/protocol/{ => roll}/RollMessage.kt (74%) diff --git a/composeApp/compose-desktop.pro b/composeApp/compose-desktop.pro index f28c79e..ac6f5d4 100644 --- a/composeApp/compose-desktop.pro +++ b/composeApp/compose-desktop.pro @@ -7,4 +7,7 @@ -dontwarn androidx.compose.material.** # Kotlinx coroutines rules seems to be outdated with the latest version of Kotlin and Proguard --keep class kotlinx.coroutines.** { *; } \ No newline at end of file +-keep class kotlinx.coroutines.** { *; } + +# OkHttp comming from COIL. +-dontwarn okhttp3.internal.platform.** \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/App.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/App.kt index 135358e..4174cbf 100644 --- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/App.kt +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/App.kt @@ -41,6 +41,7 @@ import com.pixelized.desktop.lwa.ui.navigation.window.destination.RollHistoryWin import com.pixelized.desktop.lwa.ui.navigation.window.rememberMaxWindowHeight import com.pixelized.desktop.lwa.repository.network.NetworkRepository import com.pixelized.desktop.lwa.repository.network.NetworkRepository.Status +import com.pixelized.desktop.lwa.ui.navigation.screen.MainNavHost import com.pixelized.desktop.lwa.ui.screen.campaign.player.CampaignScreen import com.pixelized.desktop.lwa.ui.screen.characterSheet.CharacterSheetMainNavHost import com.pixelized.desktop.lwa.ui.screen.rollhistory.RollHistoryPage diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/repository/network/NetworkRepository.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/repository/network/NetworkRepository.kt index a32fecb..b5e6637 100644 --- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/repository/network/NetworkRepository.kt +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/repository/network/NetworkRepository.kt @@ -10,7 +10,7 @@ import com.pixelized.desktop.lwa.utils.extention.decodeFromFrame import com.pixelized.desktop.lwa.utils.extention.encodeToFrame import com.pixelized.server.lwa.SERVER_PORT import com.pixelized.server.lwa.protocol.Message -import com.pixelized.server.lwa.protocol.MessageContent +import com.pixelized.server.lwa.protocol.MessageType import io.ktor.client.HttpClient import io.ktor.websocket.Frame import kotlinx.coroutines.CoroutineScope @@ -99,11 +99,13 @@ class NetworkRepository( suspend fun share( playerName: String = settingsRepository.settings().playerName, - content: MessageContent, + type: MessageType, + content: String, ) { if (status.value == Status.CONNECTED) { val message = Message( from = playerName, + type = type, value = content, ) // emit the message into the outgoing buffer diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/repository/roll_history/RollHistoryRepository.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/repository/roll_history/RollHistoryRepository.kt index b6b8a90..64399d7 100644 --- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/repository/roll_history/RollHistoryRepository.kt +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/repository/roll_history/RollHistoryRepository.kt @@ -1,23 +1,28 @@ package com.pixelized.desktop.lwa.repository.roll_history import com.pixelized.desktop.lwa.repository.network.NetworkRepository -import com.pixelized.server.lwa.protocol.Message -import com.pixelized.server.lwa.protocol.RollMessage +import com.pixelized.server.lwa.protocol.MessageType +import com.pixelized.server.lwa.protocol.roll.RollMessage import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.flow.SharingStarted +import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.mapNotNull import kotlinx.coroutines.flow.shareIn import kotlinx.coroutines.launch +import kotlinx.serialization.encodeToString +import kotlinx.serialization.json.Json class RollHistoryRepository( private val network: NetworkRepository, + private val jsonFormatter: Json, ) { private val scope = CoroutineScope(Dispatchers.IO) - val rolls: SharedFlow = network.data - .mapNotNull { it.takeIf { it.value is RollMessage } } + val rolls: SharedFlow = network.data + .mapNotNull { it.takeIf { it.type == MessageType.Roll } } + .map { jsonFormatter.decodeFromString(it.value) } .shareIn( scope = scope, started = SharingStarted.Eagerly, @@ -32,20 +37,24 @@ class RollHistoryRepository( } suspend fun share( + characterId: String, skillLabel: String, rollDifficulty: String?, rollValue: Int, resultLabel: String?, rollSuccessLimit: Int?, ) { + val content = RollMessage( + characterId = characterId, + skillLabel = skillLabel, + rollDifficulty = rollDifficulty, + rollValue = rollValue, + resultLabel = resultLabel, + rollSuccessLimit = rollSuccessLimit, + ) network.share( - content = RollMessage( - skillLabel = skillLabel, - rollDifficulty = rollDifficulty, - rollValue = rollValue, - resultLabel = resultLabel, - rollSuccessLimit = rollSuccessLimit, - ) + type = MessageType.Roll, + content = jsonFormatter.encodeToString(content), ) } } \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/campaign/player/CampaignScreen.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/campaign/player/CampaignScreen.kt index c735ea2..b260c91 100644 --- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/campaign/player/CampaignScreen.kt +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/campaign/player/CampaignScreen.kt @@ -9,6 +9,7 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.material.Surface import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.State import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember @@ -30,13 +31,19 @@ import com.pixelized.desktop.lwa.ui.screen.campaign.player.detail.CharacterDetai import com.pixelized.desktop.lwa.ui.screen.campaign.player.detail.CharacterDiminishedViewModel import com.pixelized.desktop.lwa.ui.screen.campaign.player.ribbon.PlayerRibbon import com.pixelized.desktop.lwa.ui.screen.characterSheet.detail.dialog.DiminishedStatDialog +import com.pixelized.desktop.lwa.ui.screen.network.NetworkViewModel import org.koin.compose.viewmodel.koinViewModel @Composable fun CampaignScreen( characterDetailViewModel: CharacterDetailViewModel = koinViewModel(), dismissedViewModel: CharacterDiminishedViewModel = koinViewModel(), + networkViewModel: NetworkViewModel = koinViewModel(), ) { + LaunchedEffect(Unit) { + networkViewModel.connect() + } + KeyHandler { when { it.type == KeyEventType.KeyUp && it.key == Key.Escape -> { diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/campaign/player/ribbon/PlayerPortraitRoll.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/campaign/player/ribbon/PlayerPortraitRoll.kt new file mode 100644 index 0000000..df6d9b8 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/campaign/player/ribbon/PlayerPortraitRoll.kt @@ -0,0 +1,129 @@ +package com.pixelized.desktop.lwa.ui.screen.campaign.player.ribbon + +import androidx.compose.animation.AnimatedContent +import androidx.compose.animation.SizeTransform +import androidx.compose.animation.core.Animatable +import androidx.compose.animation.core.AnimationVector1D +import androidx.compose.animation.core.Spring +import androidx.compose.animation.core.spring +import androidx.compose.animation.fadeIn +import androidx.compose.animation.fadeOut +import androidx.compose.animation.togetherWith +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.size +import androidx.compose.material.Icon +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.Stable +import androidx.compose.runtime.State +import androidx.compose.runtime.remember +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.graphics.Shadow +import androidx.compose.ui.graphics.graphicsLayer +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.unit.dp +import kotlinx.coroutines.launch +import lwacharactersheet.composeapp.generated.resources.Res +import lwacharactersheet.composeapp.generated.resources.ic_d20_24dp +import org.jetbrains.compose.resources.painterResource + +@Stable +data class PlayerPortraitRollAnimation( + val alpha: Animatable = Animatable(0f), + val rotation: Animatable = Animatable(0f), + val scale: Animatable = Animatable(1f), +) + +@Composable +fun PlayerPortraitRoll( + modifier: Modifier = Modifier, + value: Int?, +) { + AnimatedContent( + modifier = modifier.graphicsLayer { clip = false }, + targetState = value, + transitionSpec = { + val enter = fadeIn() + val exit = fadeOut() + enter togetherWith exit using SizeTransform(clip = false) + } + ) { + val animation = diceIconAnimation(key = it ?: Unit) + + Box( + modifier = Modifier.graphicsLayer { + this.scaleX = animation.scale.value + this.scaleY = animation.scale.value + }, + contentAlignment = Alignment.Center, + ) { + when (it) { + null -> Unit + else -> { + Icon( + modifier = Modifier + .graphicsLayer { + this.alpha = 0.8f + this.rotationZ = animation.rotation.value + } + .size(48.dp), + painter = painterResource(Res.drawable.ic_d20_24dp), + tint = MaterialTheme.colors.primary, + contentDescription = null, + ) + Text( + style = MaterialTheme.typography.h5.copy( + shadow = Shadow( + color = MaterialTheme.colors.surface, + offset = Offset.Zero, + blurRadius = 8f, + ) + ), + textAlign = TextAlign.Center, + color = MaterialTheme.colors.onSurface, + text = it.toString() + ) + } + } + } + } +} + +@Composable +private fun diceIconAnimation(key: Any = Unit): PlayerPortraitRollAnimation { + val animation = remember(key) { + PlayerPortraitRollAnimation() + } + LaunchedEffect(key) { + launch { + animation.scale.animateTo( + targetValue = 1.20f, + animationSpec = spring( + dampingRatio = Spring.DampingRatioNoBouncy, + stiffness = 800f, + ) + ) + animation.scale.animateTo( + targetValue = 1f, + animationSpec = spring( + dampingRatio = 0.28f, + stiffness = 800f, + ) + ) + } + launch { + animation.rotation.animateTo( + targetValue = 360f * 3, + animationSpec = spring( + dampingRatio = Spring.DampingRatioNoBouncy, + stiffness = Spring.StiffnessLow, + ) + ) + } + } + return animation +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/campaign/player/ribbon/PlayerRibbon.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/campaign/player/ribbon/PlayerRibbon.kt index 511cd80..7e60c2c 100644 --- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/campaign/player/ribbon/PlayerRibbon.kt +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/campaign/player/ribbon/PlayerRibbon.kt @@ -1,6 +1,8 @@ package com.pixelized.desktop.lwa.ui.screen.campaign.player.ribbon import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.runtime.Composable @@ -25,10 +27,19 @@ fun PlayerRibbon( items = characters.value, key = { it.id }, ) { - PlayerPortrait( - character = it, - onCharacter = onCharacter, - ) + Row { + PlayerPortrait( + character = it, + onCharacter = onCharacter, + ) + PlayerPortraitRoll( + modifier = Modifier.size( + width = 64.dp, + height = PlayerPortrait.Default.size.height + ), + value = playerRibbonViewModel.roll(characterId = it.id).value, + ) + } } } } \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/campaign/player/ribbon/PlayerRibbonViewModel.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/campaign/player/ribbon/PlayerRibbonViewModel.kt index cd74586..45127a5 100644 --- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/campaign/player/ribbon/PlayerRibbonViewModel.kt +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/campaign/player/ribbon/PlayerRibbonViewModel.kt @@ -1,17 +1,26 @@ package com.pixelized.desktop.lwa.ui.screen.campaign.player.ribbon +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.Stable +import androidx.compose.runtime.State +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.saveable.rememberSaveable import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.pixelized.desktop.lwa.repository.characterSheet.CharacterSheetRepository +import com.pixelized.desktop.lwa.repository.roll_history.RollHistoryRepository import kotlinx.coroutines.flow.SharingStarted +import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn class PlayerRibbonViewModel( - repository: CharacterSheetRepository, + private val rollHistoryRepository: RollHistoryRepository, + characterRepository: CharacterSheetRepository, ) : ViewModel() { - - val characters = repository.characterSheetFlow() + val characters: StateFlow> = characterRepository.characterSheetFlow() .map { sheets -> sheets.map { sheet -> PlayerPortraitUio( @@ -28,4 +37,31 @@ class PlayerRibbonViewModel( started = SharingStarted.Eagerly, initialValue = emptyList() ) + + private val _rolls: HashMap = hashMapOf() + val rolls: StateFlow> = rollHistoryRepository.rolls + .map { + _rolls[it.characterId] = it.rollValue + _rolls + }.stateIn( + scope = viewModelScope, + started = SharingStarted.Eagerly, + initialValue = emptyMap() + ) + + @Composable + @Stable + fun roll(characterId: String): State { + val state = rememberSaveable(characterId) { + mutableStateOf(null) + } + LaunchedEffect(characterId) { + rollHistoryRepository.rolls.collect { + if (it.characterId == characterId) { + state.value = it.rollValue + } + } + } + return state + } } \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/roll/RollPage.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/roll/RollPage.kt index 671d47d..bb1aeb5 100644 --- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/roll/RollPage.kt +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/roll/RollPage.kt @@ -95,11 +95,14 @@ fun RollPage( val scope = rememberCoroutineScope() KeyHandler { - if (it.type == KeyEventType.KeyUp && it.key == Key.Escape) { - onDismissRequest() - true - } else { - false + when { + it.type == KeyEventType.KeyUp && it.key == Key.Escape -> { + onDismissRequest() + true + } + else -> { + false + } } } diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/roll/RollViewModel.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/roll/RollViewModel.kt index 97335a5..b2fab6d 100644 --- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/roll/RollViewModel.kt +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/roll/RollViewModel.kt @@ -192,6 +192,7 @@ class RollViewModel( ) launch { rollHistoryRepository.share( + characterId = sheet.id, skillLabel = _rollTitle.value.label, rollDifficulty = when (_rollDifficulty.value?.difficulty) { Difficulty.EASY -> getString(Res.string.roll_page__dc_easy__label) diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/rollhistory/RollHistoryItem.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/rollhistory/RollHistoryItem.kt index d289d36..8689a5e 100644 --- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/rollhistory/RollHistoryItem.kt +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/rollhistory/RollHistoryItem.kt @@ -20,7 +20,7 @@ import org.jetbrains.compose.resources.stringResource @Stable data class RollHistoryItemUio( - val from: String, + val character: String, val skillLabel: String, val rollDifficulty: String?, val rollValue: Int, @@ -50,7 +50,7 @@ fun RollHistoryItem( fontWeight = FontWeight.Bold, overflow = TextOverflow.Ellipsis, maxLines = 1, - text = roll.from, + text = roll.character, ) Text( modifier = Modifier.alignByBaseline(), diff --git a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/rollhistory/RollHistoryViewModel.kt b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/rollhistory/RollHistoryViewModel.kt index 71f7505..be39d02 100644 --- a/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/rollhistory/RollHistoryViewModel.kt +++ b/composeApp/src/commonMain/kotlin/com/pixelized/desktop/lwa/ui/screen/rollhistory/RollHistoryViewModel.kt @@ -4,12 +4,15 @@ import androidx.compose.runtime.State import androidx.compose.runtime.mutableStateOf import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.pixelized.server.lwa.protocol.RollMessage +import com.pixelized.desktop.lwa.repository.characterSheet.CharacterSheetRepository +import com.pixelized.desktop.lwa.repository.characterSheet.model.CharacterSheet import com.pixelized.desktop.lwa.repository.roll_history.RollHistoryRepository +import kotlinx.coroutines.flow.combine import kotlinx.coroutines.launch class RollHistoryViewModel( - private val repository: RollHistoryRepository + private val characterRepository: CharacterSheetRepository, + private val rollRepository: RollHistoryRepository, ) : ViewModel() { private val _rolls = mutableStateOf((emptyList())) @@ -17,22 +20,25 @@ class RollHistoryViewModel( init { viewModelScope.launch { - repository.rolls.collect { - (it.value as? RollMessage)?.let { content -> - _rolls.value = _rolls.value.toMutableList().apply { - add( - index = 0, - element = RollHistoryItemUio( - from = it.from, - skillLabel = content.skillLabel, - rollDifficulty = content.rollDifficulty, - resultLabel = content.resultLabel, - rollValue = content.rollValue, - rollSuccessLimit = content.rollSuccessLimit, - ) + combine( + characterRepository.characterSheetFlow(), + rollRepository.rolls, + ) { sheets: List, content -> + _rolls.value.toMutableList().apply { + add( + index = 0, + element = RollHistoryItemUio( + character = sheets.firstOrNull { it.id == content.characterId }?.name ?: "", + skillLabel = content.skillLabel, + rollDifficulty = content.rollDifficulty, + resultLabel = content.resultLabel, + rollValue = content.rollValue, + rollSuccessLimit = content.rollSuccessLimit, ) - } + ) } + }.collect { content -> + _rolls.value = content } } } diff --git a/shared/src/commonMain/kotlin/com/pixelized/server/lwa/protocol/Message.kt b/shared/src/commonMain/kotlin/com/pixelized/server/lwa/protocol/Message.kt index cfe94c9..5518940 100644 --- a/shared/src/commonMain/kotlin/com/pixelized/server/lwa/protocol/Message.kt +++ b/shared/src/commonMain/kotlin/com/pixelized/server/lwa/protocol/Message.kt @@ -5,5 +5,6 @@ import kotlinx.serialization.Serializable @Serializable data class Message( val from: String, - val value: MessageContent, + val type: MessageType, + val value: String, ) \ No newline at end of file diff --git a/shared/src/commonMain/kotlin/com/pixelized/server/lwa/protocol/MessageContent.kt b/shared/src/commonMain/kotlin/com/pixelized/server/lwa/protocol/MessageContent.kt deleted file mode 100644 index 6c59cb9..0000000 --- a/shared/src/commonMain/kotlin/com/pixelized/server/lwa/protocol/MessageContent.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.pixelized.server.lwa.protocol - -import kotlinx.serialization.Serializable - -@Serializable -sealed interface MessageContent \ No newline at end of file diff --git a/shared/src/commonMain/kotlin/com/pixelized/server/lwa/protocol/MessageType.kt b/shared/src/commonMain/kotlin/com/pixelized/server/lwa/protocol/MessageType.kt new file mode 100644 index 0000000..cca0da3 --- /dev/null +++ b/shared/src/commonMain/kotlin/com/pixelized/server/lwa/protocol/MessageType.kt @@ -0,0 +1,5 @@ +package com.pixelized.server.lwa.protocol + +enum class MessageType { + Roll +} diff --git a/shared/src/commonMain/kotlin/com/pixelized/server/lwa/protocol/RollMessage.kt b/shared/src/commonMain/kotlin/com/pixelized/server/lwa/protocol/roll/RollMessage.kt similarity index 74% rename from shared/src/commonMain/kotlin/com/pixelized/server/lwa/protocol/RollMessage.kt rename to shared/src/commonMain/kotlin/com/pixelized/server/lwa/protocol/roll/RollMessage.kt index 55a76f4..fda452c 100644 --- a/shared/src/commonMain/kotlin/com/pixelized/server/lwa/protocol/RollMessage.kt +++ b/shared/src/commonMain/kotlin/com/pixelized/server/lwa/protocol/roll/RollMessage.kt @@ -1,12 +1,13 @@ -package com.pixelized.server.lwa.protocol +package com.pixelized.server.lwa.protocol.roll import kotlinx.serialization.Serializable @Serializable data class RollMessage( + val characterId: String, val skillLabel: String, val resultLabel: String?, val rollDifficulty: String?, val rollValue: Int, val rollSuccessLimit: Int?, -) : MessageContent \ No newline at end of file +) \ No newline at end of file