From d26ecccf690d33c3cf71412395a257ebb40d29e7 Mon Sep 17 00:00:00 2001 From: Joffrey Bion Date: Tue, 26 May 2020 02:39:20 +0200 Subject: Add other players' board summary Resolves: https://github.com/joffrey-bion/seven-wonders/issues/21 --- .../kotlin/org/luxons/sevenwonders/model/Moves.kt | 7 +++++++ .../org/luxons/sevenwonders/model/api/Api.kt | 22 ++++++++++++++-------- .../org/luxons/sevenwonders/model/boards/Boards.kt | 3 ++- 3 files changed, 23 insertions(+), 9 deletions(-) (limited to 'sw-common-model/src/commonMain/kotlin') 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 0d02c5fd..8b339788 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 @@ -1,6 +1,8 @@ package org.luxons.sevenwonders.model import kotlinx.serialization.Serializable +import org.luxons.sevenwonders.model.boards.Board +import org.luxons.sevenwonders.model.boards.RelativeBoardPosition import org.luxons.sevenwonders.model.cards.HandCard import org.luxons.sevenwonders.model.cards.TableCard import org.luxons.sevenwonders.model.resources.ResourceTransactions @@ -33,6 +35,11 @@ data class PlayerTurnInfo( val wonderBuildability: WonderBuildability = table.boards[playerIndex].wonder.buildability } +fun PlayerTurnInfo.getOwnBoard(): Board = table.boards[playerIndex] + +fun PlayerTurnInfo.getBoard(position: RelativeBoardPosition): Board = + table.boards[position.getIndexFrom(playerIndex, table.boards.size)] + // TODO move to server code fun Collection.hideHandsAndWaitForReadiness() = map { it.copy(action = Action.SAY_READY, hand = null) } 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 index 7a337f9a..d22a350a 100644 --- 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 @@ -44,19 +44,25 @@ data class Actionability( val tooltip: String ) +interface BasicPlayerInfo { + val username: String + val displayName: String + val icon: Icon? +} + @Serializable data class ConnectedPlayer( - val username: String, - val displayName: String, - val icon: Icon? -) + override val username: String, + override val displayName: String, + override val icon: Icon? +) : BasicPlayerInfo @Serializable data class PlayerDTO( - val username: String, - val displayName: String, - val icon: Icon?, + override val username: String, + override val displayName: String, + override val icon: Icon?, val index: Int, val isGameOwner: Boolean, val isReady: Boolean -) +) : BasicPlayerInfo 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 cdf5b65c..2fdb40b6 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 @@ -15,7 +15,8 @@ data class Board( val science: Science, val military: Military, val playedCards: List>, - val gold: Int + val gold: Int, + val bluePoints: Int ) @Serializable -- cgit