summaryrefslogtreecommitdiff
path: root/sw-engine/src/main/kotlin/org
diff options
context:
space:
mode:
authorJoffrey Bion <joffrey.bion@booking.com>2020-05-28 12:47:00 +0200
committerJoffrey Bion <joffrey.bion@booking.com>2020-05-28 13:34:57 +0200
commita4da60fa4a816e3b8428eaffd2bd605dc0aed031 (patch)
tree18fcef04d9826fb94854c1a38584460659d8a3dd /sw-engine/src/main/kotlin/org
parentAdd server-side support for PLAY_FREE_DISCARDED special ability (diff)
downloadseven-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-engine/src/main/kotlin/org')
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Boards.kt6
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Table.kt2
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/wonders/Wonder.kt2
3 files changed, 7 insertions, 3 deletions
diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Boards.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Boards.kt
index c974c25f..7ff870cf 100644
--- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Boards.kt
+++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Boards.kt
@@ -5,6 +5,7 @@ import org.luxons.sevenwonders.engine.boards.ScienceType
import org.luxons.sevenwonders.engine.effects.RawPointsIncrease
import org.luxons.sevenwonders.engine.moves.Move
import org.luxons.sevenwonders.engine.resources.Resources
+import org.luxons.sevenwonders.model.Age
import org.luxons.sevenwonders.model.MoveType
import org.luxons.sevenwonders.model.cards.Color
import org.luxons.sevenwonders.model.cards.TableCard
@@ -24,7 +25,7 @@ import org.luxons.sevenwonders.model.boards.Science as ApiScience
import org.luxons.sevenwonders.model.wonders.ApiWonder as ApiWonder
import org.luxons.sevenwonders.model.wonders.ApiWonderStage as ApiWonderStage
-internal fun InternalBoard.toApiBoard(player: Player, lastMove: Move?): ApiBoard =
+internal fun InternalBoard.toApiBoard(player: Player, lastMove: Move?, currentAge: Age): ApiBoard =
ApiBoard(
playerIndex = playerIndex,
wonder = wonder.toApiWonder(player, lastMove),
@@ -37,7 +38,8 @@ internal fun InternalBoard.toApiBoard(player: Player, lastMove: Move?): ApiBoard
bluePoints = getPlayedCards()
.filter { it.color == Color.BLUE }
.flatMap { it.effects.filterIsInstance<RawPointsIncrease>() }
- .sumBy { it.points }
+ .sumBy { it.points },
+ canPlayAnyCardForFree = canPlayFreeCard(currentAge)
)
internal fun List<TableCard>.toColumns(): List<List<TableCard>> {
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 290b3dc9..ccb73cc1 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
@@ -7,7 +7,7 @@ import org.luxons.sevenwonders.engine.boards.Table
import org.luxons.sevenwonders.model.TableState
internal fun Table.toTableState(): TableState = TableState(
- boards = boards.mapIndexed { i, b -> b.toApiBoard(SimplePlayer(i, this), lastPlayedMoves.getOrNull(i)) },
+ boards = boards.mapIndexed { i, b -> b.toApiBoard(SimplePlayer(i, this), lastPlayedMoves.getOrNull(i), currentAge) },
currentAge = currentAge,
handRotationDirection = handRotationDirection,
lastPlayedMoves = lastPlayedMoves.map { it.toPlayedMove() }
diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/wonders/Wonder.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/wonders/Wonder.kt
index 2fd369ee..0e1b37f0 100644
--- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/wonders/Wonder.kt
+++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/wonders/Wonder.kt
@@ -52,6 +52,8 @@ private object Buildability {
fun alreadyBuilt() = WonderBuildability(
isBuildable = false,
+ minPrice = Int.MAX_VALUE,
+ cheapestTransactions = emptySet(),
playabilityLevel = PlayabilityLevel.INCOMPATIBLE_WITH_BOARD
)
bgstack15