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/Moves.kt11
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/Settings.kt2
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/TableState.kt2
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Lobby.kt12
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Player.kt4
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/actions/Actions.kt18
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/errors/Errors.kt8
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/boards/Boards.kt10
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/boards/RelativeBoardPosition.kt5
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/cards/Cards.kt10
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/resources/Resources.kt2
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/score/Score.kt2
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/wonders/Wonders.kt10
13 files changed, 48 insertions, 48 deletions
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/Moves.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/Moves.kt
index bea94b64..bee7fb15 100644
--- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/Moves.kt
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/Moves.kt
@@ -40,7 +40,7 @@ data class PlayerTurnInfo(
val preparedMove: PlayedMove?,
val neighbourGuildCards: List<HandCard>,
val discardedCards: List<HandCard>?, // only present when the player can actually see them
- val scoreBoard: ScoreBoard? = null
+ val scoreBoard: ScoreBoard? = null,
) {
val currentAge: Int = table.currentAge
val message: String = action.message
@@ -53,22 +53,21 @@ fun PlayerTurnInfo.getBoard(position: RelativeBoardPosition): Board =
table.boards[position.getIndexFrom(playerIndex, table.boards.size)]
// TODO move to server code
-fun Collection<PlayerTurnInfo>.hideHandsAndWaitForReadiness() =
- map { it.copy(action = Action.SAY_READY, hand = null) }
+fun Collection<PlayerTurnInfo>.hideHandsAndWaitForReadiness() = map { it.copy(action = Action.SAY_READY, hand = null) }
@Serializable
data class PlayedMove(
val playerIndex: Int,
val type: MoveType,
val card: TableCard,
- val transactions: ResourceTransactions
+ val transactions: ResourceTransactions,
)
@Serializable
data class PlayerMove(
val type: MoveType,
val cardName: String,
- val transactions: ResourceTransactions = noTransactions()
+ val transactions: ResourceTransactions = noTransactions(),
)
enum class MoveType {
@@ -77,5 +76,5 @@ enum class MoveType {
PLAY_FREE_DISCARDED,
UPGRADE_WONDER,
DISCARD,
- COPY_GUILD;
+ COPY_GUILD,
}
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/Settings.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/Settings.kt
index 21be1c1b..a6c949ea 100644
--- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/Settings.kt
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/Settings.kt
@@ -12,7 +12,7 @@ data class Settings(
val defaultTradingCost: Int = 2,
val pointsPer3Gold: Int = 1,
val lostPointsPerDefeat: Int = 1,
- val wonPointsPerVictoryPerAge: Map<Int, Int> = mapOf(1 to 1, 2 to 3, 3 to 5)
+ val wonPointsPerVictoryPerAge: Map<Int, Int> = mapOf(1 to 1, 2 to 3, 3 to 5),
) {
val random: Random by lazy { randomSeedForTests?.let { Random(it) } ?: Random }
}
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/TableState.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/TableState.kt
index 1f1ed3ee..d27fccb5 100644
--- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/TableState.kt
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/TableState.kt
@@ -11,7 +11,7 @@ data class TableState(
val boards: List<Board>,
val currentAge: Age,
val handRotationDirection: HandRotationDirection,
- val lastPlayedMoves: List<PlayedMove>
+ val lastPlayedMoves: List<PlayedMove>,
) {
val nbPlayers: Int = boards.size
}
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 324482bb..e1e978f7 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
@@ -6,7 +6,9 @@ import org.luxons.sevenwonders.model.wonders.PreGameWonder
const val SEVEN_WONDERS_WS_ENDPOINT = "/seven-wonders-websocket"
enum class State {
- LOBBY, PLAYING, FINISHED
+ LOBBY,
+ PLAYING,
+ FINISHED,
}
@Serializable
@@ -18,7 +20,7 @@ data class LobbyDTO(
val allWonders: List<PreGameWonder>,
val state: State,
val hasEnoughPlayers: Boolean,
- val maxPlayersReached: Boolean
+ val maxPlayersReached: Boolean,
) {
private val wondersByName = allWonders.associateBy { it.name }
@@ -28,8 +30,8 @@ data class LobbyDTO(
state != State.LOBBY -> Actionability(false, "Cannot join: the game has already started")
maxPlayersReached -> Actionability(false, "Cannot join: the game is full")
playerNameAlreadyUsed(userDisplayName) -> Actionability(
- false,
- "Cannot join: already a player named '$userDisplayName' in this game"
+ canDo = false,
+ tooltip = "Cannot join: already a player named '$userDisplayName' in this game",
)
else -> Actionability(true, "Join game")
}
@@ -46,5 +48,5 @@ data class LobbyDTO(
@Serializable
data class Actionability(
val canDo: Boolean,
- val tooltip: String
+ val tooltip: String,
)
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Player.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Player.kt
index 7161b53d..db4365f5 100644
--- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Player.kt
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Player.kt
@@ -14,7 +14,7 @@ interface BasicPlayerInfo {
data class ConnectedPlayer(
override val username: String,
override val displayName: String,
- override val icon: Icon?
+ override val icon: Icon?,
) : BasicPlayerInfo
@Serializable
@@ -24,5 +24,5 @@ data class PlayerDTO(
override val icon: Icon?,
val wonder: AssignedWonder,
val isGameOwner: Boolean,
- val isReady: Boolean
+ val isReady: Boolean,
) : BasicPlayerInfo
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
index 67c64e32..ee5caef8 100644
--- 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
@@ -17,12 +17,12 @@ class ChooseNameAction(
/**
* The player's icon.
*/
- val icon: Icon?
+ val icon: Icon?,
)
@Serializable
data class Icon(
- val name: String
+ val name: String,
)
/**
@@ -33,7 +33,7 @@ class CreateGameAction(
/**
* The name of the game to create.
*/
- val gameName: String
+ val gameName: String,
)
/**
@@ -44,7 +44,7 @@ class JoinGameAction(
/**
* The ID of the game to join.
*/
- val gameId: Long
+ val gameId: Long,
)
/**
@@ -55,7 +55,7 @@ class PrepareMoveAction(
/**
* The move to prepare.
*/
- val move: PlayerMove
+ val move: PlayerMove,
)
/**
@@ -67,7 +67,7 @@ class ReorderPlayersAction(
/**
* The list of usernames of the players, in the new order.
*/
- val orderedPlayers: List<String>
+ val orderedPlayers: List<String>,
)
/**
@@ -79,7 +79,7 @@ class ReassignWondersAction(
/**
* The list of wonders assigned to each player, in the players' order.
*/
- val assignedWonders: List<AssignedWonder>
+ val assignedWonders: List<AssignedWonder>,
)
/**
@@ -90,7 +90,7 @@ class UpdateSettingsAction(
/**
* The new values for the settings.
*/
- val settings: Settings
+ val settings: Settings,
)
/**
@@ -101,5 +101,5 @@ class AddBotAction(
/**
* The display name for the bot to add.
*/
- val botDisplayName: String
+ val botDisplayName: String,
)
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
index dea6ce5b..61dba320 100644
--- 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
@@ -3,7 +3,9 @@ package org.luxons.sevenwonders.model.api.errors
import kotlinx.serialization.Serializable
enum class ErrorType {
- VALIDATION, CLIENT, SERVER
+ VALIDATION,
+ CLIENT,
+ SERVER,
}
@Serializable
@@ -11,12 +13,12 @@ data class ErrorDTO(
val code: String,
val message: String,
val type: ErrorType,
- val details: List<ValidationErrorDTO> = emptyList()
+ val details: List<ValidationErrorDTO> = emptyList(),
)
@Serializable
data class ValidationErrorDTO(
val path: String,
val message: String,
- val rejectedValue: String? = null
+ val rejectedValue: String? = null,
)
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/boards/Boards.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/boards/Boards.kt
index e080b929..1899c408 100644
--- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/boards/Boards.kt
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/boards/Boards.kt
@@ -17,19 +17,19 @@ data class Board(
val playedCards: List<List<TableCard>>,
val gold: Int,
val bluePoints: Int,
- val canPlayAnyCardForFree: Boolean
+ val canPlayAnyCardForFree: Boolean,
)
@Serializable
data class Requirements(
val gold: Int = 0,
- val resources: List<CountedResource> = emptyList()
+ val resources: List<CountedResource> = emptyList(),
)
@Serializable
data class Production(
val fixedResources: List<CountedResource>,
- val alternativeResources: List<Set<ResourceType>>
+ val alternativeResources: List<Set<ResourceType>>,
)
@Serializable
@@ -37,7 +37,7 @@ data class Military(
val nbShields: Int,
val victoryPoints: Int,
val totalPoints: Int,
- val nbDefeatTokens: Int
+ val nbDefeatTokens: Int,
)
@Serializable
@@ -45,5 +45,5 @@ data class Science(
val jokers: Int,
val nbWheels: Int,
val nbCompasses: Int,
- val nbTablets: Int
+ val nbTablets: Int,
)
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/boards/RelativeBoardPosition.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/boards/RelativeBoardPosition.kt
index f2450c5d..202dd0f8 100644
--- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/boards/RelativeBoardPosition.kt
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/boards/RelativeBoardPosition.kt
@@ -8,10 +8,7 @@ enum class RelativeBoardPosition(private val offset: Int) {
fun getIndexFrom(playerIndex: Int, nbPlayers: Int): Int = (playerIndex + offset) floorMod nbPlayers
}
-fun neighboursPositions() = listOf(
- RelativeBoardPosition.LEFT,
- RelativeBoardPosition.RIGHT
-)
+fun neighboursPositions() = listOf(RelativeBoardPosition.LEFT, RelativeBoardPosition.RIGHT)
private infix fun Int.floorMod(divisor: Int): Int {
val rem = this % divisor
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 f26baf0e..238e2612 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
@@ -24,7 +24,7 @@ data class TableCard(
override val chainChildren: List<String>,
override val image: String,
override val back: CardBack,
- val playedDuringLastMove: Boolean
+ val playedDuringLastMove: Boolean,
) : Card
/**
@@ -40,13 +40,13 @@ data class HandCard(
override val chainChildren: List<String>,
override val image: String,
override val back: CardBack,
- val playability: CardPlayability
+ val playability: CardPlayability,
) : Card
@Serializable
data class PreparedCard(
val username: String,
- val cardBack: CardBack?
+ val cardBack: CardBack?,
)
@Serializable
@@ -82,7 +82,7 @@ data class CardPlayability(
val isChainable: Boolean = false,
val minPrice: Int = Int.MAX_VALUE,
val cheapestTransactions: Set<ResourceTransactions> = setOf(noTransactions()),
- val playabilityLevel: PlayabilityLevel
+ val playabilityLevel: PlayabilityLevel,
) {
val isFree: Boolean = minPrice == 0
@@ -92,7 +92,7 @@ data class CardPlayability(
isChainable = false,
minPrice = 0,
cheapestTransactions = setOf(noTransactions()),
- playabilityLevel = PlayabilityLevel.SPECIAL_FREE
+ playabilityLevel = PlayabilityLevel.SPECIAL_FREE,
)
}
}
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/resources/Resources.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/resources/Resources.kt
index 4985c008..0ebb837d 100644
--- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/resources/Resources.kt
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/resources/Resources.kt
@@ -31,7 +31,7 @@ enum class ResourceType(val symbol: Char) {
@Serializable
data class CountedResource(
val count: Int,
- val type: ResourceType
+ val type: ResourceType,
)
@Serializable
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/score/Score.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/score/Score.kt
index 1896ecd3..c1f5e4d3 100644
--- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/score/Score.kt
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/score/Score.kt
@@ -9,7 +9,7 @@ class ScoreBoard(val scores: Collection<PlayerScore>)
data class PlayerScore(
val playerIndex: Int,
val boardGold: Int,
- val pointsByCategory: Map<ScoreCategory, Int>
+ val pointsByCategory: Map<ScoreCategory, Int>,
) : Comparable<PlayerScore> {
val totalPoints = pointsByCategory.values.sum()
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/wonders/Wonders.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/wonders/Wonders.kt
index fcecd010..a99f4f58 100644
--- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/wonders/Wonders.kt
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/wonders/Wonders.kt
@@ -13,14 +13,14 @@ typealias WonderName = String
@Serializable
data class PreGameWonder(
val name: WonderName,
- val images: Map<WonderSide, String>
+ val images: Map<WonderSide, String>,
)
@Serializable
data class AssignedWonder(
val name: WonderName,
val side: WonderSide,
- val image: String
+ val image: String,
)
@Serializable
@@ -43,7 +43,7 @@ data class ApiWonder(
val stages: List<ApiWonderStage>,
val image: String,
val nbBuiltStages: Int,
- val buildability: WonderBuildability
+ val buildability: WonderBuildability,
)
@Serializable
@@ -51,7 +51,7 @@ data class ApiWonderStage(
val cardBack: CardBack?,
val isBuilt: Boolean,
val requirements: Requirements,
- val builtDuringLastMove: Boolean
+ val builtDuringLastMove: Boolean,
)
@Serializable
@@ -59,7 +59,7 @@ data class WonderBuildability(
val isBuildable: Boolean,
val minPrice: Int,
val cheapestTransactions: Set<ResourceTransactions>,
- val playabilityLevel: PlayabilityLevel
+ val playabilityLevel: PlayabilityLevel,
) {
val isFree: Boolean = minPrice == 0
}
bgstack15