From 7600b51a738a48f99b4198021f325d8053ddb6b5 Mon Sep 17 00:00:00 2001 From: joffrey-bion Date: Tue, 16 Feb 2021 01:37:32 +0100 Subject: Fix PLAY_LAST effect at end of age (Babylon B) Resolves: https://github.com/joffrey-bion/seven-wonders/issues/125 --- .../src/main/kotlin/org/luxons/sevenwonders/engine/Game.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'sw-engine/src/main') 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 86526abe..ed58250f 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 @@ -144,6 +144,12 @@ class Game internal constructor( */ fun playTurn() { makeMoves() + + // same goes for the discarded cards during the last turn, which should be available for special actions + if (hands.maxOneCardRemains()) { + discardLastCardsIfRelevant() + } + if (shouldStartPlayDiscardedTurn()) { startPlayDiscardedTurn() } else if (endOfAgeReached()) { @@ -165,12 +171,6 @@ class Game internal constructor( // all cards from this turn need to be placed before executing any effect // because effects depending on played cards need to take the ones from the current turn into account too placePreparedCards(moves) - - // same goes for the discarded cards during the last turn, which should be available for special actions - if (hands.maxOneCardRemains()) { - discardLastCardsOfHands() - } - activatePlayedCards(moves) table.lastPlayedMoves = moves @@ -223,7 +223,7 @@ class Game internal constructor( } } - private fun discardLastCardsOfHands() = + private fun discardLastCardsIfRelevant() = table.boards.filterNot { it.hasSpecial(SpecialAbility.PLAY_LAST_CARD) }.forEach { discardHand(it.playerIndex) } private fun discardHand(playerIndex: Int) { -- cgit