summaryrefslogtreecommitdiff
path: root/sw-common-model
diff options
context:
space:
mode:
Diffstat (limited to 'sw-common-model')
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Lobby.kt25
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/events/GameEvents.kt (renamed from sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/events/Events.kt)23
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/events/GameListEvents.kt29
3 files changed, 51 insertions, 26 deletions
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 59515057..2c7e2c5c 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,36 +1,11 @@
package org.luxons.sevenwonders.model.api
-import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import org.luxons.sevenwonders.model.Settings
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<LobbyDTO>) : GameListEvent()
-
- @SerialName("CreateOrUpdate")
- @Serializable
- data class CreateOrUpdate(val lobby: LobbyDTO) : GameListEvent()
-
- @SerialName("Delete")
- @Serializable
- data class Delete(val lobbyId: Long) : GameListEvent()
-}
-
enum class State {
LOBBY,
PLAYING,
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/events/Events.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/events/GameEvents.kt
index d8c05e91..c978fb96 100644
--- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/events/Events.kt
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/events/GameEvents.kt
@@ -3,6 +3,9 @@ package org.luxons.sevenwonders.model.api.events
import kotlinx.serialization.Serializable
import org.luxons.sevenwonders.model.PlayerMove
import org.luxons.sevenwonders.model.PlayerTurnInfo
+import org.luxons.sevenwonders.model.TurnAction
+import org.luxons.sevenwonders.model.api.ConnectedPlayer
+import org.luxons.sevenwonders.model.api.LobbyDTO
import org.luxons.sevenwonders.model.cards.PreparedCard
// workaround for https://github.com/Kotlin/kotlinx.serialization/issues/1194
@@ -17,12 +20,30 @@ fun GameEvent.wrap() = GameEventWrapper(this)
sealed class GameEvent {
@Serializable
- data class NewTurnStarted(val turnInfo: PlayerTurnInfo) : GameEvent()
+ data class NameChosen(val player: ConnectedPlayer) : GameEvent()
+
+ @Serializable
+ data class LobbyJoined(val lobby: LobbyDTO) : GameEvent()
+
+ @Serializable
+ data class LobbyUpdated(val lobby: LobbyDTO) : GameEvent()
+
+ @Serializable
+ object LobbyLeft : GameEvent()
+
+ @Serializable
+ data class GameStarted(val turnInfo: PlayerTurnInfo<TurnAction.SayReady>) : GameEvent()
+
+ @Serializable
+ data class NewTurnStarted(val turnInfo: PlayerTurnInfo<*>) : GameEvent()
@Serializable
data class MovePrepared(val move: PlayerMove) : GameEvent()
@Serializable
+ object MoveUnprepared : GameEvent()
+
+ @Serializable
data class CardPrepared(val preparedCard: PreparedCard) : GameEvent()
@Serializable
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/events/GameListEvents.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/events/GameListEvents.kt
new file mode 100644
index 00000000..2dd8f551
--- /dev/null
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/events/GameListEvents.kt
@@ -0,0 +1,29 @@
+package org.luxons.sevenwonders.model.api.events
+
+import kotlinx.serialization.SerialName
+import kotlinx.serialization.Serializable
+import org.luxons.sevenwonders.model.api.LobbyDTO
+
+// 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<LobbyDTO>) : GameListEvent()
+
+ @SerialName("CreateOrUpdate")
+ @Serializable
+ data class CreateOrUpdate(val lobby: LobbyDTO) : GameListEvent()
+
+ @SerialName("Delete")
+ @Serializable
+ data class Delete(val lobbyId: Long) : GameListEvent()
+}
bgstack15