summaryrefslogtreecommitdiff
path: root/sw-common-model/src/commonMain/kotlin/org/luxons
diff options
context:
space:
mode:
authorJoffrey BION <joffrey.bion@gmail.com>2019-05-31 20:19:34 +0200
committerjbion <joffrey.bion@amadeus.com>2019-07-08 19:21:15 +0200
commitc3fc62e7117b2e970eea4eb84137b6624063fb6d (patch)
treebd9a29c611f78227519729e54ec18b7ac530740e /sw-common-model/src/commonMain/kotlin/org/luxons
parentRemove useless Travis CI config (diff)
downloadseven-wonders-c3fc62e7117b2e970eea4eb84137b6624063fb6d.tar.gz
seven-wonders-c3fc62e7117b2e970eea4eb84137b6624063fb6d.tar.bz2
seven-wonders-c3fc62e7117b2e970eea4eb84137b6624063fb6d.zip
Create multiplatform SevenWondersClient based on Krossbow
Diffstat (limited to 'sw-common-model/src/commonMain/kotlin/org/luxons')
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Api.kt23
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/actions/Actions.kt65
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/errors/Errors.kt18
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/cards/Cards.kt6
4 files changed, 112 insertions, 0 deletions
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Api.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Api.kt
new file mode 100644
index 00000000..04c7ef2f
--- /dev/null
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Api.kt
@@ -0,0 +1,23 @@
+package org.luxons.sevenwonders.model.api
+
+const val SEVEN_WONDERS_WS_ENDPOINT = "/seven-wonders-websocket"
+
+enum class State {
+ LOBBY, PLAYING
+}
+
+data class LobbyDTO(
+ val id: Long,
+ val name: String,
+ val owner: String,
+ val players: List<PlayerDTO>,
+ val state: State
+)
+
+data class PlayerDTO(
+ val username: String,
+ val displayName: String,
+ val index: Int,
+ val isGameOwner: Boolean,
+ val isUser: Boolean
+)
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/actions/Actions.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/actions/Actions.kt
new file mode 100644
index 00000000..59bc2e5b
--- /dev/null
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/actions/Actions.kt
@@ -0,0 +1,65 @@
+package org.luxons.sevenwonders.model.api.actions
+
+import org.luxons.sevenwonders.model.CustomizableSettings
+import org.luxons.sevenwonders.model.PlayerMove
+
+/**
+ * The action to choose the player's name. This is the first action that should be called.
+ */
+class ChooseNameAction(
+ /**
+ * The display name of the player. May contain spaces and special characters.
+ */
+ val playerName: String
+)
+
+/**
+ * The action to create a game.
+ */
+class CreateGameAction(
+ /**
+ * The name of the game to create.
+ */
+ val gameName: String
+)
+
+/**
+ * The action to join a game.
+ */
+class JoinGameAction(
+ /**
+ * The ID of the game to join.
+ */
+ val gameId: Long
+)
+
+/**
+ * The action to prepare the next move during a game.
+ */
+class PrepareMoveAction(
+ /**
+ * The move to prepare.
+ */
+ val move: PlayerMove
+)
+
+/**
+ * The action to update the order of the players around the table. Can only be called in the lobby by the owner of the
+ * game.
+ */
+class ReorderPlayersAction(
+ /**
+ * The list of usernames of the players, in the new order.
+ */
+ val orderedPlayers: List<String>
+)
+
+/**
+ * The action to update the settings of the game. Can only be called in the lobby by the owner of the game.
+ */
+class UpdateSettingsAction(
+ /**
+ * The new values for the settings.
+ */
+ val settings: CustomizableSettings
+)
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/errors/Errors.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/errors/Errors.kt
new file mode 100644
index 00000000..f668f020
--- /dev/null
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/errors/Errors.kt
@@ -0,0 +1,18 @@
+package org.luxons.sevenwonders.model.api.errors
+
+enum class ErrorType {
+ VALIDATION, CLIENT, SERVER
+}
+
+data class ErrorDTO(
+ val code: String,
+ val message: String,
+ val type: ErrorType,
+ val details: List<ValidationErrorDTO> = emptyList()
+)
+
+data class ValidationErrorDTO(
+ val path: String,
+ val message: String,
+ val rejectedValue: Any? = null
+)
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/cards/Cards.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/cards/Cards.kt
index 57cf3a00..11a3e8d8 100644
--- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/cards/Cards.kt
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/cards/Cards.kt
@@ -1,5 +1,6 @@
package org.luxons.sevenwonders.model.cards
+import org.luxons.sevenwonders.model.api.PlayerDTO
import org.luxons.sevenwonders.model.boards.Requirements
import org.luxons.sevenwonders.model.resources.ResourceTransactions
@@ -29,6 +30,11 @@ data class HandCard(
val playability: CardPlayability
)
+class PreparedCard(
+ val player: PlayerDTO,
+ val cardBack: CardBack
+)
+
data class CardBack(val image: String)
enum class PlayabilityLevel {
bgstack15