diff options
author | Joffrey Bion <joffrey.bion@booking.com> | 2020-05-28 20:26:29 +0200 |
---|---|---|
committer | Joffrey Bion <joffrey.bion@booking.com> | 2020-05-31 11:16:00 +0200 |
commit | 36103b92ce4b6cd00925d861f4fb5e381cdc4833 (patch) | |
tree | 4c2bfced8317526b24da23fcef9febe6368c736e /sw-engine/src/test/kotlin/org | |
parent | Attempt at fixing race conditions with bot subscriptions (diff) | |
download | seven-wonders-36103b92ce4b6cd00925d861f4fb5e381cdc4833.tar.gz seven-wonders-36103b92ce4b6cd00925d861f4fb5e381cdc4833.tar.bz2 seven-wonders-36103b92ce4b6cd00925d861f4fb5e381cdc4833.zip |
Simplify settings and allow choosing wonders
Diffstat (limited to 'sw-engine/src/test/kotlin/org')
5 files changed, 27 insertions, 27 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 51a6376a..595ca1e0 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 @@ -1,17 +1,16 @@ package org.luxons.sevenwonders.engine -import org.luxons.sevenwonders.model.Action -import org.luxons.sevenwonders.model.PlayedMove -import org.luxons.sevenwonders.model.PlayerMove -import org.luxons.sevenwonders.model.PlayerTurnInfo import org.luxons.sevenwonders.model.cards.HandCard import org.luxons.sevenwonders.model.cards.TableCard import org.luxons.sevenwonders.engine.data.GameDefinition import org.luxons.sevenwonders.engine.data.LAST_AGE -import org.luxons.sevenwonders.model.MoveType +import org.luxons.sevenwonders.engine.test.SEED import org.luxons.sevenwonders.model.resources.ResourceTransactions import org.luxons.sevenwonders.model.resources.noTransactions -import org.luxons.sevenwonders.engine.test.testCustomizableSettings +import org.luxons.sevenwonders.engine.test.testSettings +import org.luxons.sevenwonders.model.* +import org.luxons.sevenwonders.model.wonders.deal +import kotlin.random.Random import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFalse @@ -46,8 +45,10 @@ class GameTest { } } - private fun createGame(nbPlayers: Int): Game = - GameDefinition.load().initGame(0, testCustomizableSettings(), nbPlayers) + private fun createGame(nbPlayers: Int): Game = GameDefinition.load().let { + val wonders = it.allWonders.deal(nbPlayers, random = Random(SEED)) + it.createGame(0, wonders, testSettings()) + } private fun playAge(nbPlayers: Int, game: Game, age: Int) { do { diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/cards/CardTest.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/cards/CardTest.kt index 8fd673b2..2b0e5462 100644 --- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/cards/CardTest.kt +++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/cards/CardTest.kt @@ -20,7 +20,7 @@ class CardTest { fun playCardCostingMoney() { val initialGold = 3 val price = 1 - val settings = testSettings(3, initialGold) + val settings = testSettings(initialGold) val boards = listOf( Board(Wonder("TestWonder", ResourceType.WOOD, emptyList(), ""), 0, settings), diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/data/GameDefinitionTest.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/data/GameDefinitionTest.kt index b9b7bb3c..d91c3b50 100644 --- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/data/GameDefinitionTest.kt +++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/data/GameDefinitionTest.kt @@ -1,7 +1,8 @@ package org.luxons.sevenwonders.engine.data import org.junit.Test -import org.luxons.sevenwonders.model.CustomizableSettings +import org.luxons.sevenwonders.model.Settings +import org.luxons.sevenwonders.model.wonders.deal import kotlin.test.assertEquals import kotlin.test.assertNotNull @@ -14,7 +15,8 @@ class GameDefinitionTest { assertEquals(3, gameDefinition.minPlayers) assertEquals(7, gameDefinition.maxPlayers) - val game = gameDefinition.initGame(0, CustomizableSettings(), 7) + val wonders = gameDefinition.allWonders.deal(7) + val game = gameDefinition.createGame(0, wonders, Settings()) assertNotNull(game) } } diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/moves/BuildWonderMoveTest.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/moves/BuildWonderMoveTest.kt index 764d7890..8ff9aa33 100644 --- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/moves/BuildWonderMoveTest.kt +++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/moves/BuildWonderMoveTest.kt @@ -2,7 +2,6 @@ package org.luxons.sevenwonders.engine.moves import org.junit.Test import org.luxons.sevenwonders.engine.PlayerContext -import org.luxons.sevenwonders.engine.Settings import org.luxons.sevenwonders.model.MoveType import org.luxons.sevenwonders.engine.boards.Table import org.luxons.sevenwonders.engine.cards.Card @@ -11,6 +10,7 @@ import org.luxons.sevenwonders.engine.test.sampleCards import org.luxons.sevenwonders.engine.test.testCard import org.luxons.sevenwonders.engine.test.testSettings import org.luxons.sevenwonders.engine.test.testTable +import org.luxons.sevenwonders.model.Settings import kotlin.test.assertEquals import kotlin.test.assertFailsWith import kotlin.test.fail @@ -31,8 +31,8 @@ class BuildWonderMoveTest { @Test fun init_failsWhenWonderIsCompletelyBuilt() { - val settings = testSettings(3) - val table = testTable(settings) + val settings = testSettings() + val table = testTable(3, settings) val hand = sampleCards(7) fillPlayerWonderLevels(settings, table, hand) @@ -64,8 +64,8 @@ class BuildWonderMoveTest { @Test fun place_increasesWonderLevel() { - val settings = testSettings(3) - val table = testTable(settings) + val settings = testSettings() + val table = testTable(3, settings) val hand = sampleCards(7) val cardToUse = hand[0] val playerContext = PlayerContext(0, table, hand) 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 cc97dc54..4db574e2 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 @@ -2,9 +2,8 @@ package org.luxons.sevenwonders.engine.test import org.luxons.sevenwonders.engine.Player import org.luxons.sevenwonders.engine.PlayerContext -import org.luxons.sevenwonders.engine.Settings import org.luxons.sevenwonders.model.resources.CountedResource -import org.luxons.sevenwonders.model.CustomizableSettings +import org.luxons.sevenwonders.model.Settings import org.luxons.sevenwonders.model.PlayerMove import org.luxons.sevenwonders.engine.boards.Board import org.luxons.sevenwonders.model.boards.RelativeBoardPosition @@ -30,18 +29,16 @@ import org.luxons.sevenwonders.engine.resources.resourcesOf import org.luxons.sevenwonders.engine.wonders.Wonder import org.luxons.sevenwonders.engine.wonders.WonderStage -private const val SEED: Long = 42 +internal const val SEED: Long = 42 -internal fun testCustomizableSettings(initialGold: Int = 0): CustomizableSettings = - CustomizableSettings(randomSeedForTests = SEED).copy(initialGold = initialGold) +internal fun testSettings(initialGold: Int = 0): Settings = Settings( + randomSeedForTests = SEED, + initialGold = initialGold +) -internal fun testSettings(nbPlayers: Int = 5, initialGold: Int = 0): Settings = - Settings(nbPlayers, testCustomizableSettings(initialGold)) +internal fun testTable(nbPlayers: Int = 5): Table = testTable(nbPlayers, testSettings()) -internal fun testTable(nbPlayers: Int = 5): Table = testTable(testSettings(nbPlayers)) - -internal fun testTable(settings: Settings): Table = - Table(testBoards(settings.nbPlayers, settings)) +internal fun testTable(nbPlayers: Int, settings: Settings): Table = Table(testBoards(nbPlayers, settings)) private fun testBoards(count: Int, settings: Settings): List<Board> = List(count) { testBoard(settings) } |