From 88e992b0e94d92ac9ac26e8d2d72d818292841ca Mon Sep 17 00:00:00 2001 From: Joffrey Bion Date: Sun, 29 Mar 2020 18:08:49 +0200 Subject: Rename GameState -> TableState --- .../kotlin/org/luxons/sevenwonders/model/GameState.kt | 17 ----------------- .../kotlin/org/luxons/sevenwonders/model/Moves.kt | 2 +- .../kotlin/org/luxons/sevenwonders/model/TableState.kt | 17 +++++++++++++++++ .../main/kotlin/org/luxons/sevenwonders/engine/Game.kt | 10 +++++----- .../org/luxons/sevenwonders/engine/converters/Table.kt | 4 ++-- 5 files changed, 25 insertions(+), 25 deletions(-) delete mode 100644 sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/GameState.kt create mode 100644 sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/TableState.kt diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/GameState.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/GameState.kt deleted file mode 100644 index 29423cd7..00000000 --- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/GameState.kt +++ /dev/null @@ -1,17 +0,0 @@ -package org.luxons.sevenwonders.model - -import kotlinx.serialization.Serializable -import org.luxons.sevenwonders.model.boards.Board -import org.luxons.sevenwonders.model.cards.HandRotationDirection - -typealias Age = Int - -@Serializable -data class GameState( - val boards: List, - val currentAge: Age, - val handRotationDirection: HandRotationDirection, - val lastPlayedMoves: List -) { - val nbPlayers: Int = boards.size -} 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 22cbfc8c..d684505e 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 @@ -19,7 +19,7 @@ enum class Action(val message: String) { @Serializable data class PlayerTurnInfo( val playerIndex: Int, - val table: GameState, + val table: TableState, val action: Action, val hand: List?, val preparedMove: PlayedMove?, 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 new file mode 100644 index 00000000..1f1ed3ee --- /dev/null +++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/TableState.kt @@ -0,0 +1,17 @@ +package org.luxons.sevenwonders.model + +import kotlinx.serialization.Serializable +import org.luxons.sevenwonders.model.boards.Board +import org.luxons.sevenwonders.model.cards.HandRotationDirection + +typealias Age = Int + +@Serializable +data class TableState( + val boards: List, + val currentAge: Age, + val handRotationDirection: HandRotationDirection, + val lastPlayedMoves: List +) { + val nbPlayers: Int = boards.size +} diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Game.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Game.kt index 931360d6..5a75516c 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Game.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Game.kt @@ -5,7 +5,7 @@ import org.luxons.sevenwonders.engine.boards.Table import org.luxons.sevenwonders.engine.cards.Card import org.luxons.sevenwonders.engine.cards.Decks import org.luxons.sevenwonders.engine.cards.Hands -import org.luxons.sevenwonders.engine.converters.toGameState +import org.luxons.sevenwonders.engine.converters.toTableState import org.luxons.sevenwonders.engine.converters.toPlayedMove import org.luxons.sevenwonders.engine.converters.toTableCard import org.luxons.sevenwonders.engine.data.LAST_AGE @@ -14,7 +14,7 @@ import org.luxons.sevenwonders.engine.moves.Move import org.luxons.sevenwonders.engine.moves.resolve import org.luxons.sevenwonders.engine.score.ScoreBoard import org.luxons.sevenwonders.model.Action -import org.luxons.sevenwonders.model.GameState +import org.luxons.sevenwonders.model.TableState import org.luxons.sevenwonders.model.PlayerMove import org.luxons.sevenwonders.model.PlayerTurnInfo import org.luxons.sevenwonders.model.cards.CardBack @@ -54,7 +54,7 @@ class Game internal constructor( return PlayerTurnInfo( playerIndex = player.index, - table = table.toGameState(), + table = table.toTableState(), action = action, hand = hand, preparedMove = preparedMoves[player.index]?.toPlayedMove(), @@ -107,7 +107,7 @@ class Game internal constructor( * had not prepared their moves (unless these players had nothing to do). To avoid this, please check if everyone * is ready using [allPlayersPreparedTheirMove]. */ - fun playTurn(): GameState { + fun playTurn(): TableState { makeMoves() if (endOfAgeReached()) { executeEndOfAgeEvents() @@ -118,7 +118,7 @@ class Game internal constructor( rotateHandsIfRelevant() startNewTurn() } - return table.toGameState() + return table.toTableState() } private fun makeMoves() { diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Table.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Table.kt index 77843334..290b3dc9 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Table.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Table.kt @@ -4,9 +4,9 @@ import org.luxons.sevenwonders.engine.SimplePlayer import org.luxons.sevenwonders.engine.moves.Move import org.luxons.sevenwonders.model.PlayedMove import org.luxons.sevenwonders.engine.boards.Table -import org.luxons.sevenwonders.model.GameState +import org.luxons.sevenwonders.model.TableState -internal fun Table.toGameState(): GameState = GameState( +internal fun Table.toTableState(): TableState = TableState( boards = boards.mapIndexed { i, b -> b.toApiBoard(SimplePlayer(i, this), lastPlayedMoves.getOrNull(i)) }, currentAge = currentAge, handRotationDirection = handRotationDirection, -- cgit