From eef32bd9307a3a9f1ee3b532db2fb1f7cf37927a Mon Sep 17 00:00:00 2001 From: joffrey-bion Date: Thu, 10 Dec 2020 23:06:00 +0100 Subject: Allow owner to leave/disband the game Resolves: https://github.com/joffrey-bion/seven-wonders/issues/51 --- .../org/luxons/sevenwonders/model/api/Lobby.kt | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'sw-common-model/src/commonMain/kotlin/org/luxons') diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Lobby.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Lobby.kt index e1e978f7..62bac3b1 100644 --- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Lobby.kt +++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Lobby.kt @@ -1,10 +1,36 @@ package org.luxons.sevenwonders.model.api +import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable import org.luxons.sevenwonders.model.wonders.PreGameWonder const val SEVEN_WONDERS_WS_ENDPOINT = "/seven-wonders-websocket" +// workaround for https://github.com/Kotlin/kotlinx.serialization/issues/1194 +@Serializable +data class GameListEventWrapper( + val event: GameListEvent +) + +fun GameListEvent.wrap(): GameListEventWrapper = GameListEventWrapper(this) + +@Serializable +sealed class GameListEvent { + + @SerialName("ReplaceList") + @Serializable + data class ReplaceList(val lobbies: List) : GameListEvent() + + @SerialName("CreateOrUpdate") + @Serializable + data class CreateOrUpdate(val lobby: LobbyDTO) : GameListEvent() + + @SerialName("Delete") + @Serializable + data class Delete(val lobbyId: Long) : GameListEvent() +} + +@Serializable enum class State { LOBBY, PLAYING, -- cgit