diff options
author | jbion <joffrey.bion@amadeus.com> | 2019-02-19 18:09:27 +0100 |
---|---|---|
committer | jbion <joffrey.bion@amadeus.com> | 2019-02-19 19:01:52 +0100 |
commit | cab8a5a83e810d14c97fbb26f0cdfe1b86e88d43 (patch) | |
tree | e2e6ce43eca9b20ef82589e174ac411c22a9f318 /game-engine/src/main/kotlin/org | |
parent | Update repository URLs in README (diff) | |
download | seven-wonders-cab8a5a83e810d14c97fbb26f0cdfe1b86e88d43.tar.gz seven-wonders-cab8a5a83e810d14c97fbb26f0cdfe1b86e88d43.tar.bz2 seven-wonders-cab8a5a83e810d14c97fbb26f0cdfe1b86e88d43.zip |
Fix board gold access and cleanup tests
Diffstat (limited to 'game-engine/src/main/kotlin/org')
4 files changed, 7 insertions, 12 deletions
diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/Settings.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/Settings.kt index 3cb14083..63d5052f 100644 --- a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/Settings.kt +++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/Settings.kt @@ -1,15 +1,15 @@ package org.luxons.sevenwonders.game import org.luxons.sevenwonders.game.api.CustomizableSettings -import org.luxons.sevenwonders.game.data.definitions.WonderSide import org.luxons.sevenwonders.game.api.WonderSidePickMethod +import org.luxons.sevenwonders.game.data.definitions.WonderSide import java.util.Random internal class Settings( val nbPlayers: Int, customSettings: CustomizableSettings = CustomizableSettings() ) { - val random: Random + val random: Random = customSettings.randomSeedForTests?.let { Random(it) } ?: Random() val timeLimitInSeconds: Int = customSettings.timeLimitInSeconds val initialGold: Int = customSettings.initialGold val discardedCardGold: Int = customSettings.discardedCardGold @@ -21,11 +21,6 @@ internal class Settings( private val wonderSidePickMethod: WonderSidePickMethod = customSettings.wonderSidePickMethod private var lastPickedSide: WonderSide? = null - init { - val seed = customSettings.randomSeedForTests - this.random = if (seed != null) Random(seed) else Random() - } - fun pickWonderSide(): WonderSide { val newSide = wonderSidePickMethod.pickSide(random, lastPickedSide) lastPickedSide = newSide diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/api/Table.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/api/Table.kt index c4dbeb21..470f3ba0 100644 --- a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/api/Table.kt +++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/api/Table.kt @@ -36,9 +36,9 @@ class Table internal constructor(val boards: List<Board>) { } internal fun resolveMilitaryConflicts() { - for (i in 0 until nbPlayers) { - val board1 = getBoard(i) - val board2 = getBoard(i, RelativeBoardPosition.RIGHT) + repeat(nbPlayers) { + val board1 = getBoard(it) + val board2 = getBoard(it, RelativeBoardPosition.RIGHT) resolveConflict(board1, board2) } } diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/moves/MoveType.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/moves/MoveType.kt index fc859931..ae00f23f 100644 --- a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/moves/MoveType.kt +++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/moves/MoveType.kt @@ -4,7 +4,7 @@ import org.luxons.sevenwonders.game.PlayerContext import org.luxons.sevenwonders.game.api.PlayerMove import org.luxons.sevenwonders.game.cards.Card -enum class MoveType(val create: (move: PlayerMove, card: Card, context: PlayerContext) -> Move) { +enum class MoveType(private val create: (move: PlayerMove, card: Card, context: PlayerContext) -> Move) { PLAY(::PlayCardMove), PLAY_FREE(::PlayFreeCardMove), UPGRADE_WONDER(::BuildWonderMove), diff --git a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/resources/ResourceType.kt b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/resources/ResourceType.kt index 7e259023..5c92b887 100644 --- a/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/resources/ResourceType.kt +++ b/game-engine/src/main/kotlin/org/luxons/sevenwonders/game/resources/ResourceType.kt @@ -1,6 +1,6 @@ package org.luxons.sevenwonders.game.resources -enum class ResourceType(val symbol: Char?) { +enum class ResourceType(val symbol: Char) { WOOD('W'), STONE('S'), ORE('O'), |