diff options
author | joffrey-bion <joffrey.bion@gmail.com> | 2021-02-02 14:40:26 +0100 |
---|---|---|
committer | joffrey-bion <joffrey.bion@gmail.com> | 2021-02-02 14:47:32 +0100 |
commit | 2762d7d0ea69291593662a9c2d934e45caa23dbb (patch) | |
tree | 92f067984c0862a676dcb4e5b095506e54f23ea2 /sw-engine/src/test/kotlin | |
parent | Move prepareMove log before the actual preparation (diff) | |
download | seven-wonders-2762d7d0ea69291593662a9c2d934e45caa23dbb.tar.gz seven-wonders-2762d7d0ea69291593662a9c2d934e45caa23dbb.tar.bz2 seven-wonders-2762d7d0ea69291593662a9c2d934e45caa23dbb.zip |
Filter only affordable transactions
Resolves:
https://github.com/joffrey-bion/seven-wonders/issues/81
Diffstat (limited to 'sw-engine/src/test/kotlin')
-rw-r--r-- | sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/cards/RequirementsTest.kt | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/cards/RequirementsTest.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/cards/RequirementsTest.kt index 36dc8ed1..20100537 100644 --- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/cards/RequirementsTest.kt +++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/cards/RequirementsTest.kt @@ -128,6 +128,39 @@ class RequirementsTest { } @Theory + fun allTransactionOptionsAreValid( + initialResource: ResourceType, + boughtResource: ResourceType, + requiredResource: ResourceType, + ) { + assumeTrue(initialResource != requiredResource) + + val requirements = createRequirements(requiredResource) + + val board = testBoard(initialResource, 1) + board.tradingRules.setCost(boughtResource, Provider.RIGHT_PLAYER, 1) + + val leftNeighbourBoard = testBoard(initialResource, 0) + leftNeighbourBoard.publicProduction.addFixedResource(boughtResource, 1) + + val rightNeighbourBoard = testBoard(initialResource, 0) + rightNeighbourBoard.publicProduction.addFixedResource(boughtResource, 1) + + val table = Table(listOf(leftNeighbourBoard, board, rightNeighbourBoard)) + val player = SimplePlayer(0, table) + + val satisfaction = requirements.assess(player) + if (satisfaction.satisfied) { + satisfaction.transactionOptions.forEach { + assertTrue( + requirements.areMetWithHelpBy(board, it), + "all transaction options should be valid, but this is not: $it" + ) + } + } + } + + @Theory fun pay_boughtResource(initialResource: ResourceType, requiredResource: ResourceType) { assumeTrue(initialResource != requiredResource) |