diff options
author | Joffrey Bion <joffrey.bion@booking.com> | 2020-05-28 12:47:00 +0200 |
---|---|---|
committer | Joffrey Bion <joffrey.bion@booking.com> | 2020-05-28 13:34:57 +0200 |
commit | a4da60fa4a816e3b8428eaffd2bd605dc0aed031 (patch) | |
tree | 18fcef04d9826fb94854c1a38584460659d8a3dd /sw-common-model/src/commonMain/kotlin/org/luxons | |
parent | Add server-side support for PLAY_FREE_DISCARDED special ability (diff) | |
download | seven-wonders-a4da60fa4a816e3b8428eaffd2bd605dc0aed031.tar.gz seven-wonders-a4da60fa4a816e3b8428eaffd2bd605dc0aed031.tar.bz2 seven-wonders-a4da60fa4a816e3b8428eaffd2bd605dc0aed031.zip |
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
Diffstat (limited to 'sw-common-model/src/commonMain/kotlin/org/luxons')
4 files changed, 29 insertions, 6 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 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<List<TableCard>>, 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<ResourceTransactions> = emptySet(), + val cheapestTransactions: Set<ResourceTransactions> = 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<ResourceTransactions> = emptySet(), + val minPrice: Int, + val cheapestTransactions: Set<ResourceTransactions>, val playabilityLevel: PlayabilityLevel ) { val isFree: Boolean = minPrice == 0 |