From a4da60fa4a816e3b8428eaffd2bd605dc0aed031 Mon Sep 17 00:00:00 2001 From: Joffrey Bion Date: Thu, 28 May 2020 12:47:00 +0200 Subject: Add UI support for playing discarded cards Resolves: https://github.com/joffrey-bion/seven-wonders/issues/25 Resolves: https://github.com/joffrey-bion/seven-wonders/issues/26 --- .../kotlin/org/luxons/sevenwonders/model/Moves.kt | 15 +++++++++++++-- .../kotlin/org/luxons/sevenwonders/model/boards/Boards.kt | 3 ++- .../kotlin/org/luxons/sevenwonders/model/cards/Cards.kt | 13 ++++++++++++- .../org/luxons/sevenwonders/model/wonders/Wonders.kt | 4 ++-- 4 files changed, 29 insertions(+), 6 deletions(-) (limited to 'sw-common-model') 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 12084539..54142ad2 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 @@ -15,10 +15,21 @@ enum class Action(val message: String) { PLAY("Pick the card you want to play or discard."), PLAY_2("Pick the first card you want to play or discard. Note that you have the ability to play these 2 last cards. You will choose how to play the last one during your next turn."), PLAY_LAST("You have the special ability to play your last card. Choose how you want to play it."), - PLAY_FREE_DISCARDED("Pick a card from the discarded deck, you can play it for free."), + PLAY_FREE_DISCARDED("Pick a card from the discarded deck, you can play it for free (but you cannot discard for 3 " + + "gold coins or upgrade your wonder with it."), PICK_NEIGHBOR_GUILD("Choose a Guild card (purple) that you want to copy from one of your neighbours."), WAIT("Please wait for other players to perform extra actions."), - WATCH_SCORE("The game is over! Look at the scoreboard to see the final ranking!") + WATCH_SCORE("The game is over! Look at the scoreboard to see the final ranking!"); + + fun allowsBuildingWonder(): Boolean = when (this) { + PLAY, PLAY_2, PLAY_LAST -> true + else -> false + } + + fun allowsDiscarding(): Boolean = when (this) { + PLAY, PLAY_2, PLAY_LAST -> true + else -> false + } } @Serializable 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 2fdb40b6..68a85898 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 @@ -16,7 +16,8 @@ data class Board( val military: Military, val playedCards: List>, val gold: Int, - val bluePoints: Int + val bluePoints: Int, + val canPlayAnyCardForFree: Boolean ) @Serializable 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 5c7616a1..13a9042d 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 @@ -4,6 +4,7 @@ import kotlinx.serialization.Serializable import org.luxons.sevenwonders.model.api.PlayerDTO import org.luxons.sevenwonders.model.boards.Requirements import org.luxons.sevenwonders.model.resources.ResourceTransactions +import org.luxons.sevenwonders.model.resources.noTransactions interface Card { val name: String @@ -81,8 +82,18 @@ data class CardPlayability( val isPlayable: Boolean, val isChainable: Boolean = false, val minPrice: Int = Int.MAX_VALUE, - val cheapestTransactions: Set = emptySet(), + val cheapestTransactions: Set = setOf(noTransactions()), val playabilityLevel: PlayabilityLevel ) { val isFree: Boolean = minPrice == 0 + + companion object { + val SPECIAL_FREE = CardPlayability( + isPlayable = true, + isChainable = false, + minPrice = 0, + cheapestTransactions = setOf(noTransactions()), + playabilityLevel = PlayabilityLevel.SPECIAL_FREE + ) + } } 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 e48a37d0..9e9a5b38 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 @@ -28,8 +28,8 @@ data class ApiWonderStage( @Serializable data class WonderBuildability( val isBuildable: Boolean, - val minPrice: Int = Int.MAX_VALUE, - val cheapestTransactions: Set = emptySet(), + val minPrice: Int, + val cheapestTransactions: Set, val playabilityLevel: PlayabilityLevel ) { val isFree: Boolean = minPrice == 0 -- cgit