summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey Bion <joffrey.bion@booking.com>2020-03-29 18:08:49 +0200
committerJoffrey Bion <joffrey.bion@booking.com>2020-03-29 18:08:49 +0200
commit88e992b0e94d92ac9ac26e8d2d72d818292841ca (patch)
tree244d1e170417b40dc2110b8ca7c14630ac43d871
parentFix duplicated inconsistent state (diff)
downloadseven-wonders-88e992b0e94d92ac9ac26e8d2d72d818292841ca.tar.gz
seven-wonders-88e992b0e94d92ac9ac26e8d2d72d818292841ca.tar.bz2
seven-wonders-88e992b0e94d92ac9ac26e8d2d72d818292841ca.zip
Rename GameState -> TableState
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/Moves.kt2
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/TableState.kt (renamed from sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/GameState.kt)2
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Game.kt10
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Table.kt4
4 files changed, 9 insertions, 9 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 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<HandCard>?,
val preparedMove: PlayedMove?,
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/TableState.kt
index 29423cd7..1f1ed3ee 100644
--- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/GameState.kt
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/TableState.kt
@@ -7,7 +7,7 @@ import org.luxons.sevenwonders.model.cards.HandRotationDirection
typealias Age = Int
@Serializable
-data class GameState(
+data class TableState(
val boards: List<Board>,
val currentAge: Age,
val handRotationDirection: HandRotationDirection,
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,
bgstack15