diff options
Diffstat (limited to 'sw-common-model/src')
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 { |