diff options
author | Joffrey Bion <joffrey.bion@booking.com> | 2020-05-15 01:20:40 +0200 |
---|---|---|
committer | Joffrey Bion <joffrey.bion@booking.com> | 2020-05-15 01:20:40 +0200 |
commit | 6be4b282381546060b2496b9ea9c9c7318d63247 (patch) | |
tree | f7ff056f7727cf49aca5b007b53010c29ea70d9b /sw-engine/src/test/kotlin | |
parent | Clean up (diff) | |
download | seven-wonders-6be4b282381546060b2496b9ea9c9c7318d63247.tar.gz seven-wonders-6be4b282381546060b2496b9ea9c9c7318d63247.tar.bz2 seven-wonders-6be4b282381546060b2496b9ea9c9c7318d63247.zip |
Send score at end of game
Diffstat (limited to 'sw-engine/src/test/kotlin')
-rw-r--r-- | sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/GameTest.kt | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/GameTest.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/GameTest.kt index ad3c28d4..320b3e94 100644 --- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/GameTest.kt +++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/GameTest.kt @@ -15,7 +15,9 @@ import org.luxons.sevenwonders.engine.test.testCustomizableSettings import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFalse +import kotlin.test.assertNotNull import kotlin.test.assertTrue +import kotlin.test.fail class GameTest { @@ -33,18 +35,26 @@ class GameTest { (1..LAST_AGE).forEach { playAge(nbPlayers, game, it) } - game.computeScore() + val turnInfos = game.getCurrentTurnInfo() + assertEquals(nbPlayers, turnInfos.size) + turnInfos.forEach { + assertEquals(Action.WATCH_SCORE, it.action) + + val scoreBoard = it.scoreBoard + assertNotNull(scoreBoard) + assertEquals(nbPlayers, scoreBoard.scores.size) + } } + private fun createGame(nbPlayers: Int): Game = + GameDefinition.load().initGame(0, testCustomizableSettings(), nbPlayers) + private fun playAge(nbPlayers: Int, game: Game, age: Int) { repeat(6) { playTurn(nbPlayers, game, age, 7 - it) } } - private fun createGame(nbPlayers: Int): Game = - GameDefinition.load().initGame(0, testCustomizableSettings(), nbPlayers) - private fun playTurn(nbPlayers: Int, game: Game, ageToCheck: Int, handSize: Int) { val turnInfos = game.getCurrentTurnInfo() assertEquals(nbPlayers, turnInfos.size) @@ -68,6 +78,7 @@ class GameTest { Action.PLAY, Action.PLAY_2, Action.PLAY_LAST -> createPlayCardMove(this) Action.PICK_NEIGHBOR_GUILD -> createPickGuildMove(this) Action.WAIT, Action.SAY_READY -> null + Action.WATCH_SCORE -> fail("should not have WATCH_SCORE action before end of game") } private fun createPlayCardMove(turnInfo: PlayerTurnInfo): MoveExpectation { @@ -80,12 +91,21 @@ class GameTest { return if (playableCard != null) { planMove(turnInfo, MoveType.PLAY, playableCard, playableCard.playability.cheapestTransactions.first()) } else { - planMove(turnInfo, MoveType.DISCARD, turnInfo.hand!!.first(), - noTransactions() - ) + planMove(turnInfo, MoveType.DISCARD, turnInfo.hand!!.first(), noTransactions()) } } + private fun planMove( + turnInfo: PlayerTurnInfo, + moveType: MoveType, + card: HandCard, + transactions: ResourceTransactions + ): MoveExpectation = MoveExpectation( + turnInfo.playerIndex, + PlayerMove(moveType, card.name, transactions), + PlayedMove(turnInfo.playerIndex, moveType, card.toPlayedCard(), transactions) + ) + private fun createPickGuildMove(turnInfo: PlayerTurnInfo): MoveExpectation { val neighbourGuilds = turnInfo.neighbourGuildCards @@ -108,19 +128,6 @@ class GameTest { data class MoveExpectation(val playerIndex: Int, val moveToSend: PlayerMove, val expectedPlayedMove: PlayedMove) - private fun planMove( - turnInfo: PlayerTurnInfo, - moveType: MoveType, - card: HandCard, - transactions: ResourceTransactions - ): MoveExpectation = MoveExpectation( - turnInfo.playerIndex, - PlayerMove(moveType, card.name, transactions), - PlayedMove(turnInfo.playerIndex, moveType, card.toPlayedCard(), transactions) - ) - private fun HandCard.toPlayedCard(): TableCard = - TableCard( - name, color, requirements, chainParent, chainChildren, image, back, true - ) + TableCard(name, color, requirements, chainParent, chainChildren, image, back, true) } |