From e2957be6c0f2dea09d0633cd7ee7549311b9b923 Mon Sep 17 00:00:00 2001 From: Joffrey Bion Date: Tue, 23 Feb 2021 00:01:00 +0100 Subject: Funnel game events into a single client subscription --- .../luxons/sevenwonders/model/api/events/Events.kt | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/events/Events.kt (limited to 'sw-common-model/src') 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/Events.kt new file mode 100644 index 00000000..d8c05e91 --- /dev/null +++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/events/Events.kt @@ -0,0 +1,30 @@ +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.cards.PreparedCard + +// workaround for https://github.com/Kotlin/kotlinx.serialization/issues/1194 +@Serializable +data class GameEventWrapper( + val event: GameEvent +) + +fun GameEvent.wrap() = GameEventWrapper(this) + +@Serializable +sealed class GameEvent { + + @Serializable + data class NewTurnStarted(val turnInfo: PlayerTurnInfo) : GameEvent() + + @Serializable + data class MovePrepared(val move: PlayerMove) : GameEvent() + + @Serializable + data class CardPrepared(val preparedCard: PreparedCard) : GameEvent() + + @Serializable + data class PlayerIsReady(val username: String) : GameEvent() +} -- cgit