diff options
author | joffrey-bion <joffrey.bion@gmail.com> | 2021-02-16 01:57:13 +0100 |
---|---|---|
committer | joffrey-bion <joffrey.bion@gmail.com> | 2021-02-16 02:24:33 +0100 |
commit | 6a91cb4afa645ca0c1712433e212fb654a68da06 (patch) | |
tree | 219f71111c733f35e6c17329bb871a87fea13c99 /sw-engine/src/test/kotlin/org | |
parent | Fix PLAY_LAST effect at end of age (Babylon B) (diff) | |
download | seven-wonders-6a91cb4afa645ca0c1712433e212fb654a68da06.tar.gz seven-wonders-6a91cb4afa645ca0c1712433e212fb654a68da06.tar.bz2 seven-wonders-6a91cb4afa645ca0c1712433e212fb654a68da06.zip |
Fix copy-guild move (points are now counted properly)
Resolves:
https://github.com/joffrey-bion/seven-wonders/issues/126
Diffstat (limited to 'sw-engine/src/test/kotlin/org')
-rw-r--r-- | sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/boards/BoardTest.kt | 39 | ||||
-rw-r--r-- | sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/test/TestUtils.kt | 10 |
2 files changed, 34 insertions, 15 deletions
diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/boards/BoardTest.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/boards/BoardTest.kt index 909d5e99..821855ba 100644 --- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/boards/BoardTest.kt +++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/boards/BoardTest.kt @@ -9,18 +9,10 @@ import org.junit.experimental.theories.Theories import org.junit.experimental.theories.Theory import org.junit.runner.RunWith import org.luxons.sevenwonders.engine.boards.Board.InsufficientFundsException -import org.luxons.sevenwonders.engine.effects.RawPointsIncrease -import org.luxons.sevenwonders.engine.effects.SpecialAbility -import org.luxons.sevenwonders.engine.effects.SpecialAbilityActivation +import org.luxons.sevenwonders.engine.effects.* import org.luxons.sevenwonders.engine.resources.resourcesOf -import org.luxons.sevenwonders.engine.test.addCards -import org.luxons.sevenwonders.engine.test.getDifferentColorFrom -import org.luxons.sevenwonders.engine.test.playCardWithEffect -import org.luxons.sevenwonders.engine.test.singleBoardPlayer -import org.luxons.sevenwonders.engine.test.testBoard -import org.luxons.sevenwonders.engine.test.testCard -import org.luxons.sevenwonders.engine.test.testSettings -import org.luxons.sevenwonders.engine.test.testWonder +import org.luxons.sevenwonders.engine.test.* +import org.luxons.sevenwonders.model.boards.RelativeBoardPosition import org.luxons.sevenwonders.model.cards.Color import org.luxons.sevenwonders.model.resources.ResourceType import org.luxons.sevenwonders.model.score.ScoreCategory @@ -186,6 +178,31 @@ class BoardTest { assertEquals(5 + gold / 3, score.totalPoints) } + @Theory + fun computePoints_countsCopiedGuild(@FromDataPoints("gold") gold: Int) { + assumeTrue(gold >= 0) + val left = testBoard(initialGold = gold) + val self = testBoard(initialGold = gold) + val right = testBoard(initialGold = gold) + + left.addCard(testCard(color = Color.YELLOW)) + right.addCard(testCard(color = Color.YELLOW)) + right.addCard(testCard(color = Color.YELLOW)) + self.copiedGuild = testCard( + name = "Custom guild for yellows", + color = Color.PURPLE, + effect = BonusPerBoardElement( + boards = listOf(RelativeBoardPosition.LEFT, RelativeBoardPosition.RIGHT), + type = BoardElementType.CARD, + colors = listOf(Color.YELLOW), + points = 1, + ) + ) + + val score = self.computeScore(testPlayer(left, self, right)) + assertEquals(3, score.pointsByCategory[ScoreCategory.GUILD]) + } + companion object { @JvmStatic diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/test/TestUtils.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/test/TestUtils.kt index 0e8800f3..7a13eccd 100644 --- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/test/TestUtils.kt +++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/test/TestUtils.kt @@ -132,12 +132,14 @@ internal fun playCardWithEffect(player: Player, color: Color, effect: Effect) { internal fun createMove(context: PlayerContext, card: Card, type: MoveType): Move = type.resolve(PlayerMove(type, card.name), card, context, emptyList()) -internal fun singleBoardPlayer(board: Board): Player = object : Player { +internal fun singleBoardPlayer(board: Board): Player = testPlayer(leftBoard = null, selfBoard = board, rightBoard = null) + +internal fun testPlayer(leftBoard: Board?, selfBoard: Board, rightBoard: Board?): Player = object : Player { override val index = 0 - override val board = board + override val board = selfBoard override fun getBoard(relativePosition: RelativeBoardPosition): Board = when (relativePosition) { - RelativeBoardPosition.LEFT -> throw RuntimeException("No LEFT board") + RelativeBoardPosition.LEFT -> leftBoard ?: error("No LEFT board") RelativeBoardPosition.SELF -> this.board - RelativeBoardPosition.RIGHT -> throw RuntimeException("No RIGHT board") + RelativeBoardPosition.RIGHT -> rightBoard ?: error("No RIGHT board") } } |