diff options
Diffstat (limited to 'game-engine/src/test/kotlin/org')
9 files changed, 17 insertions, 26 deletions
diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/GameTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/GameTest.kt index 1917c860..3736ddc0 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/GameTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/GameTest.kt @@ -10,8 +10,6 @@ import org.luxons.sevenwonders.game.data.GameDefinition import org.luxons.sevenwonders.game.data.LAST_AGE import org.luxons.sevenwonders.game.moves.MoveType import org.luxons.sevenwonders.game.resources.ResourceTransactions -import org.luxons.sevenwonders.game.resources.Resources -import org.luxons.sevenwonders.game.resources.bestSolution import org.luxons.sevenwonders.game.resources.noTransactions import org.luxons.sevenwonders.game.test.testCustomizableSettings import java.util.HashMap @@ -73,27 +71,19 @@ class GameTest { private fun createPlayCardMove(turnInfo: PlayerTurnInfo): PlayerMove { for (handCard in turnInfo.hand) { if (handCard.isPlayable) { - val resourcesToBuy = findResourcesToBuyFor(handCard, turnInfo) - return PlayerMove(MoveType.PLAY, handCard.card.name, resourcesToBuy) + val transactions = findResourcesToBuyFor(handCard) + return PlayerMove(MoveType.PLAY, handCard.name, transactions) } } val firstCardInHand = turnInfo.hand[0] - return PlayerMove(MoveType.DISCARD, firstCardInHand.card.name) + return PlayerMove(MoveType.DISCARD, firstCardInHand.name) } - private fun findResourcesToBuyFor(handCard: HandCard, turnInfo: PlayerTurnInfo): ResourceTransactions { + private fun findResourcesToBuyFor(handCard: HandCard): ResourceTransactions { if (handCard.isFree) { return noTransactions() } - val requiredResources = handCard.card.requirements.resources - val table = turnInfo.table - val playerIndex = turnInfo.playerIndex - // we're supposed to have a best transaction plan because the card is playable - return bestTransaction(requiredResources, PlayerContext(playerIndex, table, listOf())) - } - - private fun bestTransaction(resources: Resources, player: Player): ResourceTransactions { - return bestSolution(resources, player).possibleTransactions.first() + return handCard.cheapestTransactions.possibleTransactions.first() } private fun createPickGuildMove(turnInfo: PlayerTurnInfo): PlayerMove { @@ -106,7 +96,7 @@ class GameTest { private fun checkLastPlayedMoves(sentMoves: Map<Int, PlayerMove>, table: Table) { for (move in table.lastPlayedMoves) { - val sentMove = sentMoves[move.playerContext.index] + val sentMove = sentMoves[move.playerIndex] assertNotNull(sentMove) assertNotNull(move.card) assertEquals(sentMove.cardName, move.card.name) diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/CardTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/CardTest.kt index 41c3c070..b6fecbd0 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/CardTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/CardTest.kt @@ -2,8 +2,8 @@ package org.luxons.sevenwonders.game.cards import org.junit.Test import org.luxons.sevenwonders.game.SimplePlayer -import org.luxons.sevenwonders.game.api.Table import org.luxons.sevenwonders.game.boards.Board +import org.luxons.sevenwonders.game.boards.Table import org.luxons.sevenwonders.game.effects.ProductionIncrease import org.luxons.sevenwonders.game.resources.Production import org.luxons.sevenwonders.game.resources.ResourceType diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/HandsTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/HandsTest.kt index eddb4d36..5a71aeda 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/HandsTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/HandsTest.kt @@ -101,7 +101,7 @@ class HandsTest { val table = testTable(2) val hand = hands.createHand(SimplePlayer(0, table)) - hand.map { it.card }.forEach { assertTrue(it in hand0) } + assertEquals(hand0.map { it.name }, hand.map { it.name }) } companion object { diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/RequirementsTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/RequirementsTest.kt index e3e3a393..5abbba6e 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/RequirementsTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/cards/RequirementsTest.kt @@ -7,7 +7,7 @@ import org.junit.experimental.theories.Theories import org.junit.experimental.theories.Theory import org.junit.runner.RunWith import org.luxons.sevenwonders.game.SimplePlayer -import org.luxons.sevenwonders.game.api.Table +import org.luxons.sevenwonders.game.boards.Table import org.luxons.sevenwonders.game.resources.Provider import org.luxons.sevenwonders.game.resources.ResourceType import org.luxons.sevenwonders.game.resources.emptyResources diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/BonusPerBoardElementTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/BonusPerBoardElementTest.kt index 7c8a7e95..700eddb1 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/BonusPerBoardElementTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/BonusPerBoardElementTest.kt @@ -7,8 +7,8 @@ import org.junit.experimental.theories.Theory import org.junit.runner.RunWith import org.luxons.sevenwonders.game.Player import org.luxons.sevenwonders.game.SimplePlayer -import org.luxons.sevenwonders.game.api.Table import org.luxons.sevenwonders.game.boards.RelativeBoardPosition +import org.luxons.sevenwonders.game.boards.Table import org.luxons.sevenwonders.game.cards.CardBack import org.luxons.sevenwonders.game.cards.Color import org.luxons.sevenwonders.game.test.addCards diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/SpecialAbilityActivationTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/SpecialAbilityActivationTest.kt index 41d3d51b..524124b4 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/SpecialAbilityActivationTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/effects/SpecialAbilityActivationTest.kt @@ -39,7 +39,7 @@ class SpecialAbilityActivationTest { } @Theory - fun computePoints_copiedGuild(guildCard: Card, neighbour: RelativeBoardPosition) { + internal fun computePoints_copiedGuild(guildCard: Card, neighbour: RelativeBoardPosition) { val effect = SpecialAbilityActivation(SpecialAbility.COPY_GUILD) val player = SimplePlayer(0, testTable(5)) @@ -71,7 +71,7 @@ class SpecialAbilityActivationTest { @JvmStatic @DataPoints - fun guilds(): Array<Card> { + internal fun guilds(): Array<Card> { val bonus = BonusPerBoardElement( listOf(RelativeBoardPosition.LEFT, RelativeBoardPosition.RIGHT), BoardElementType.CARD, diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/moves/BuildWonderMoveTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/moves/BuildWonderMoveTest.kt index acced6be..b0667d67 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/moves/BuildWonderMoveTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/moves/BuildWonderMoveTest.kt @@ -3,7 +3,7 @@ package org.luxons.sevenwonders.game.moves import org.junit.Test import org.luxons.sevenwonders.game.PlayerContext import org.luxons.sevenwonders.game.Settings -import org.luxons.sevenwonders.game.api.Table +import org.luxons.sevenwonders.game.boards.Table import org.luxons.sevenwonders.game.cards.Card import org.luxons.sevenwonders.game.test.createMove import org.luxons.sevenwonders.game.test.sampleCards diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/BestPriceCalculatorTest.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/BestPriceCalculatorTest.kt index e6751776..5d99ae00 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/BestPriceCalculatorTest.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/resources/BestPriceCalculatorTest.kt @@ -2,7 +2,7 @@ package org.luxons.sevenwonders.game.resources import org.junit.Test import org.luxons.sevenwonders.game.SimplePlayer -import org.luxons.sevenwonders.game.api.Table +import org.luxons.sevenwonders.game.boards.Table import org.luxons.sevenwonders.game.resources.Provider.LEFT_PLAYER import org.luxons.sevenwonders.game.resources.Provider.RIGHT_PLAYER import org.luxons.sevenwonders.game.resources.ResourceType.CLAY diff --git a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/test/TestUtils.kt b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/test/TestUtils.kt index 4bf41a8b..78386b3d 100644 --- a/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/test/TestUtils.kt +++ b/game-engine/src/test/kotlin/org/luxons/sevenwonders/game/test/TestUtils.kt @@ -5,11 +5,11 @@ import org.luxons.sevenwonders.game.PlayerContext import org.luxons.sevenwonders.game.Settings import org.luxons.sevenwonders.game.api.CustomizableSettings import org.luxons.sevenwonders.game.api.PlayerMove -import org.luxons.sevenwonders.game.api.Table import org.luxons.sevenwonders.game.boards.Board import org.luxons.sevenwonders.game.boards.RelativeBoardPosition import org.luxons.sevenwonders.game.boards.Science import org.luxons.sevenwonders.game.boards.ScienceType +import org.luxons.sevenwonders.game.boards.Table import org.luxons.sevenwonders.game.cards.Card import org.luxons.sevenwonders.game.cards.CardBack import org.luxons.sevenwonders.game.cards.Color @@ -38,7 +38,8 @@ internal fun testSettings(nbPlayers: Int = 5, initialGold: Int = 0): Settings = internal fun testTable(nbPlayers: Int = 5): Table = testTable(testSettings(nbPlayers)) -internal fun testTable(settings: Settings): Table = Table(testBoards(settings.nbPlayers, settings)) +internal fun testTable(settings: Settings): Table = + Table(testBoards(settings.nbPlayers, settings)) private fun testBoards(count: Int, settings: Settings): List<Board> = List(count) { testBoard(settings) } |