diff options
Diffstat (limited to 'sw-engine')
51 files changed, 557 insertions, 585 deletions
diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Game.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Game.kt index 34a8dd99..60dc505b 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Game.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Game.kt @@ -12,7 +12,12 @@ import org.luxons.sevenwonders.engine.data.LAST_AGE import org.luxons.sevenwonders.engine.effects.SpecialAbility import org.luxons.sevenwonders.engine.moves.Move import org.luxons.sevenwonders.engine.moves.resolve -import org.luxons.sevenwonders.model.* +import org.luxons.sevenwonders.model.Action +import org.luxons.sevenwonders.model.MoveType +import org.luxons.sevenwonders.model.PlayerMove +import org.luxons.sevenwonders.model.PlayerTurnInfo +import org.luxons.sevenwonders.model.Settings +import org.luxons.sevenwonders.model.TableState import org.luxons.sevenwonders.model.cards.CardBack import org.luxons.sevenwonders.model.cards.HandCard import org.luxons.sevenwonders.model.score.ScoreBoard @@ -21,7 +26,7 @@ class Game internal constructor( val id: Long, private val settings: Settings, boards: List<Board>, - private val decks: Decks + private val decks: Decks, ) { private val table: Table = Table(boards) private val players: List<Player> = boards.map { SimplePlayer(it.playerIndex, table) } @@ -86,7 +91,7 @@ class Game internal constructor( hand = hand, preparedMove = preparedMoves[player.index]?.toPlayedMove(), discardedCards = exposedDiscardedCards, - neighbourGuildCards = neighbourGuildCards + neighbourGuildCards = neighbourGuildCards, ) } diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Player.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Player.kt index e28fa7bf..75e7c9ec 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Player.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Player.kt @@ -13,7 +13,7 @@ internal interface Player { internal data class SimplePlayer( override val index: Int, - private val table: Table + private val table: Table, ) : Player { override val board = table.getBoard(index) override fun getBoard(relativePosition: RelativeBoardPosition) = table.getBoard(index, relativePosition) @@ -22,7 +22,7 @@ internal data class SimplePlayer( internal data class PlayerContext( override val index: Int, private val table: Table, - val hand: List<Card> + val hand: List<Card>, ) : Player by SimplePlayer(index, table) { val currentAge = table.currentAge } diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/boards/Board.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/boards/Board.kt index a78d6d4b..3a3521ee 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/boards/Board.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/boards/Board.kt @@ -13,8 +13,11 @@ import org.luxons.sevenwonders.model.cards.Color import org.luxons.sevenwonders.model.score.PlayerScore import org.luxons.sevenwonders.model.score.ScoreCategory -internal class Board(val wonder: Wonder, val playerIndex: Int, settings: Settings) { - +internal class Board( + val wonder: Wonder, + val playerIndex: Int, + settings: Settings, +) { val production = Production(mutableResourcesOf(wonder.initialResource)) val publicProduction = Production(mutableResourcesOf(wonder.initialResource)) val science = Science() @@ -86,14 +89,12 @@ internal class Board(val wonder: Wonder, val playerIndex: Int, settings: Setting ScoreCategory.TRADE to computePointsForCards(player, Color.YELLOW), ScoreCategory.GUILD to computePointsForCards(player, Color.PURPLE), ScoreCategory.WONDER to wonder.computePoints(player), - ScoreCategory.GOLD to computeGoldPoints() - ) + ScoreCategory.GOLD to computeGoldPoints(), + ), ) private fun computePointsForCards(player: Player, color: Color): Int = - playedCards.filter { it.color === color } - .flatMap { it.effects } - .sumBy { it.computePoints(player) } + playedCards.filter { it.color === color }.flatMap { it.effects }.sumBy { it.computePoints(player) } private fun computeGoldPoints(): Int = gold / 3 * pointsPer3Gold diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/boards/Military.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/boards/Military.kt index ea008e4c..a449268a 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/boards/Military.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/boards/Military.kt @@ -4,7 +4,7 @@ import org.luxons.sevenwonders.model.Age internal class Military( private val lostPointsPerDefeat: Int, - private val wonPointsPerVictoryPerAge: Map<Age, Int> + private val wonPointsPerVictoryPerAge: Map<Age, Int>, ) { var nbShields = 0 private set diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/boards/Table.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/boards/Table.kt index b8da6ae7..62554492 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/boards/Table.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/boards/Table.kt @@ -54,7 +54,7 @@ internal class Table(val boards: List<Board>) { } } - fun getNeighbourGuildCards(playerIndex: Int): List<Card> = neighboursPositions() - .flatMap { getBoard(playerIndex, it).getPlayedCards() } + fun getNeighbourGuildCards(playerIndex: Int): List<Card> = neighboursPositions() // + .flatMap { getBoard(playerIndex, it).getPlayedCards() } // .filter { it.color == Color.PURPLE } } diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/Cards.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/Cards.kt index cc00123e..438798bf 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/Cards.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/Cards.kt @@ -18,7 +18,7 @@ internal data class Card( val chainParent: String?, val chainChildren: List<String>, val image: String, - val back: CardBack + val back: CardBack, ) { fun computePlayabilityBy(player: Player, forceSpecialFree: Boolean = false): CardPlayability = when { isAlreadyOnBoard(player.board) -> Playability.incompatibleWithBoard() // cannot play twice the same card @@ -47,35 +47,29 @@ internal data class Card( private object Playability { fun incompatibleWithBoard(): CardPlayability = - CardPlayability( - isPlayable = false, - playabilityLevel = PlayabilityLevel.INCOMPATIBLE_WITH_BOARD - ) + CardPlayability(isPlayable = false, playabilityLevel = PlayabilityLevel.INCOMPATIBLE_WITH_BOARD) - fun chainable(): CardPlayability = - CardPlayability( - isPlayable = true, - isChainable = true, - minPrice = 0, - cheapestTransactions = setOf(noTransactions()), - playabilityLevel = PlayabilityLevel.CHAINABLE - ) + fun chainable(): CardPlayability = CardPlayability( + isPlayable = true, + isChainable = true, + minPrice = 0, + cheapestTransactions = setOf(noTransactions()), + playabilityLevel = PlayabilityLevel.CHAINABLE, + ) - fun requirementDependent(satisfaction: RequirementsSatisfaction): CardPlayability = - CardPlayability( - isPlayable = satisfaction.satisfied, - isChainable = false, - minPrice = satisfaction.minPrice, - cheapestTransactions = satisfaction.cheapestTransactions, - playabilityLevel = satisfaction.level - ) + fun requirementDependent(satisfaction: RequirementsSatisfaction): CardPlayability = CardPlayability( + isPlayable = satisfaction.satisfied, + isChainable = false, + minPrice = satisfaction.minPrice, + cheapestTransactions = satisfaction.cheapestTransactions, + playabilityLevel = satisfaction.level, + ) - fun specialFree(): CardPlayability = - CardPlayability( - isPlayable = true, - isChainable = false, - minPrice = 0, - cheapestTransactions = setOf(noTransactions()), - playabilityLevel = PlayabilityLevel.SPECIAL_FREE - ) + fun specialFree(): CardPlayability = CardPlayability( + isPlayable = true, + isChainable = false, + minPrice = 0, + cheapestTransactions = setOf(noTransactions()), + playabilityLevel = PlayabilityLevel.SPECIAL_FREE, + ) } diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/Decks.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/Decks.kt index e8d9ab40..ac36a72f 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/Decks.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/Decks.kt @@ -1,8 +1,8 @@ package org.luxons.sevenwonders.engine.cards internal fun List<Card>.deal(nbPlayers: Int): Hands { - val hands: Map<Int, List<Card>> = this.withIndex() - .groupBy { (index, _) -> index % nbPlayers } + val hands: Map<Int, List<Card>> = this.withIndex() // + .groupBy { (index, _) -> index % nbPlayers } // .mapValues { it.value.map { (_, cards) -> cards } } val allHands = List(nbPlayers) { i -> hands[i] ?: emptyList() } @@ -33,5 +33,5 @@ internal class Decks(private val cardsPerAge: Map<Int, List<Card>>) { } } - inner class CardNotFoundException(message: String) : RuntimeException(message) + class CardNotFoundException(message: String) : RuntimeException(message) } diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/Requirements.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/Requirements.kt index b9ffe247..945f4463 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/Requirements.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/Requirements.kt @@ -11,7 +11,7 @@ import org.luxons.sevenwonders.model.resources.ResourceTransactions data class Requirements internal constructor( val gold: Int = 0, - val resources: Resources = emptyResources() + val resources: Resources = emptyResources(), ) { /** * Returns information about the extent to which the given [player] meets these requirements, either on its own or diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/RequirementsSatisfaction.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/RequirementsSatisfaction.kt index e010c6aa..3a1ac5ce 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/RequirementsSatisfaction.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/RequirementsSatisfaction.kt @@ -8,7 +8,7 @@ internal data class RequirementsSatisfaction( val satisfied: Boolean, val level: PlayabilityLevel, val minPrice: Int, - val cheapestTransactions: Set<ResourceTransactions> + val cheapestTransactions: Set<ResourceTransactions>, ) { companion object { diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Boards.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Boards.kt index df321952..2ddce8a8 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Boards.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Boards.kt @@ -25,22 +25,20 @@ import org.luxons.sevenwonders.model.boards.Production as ApiProduction import org.luxons.sevenwonders.model.boards.Requirements as ApiRequirements import org.luxons.sevenwonders.model.boards.Science as ApiScience -internal fun InternalBoard.toApiBoard(player: Player, lastMove: Move?, currentAge: Age): ApiBoard = - ApiBoard( - playerIndex = playerIndex, - wonder = wonder.toApiWonder(player, lastMove), - production = production.toApiProduction(), - publicProduction = publicProduction.toApiProduction(), - science = science.toApiScience(), - military = military.toApiMilitary(), - playedCards = getPlayedCards().map { it.toTableCard(lastMove) }.toColumns(), - gold = gold, - bluePoints = getPlayedCards() - .filter { it.color == Color.BLUE } - .flatMap { it.effects.filterIsInstance<RawPointsIncrease>() } - .sumBy { it.points }, - canPlayAnyCardForFree = canPlayFreeCard(currentAge) - ) +internal fun InternalBoard.toApiBoard(player: Player, lastMove: Move?, currentAge: Age): ApiBoard = ApiBoard( + playerIndex = playerIndex, + wonder = wonder.toApiWonder(player, lastMove), + production = production.toApiProduction(), + publicProduction = publicProduction.toApiProduction(), + science = science.toApiScience(), + military = military.toApiMilitary(), + playedCards = getPlayedCards().map { it.toTableCard(lastMove) }.toColumns(), + gold = gold, + bluePoints = getPlayedCards().filter { it.color == Color.BLUE } + .flatMap { it.effects.filterIsInstance<RawPointsIncrease>() } + .sumBy { it.points }, + canPlayAnyCardForFree = canPlayFreeCard(currentAge), +) internal fun List<TableCard>.toColumns(): List<List<TableCard>> { val cardsByColor = this.groupBy { it.color } @@ -59,7 +57,7 @@ internal fun InternalWonder.toApiWonder(player: Player, lastMove: Move?): ApiWon stages = stages.map { it.toApiWonderStage(lastBuiltStage == it, lastMove) }, image = image, nbBuiltStages = nbBuiltStages, - buildability = computeBuildabilityBy(player) + buildability = computeBuildabilityBy(player), ) internal fun InternalWonderStage.toApiWonderStage(isLastBuiltStage: Boolean, lastMove: Move?): ApiWonderStage = @@ -67,33 +65,28 @@ internal fun InternalWonderStage.toApiWonderStage(isLastBuiltStage: Boolean, las cardBack = cardBack, isBuilt = isBuilt, requirements = requirements.toApiRequirements(), - builtDuringLastMove = lastMove?.type == MoveType.UPGRADE_WONDER && isLastBuiltStage + builtDuringLastMove = lastMove?.type == MoveType.UPGRADE_WONDER && isLastBuiltStage, ) -internal fun InternalProduction.toApiProduction(): ApiProduction = - ApiProduction( - fixedResources = getFixedResources().toCountedResourcesList(), - alternativeResources = getAlternativeResources().sortedBy { it.size } - ) +internal fun InternalProduction.toApiProduction(): ApiProduction = ApiProduction( + fixedResources = getFixedResources().toCountedResourcesList(), + alternativeResources = getAlternativeResources().sortedBy { it.size }, +) internal fun InternalRequirements.toApiRequirements(): ApiRequirements = - ApiRequirements( - gold = gold, - resources = resources.toCountedResourcesList() - ) + ApiRequirements(gold = gold, resources = resources.toCountedResourcesList()) -internal fun Resources.toCountedResourcesList(): List<CountedResource> = - quantities.filterValues { it > 0 } - .map { (type, count) -> CountedResource(count, type) } +internal fun Resources.toCountedResourcesList(): List<CountedResource> = // + quantities.filterValues { it > 0 } // + .map { (type, count) -> CountedResource(count, type) } // .sortedBy { it.type } internal fun InternalMilitary.toApiMilitary(): ApiMilitary = ApiMilitary(nbShields, victoryPoints, totalPoints, nbDefeatTokens) -internal fun InternalScience.toApiScience(): ApiScience = - ApiScience( - jokers = jokers, - nbWheels = getQuantity(ScienceType.WHEEL), - nbCompasses = getQuantity(ScienceType.COMPASS), - nbTablets = getQuantity(ScienceType.TABLET) - ) +internal fun InternalScience.toApiScience(): ApiScience = ApiScience( + jokers = jokers, + nbWheels = getQuantity(ScienceType.WHEEL), + nbCompasses = getQuantity(ScienceType.COMPASS), + nbTablets = getQuantity(ScienceType.TABLET), +) diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Cards.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Cards.kt index f0e17515..7c9c5d32 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Cards.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Cards.kt @@ -6,26 +6,24 @@ import org.luxons.sevenwonders.engine.moves.Move import org.luxons.sevenwonders.model.cards.HandCard import org.luxons.sevenwonders.model.cards.TableCard -internal fun Card.toTableCard(lastMove: Move? = null): TableCard = - TableCard( - name = name, - color = color, - requirements = requirements.toApiRequirements(), - chainParent = chainParent, - chainChildren = chainChildren, - image = image, - back = back, - playedDuringLastMove = lastMove != null && this.name == lastMove.card.name - ) +internal fun Card.toTableCard(lastMove: Move? = null): TableCard = TableCard( + name = name, + color = color, + requirements = requirements.toApiRequirements(), + chainParent = chainParent, + chainChildren = chainChildren, + image = image, + back = back, + playedDuringLastMove = lastMove != null && this.name == lastMove.card.name, +) -internal fun Card.toHandCard(player: Player, forceSpecialFree: Boolean): HandCard = - HandCard( - name = name, - color = color, - requirements = requirements.toApiRequirements(), - chainParent = chainParent, - chainChildren = chainChildren, - image = image, - back = back, - playability = computePlayabilityBy(player, forceSpecialFree) - ) +internal fun Card.toHandCard(player: Player, forceSpecialFree: Boolean): HandCard = HandCard( + name = name, + color = color, + requirements = requirements.toApiRequirements(), + chainParent = chainParent, + chainChildren = chainChildren, + image = image, + back = back, + playability = computePlayabilityBy(player, forceSpecialFree), +) diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Table.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Table.kt index 60ee5b21..ec61b42f 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Table.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Table.kt @@ -7,15 +7,17 @@ import org.luxons.sevenwonders.model.PlayedMove import org.luxons.sevenwonders.model.TableState internal fun Table.toTableState(): TableState = TableState( - boards = boards.mapIndexed { i, b -> b.toApiBoard(SimplePlayer(i, this), lastPlayedMoves.getOrNull(i), currentAge) }, + boards = boards.mapIndexed { i, b -> + b.toApiBoard(SimplePlayer(i, this), lastPlayedMoves.getOrNull(i), currentAge) + }, currentAge = currentAge, handRotationDirection = handRotationDirection, - lastPlayedMoves = lastPlayedMoves.map { it.toPlayedMove() } + lastPlayedMoves = lastPlayedMoves.map { it.toPlayedMove() }, ) internal fun Move.toPlayedMove(): PlayedMove = PlayedMove( playerIndex = playerContext.index, type = type, card = card.toTableCard(this), - transactions = transactions + transactions = transactions, ) diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/GameDefinition.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/GameDefinition.kt index 4228f6af..07c101e6 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/GameDefinition.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/GameDefinition.kt @@ -7,8 +7,18 @@ import org.luxons.sevenwonders.engine.Game import org.luxons.sevenwonders.engine.boards.Board import org.luxons.sevenwonders.engine.data.definitions.DecksDefinition import org.luxons.sevenwonders.engine.data.definitions.WonderDefinition -import org.luxons.sevenwonders.engine.data.serializers.* -import org.luxons.sevenwonders.engine.effects.* +import org.luxons.sevenwonders.engine.data.serializers.NumericEffectSerializer +import org.luxons.sevenwonders.engine.data.serializers.ProductionIncreaseSerializer +import org.luxons.sevenwonders.engine.data.serializers.ProductionSerializer +import org.luxons.sevenwonders.engine.data.serializers.ResourceTypeSerializer +import org.luxons.sevenwonders.engine.data.serializers.ResourceTypesSerializer +import org.luxons.sevenwonders.engine.data.serializers.ResourcesSerializer +import org.luxons.sevenwonders.engine.data.serializers.ScienceProgressSerializer +import org.luxons.sevenwonders.engine.effects.GoldIncrease +import org.luxons.sevenwonders.engine.effects.MilitaryReinforcements +import org.luxons.sevenwonders.engine.effects.ProductionIncrease +import org.luxons.sevenwonders.engine.effects.RawPointsIncrease +import org.luxons.sevenwonders.engine.effects.ScienceProgress import org.luxons.sevenwonders.engine.resources.Production import org.luxons.sevenwonders.engine.resources.Resources import org.luxons.sevenwonders.model.Age @@ -21,13 +31,13 @@ internal const val LAST_AGE: Age = 3 internal data class GlobalRules( val minPlayers: Int, - val maxPlayers: Int + val maxPlayers: Int, ) class GameDefinition internal constructor( rules: GlobalRules, wonderDefinitions: List<WonderDefinition>, - private val decksDefinition: DecksDefinition + private val decksDefinition: DecksDefinition, ) { val minPlayers: Int = rules.minPlayers val maxPlayers: Int = rules.maxPlayers diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/definitions/CardDefinition.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/definitions/CardDefinition.kt index 1785ad49..cc42641a 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/definitions/CardDefinition.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/definitions/CardDefinition.kt @@ -13,7 +13,7 @@ internal class CardDefinition( private val chainParent: String?, private val chainChildren: List<String>?, private val image: String, - private val countPerNbPlayer: Map<Int, Int> + private val countPerNbPlayer: Map<Int, Int>, ) { fun create(back: CardBack, nbPlayers: Int): List<Card> = List(countPerNbPlayer[nbPlayers] ?: 0) { create(back) } diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/definitions/DecksDefinition.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/definitions/DecksDefinition.kt index e4dfb8fd..f3dc42f4 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/definitions/DecksDefinition.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/definitions/DecksDefinition.kt @@ -7,7 +7,7 @@ import kotlin.random.Random internal class DeckDefinition( val cards: List<CardDefinition>, - val backImage: String + val backImage: String, ) { fun create(nbPlayers: Int): List<Card> = cards.flatMap { it.create(CardBack(backImage), nbPlayers) } } @@ -16,14 +16,14 @@ internal class DecksDefinition( private val age1: DeckDefinition, private val age2: DeckDefinition, private val age3: DeckDefinition, - private val guildCards: List<CardDefinition> + private val guildCards: List<CardDefinition>, ) { fun prepareDecks(nbPlayers: Int, random: Random) = Decks( mapOf( 1 to age1.create(nbPlayers).shuffled(random), 2 to age2.create(nbPlayers).shuffled(random), - 3 to (age3.create(nbPlayers) + pickGuildCards(nbPlayers, random)).shuffled(random) - ) + 3 to (age3.create(nbPlayers) + pickGuildCards(nbPlayers, random)).shuffled(random), + ), ) private fun pickGuildCards(nbPlayers: Int, random: Random): List<Card> { diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/definitions/EffectsDefinition.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/definitions/EffectsDefinition.kt index 0322d657..86829eca 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/definitions/EffectsDefinition.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/definitions/EffectsDefinition.kt @@ -19,7 +19,7 @@ internal class EffectsDefinition( private val perBoardElement: BonusPerBoardElement? = null, private val production: ProductionIncrease? = null, private val points: RawPointsIncrease? = null, - private val action: SpecialAbility? = null + private val action: SpecialAbility? = null, ) { fun create(): List<Effect> = mutableListOf<Effect>().apply { gold?.let { add(it) } diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/definitions/WonderDefinition.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/definitions/WonderDefinition.kt index e7f1e0fc..2a59f6dc 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/definitions/WonderDefinition.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/definitions/WonderDefinition.kt @@ -9,7 +9,7 @@ import org.luxons.sevenwonders.model.wonders.WonderSide internal class WonderDefinition( val name: WonderName, - val sides: Map<WonderSide, WonderSideDefinition> + val sides: Map<WonderSide, WonderSideDefinition>, ) { fun create(wonderSide: WonderSide): Wonder = sides[wonderSide]!!.createWonder(name) } @@ -17,14 +17,14 @@ internal class WonderDefinition( internal class WonderSideDefinition( private val initialResource: ResourceType, private val stages: List<WonderStageDefinition>, - val image: String + val image: String, ) { fun createWonder(name: String): Wonder = Wonder(name, initialResource, stages.map { it.create() }, image) } internal class WonderStageDefinition( private val requirements: Requirements, - private val effects: EffectsDefinition + private val effects: EffectsDefinition, ) { fun create(): WonderStage = WonderStage(requirements, effects.create()) } diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/serializers/ProductionIncreaseSerializer.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/serializers/ProductionIncreaseSerializer.kt index 5115649f..dc340578 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/serializers/ProductionIncreaseSerializer.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/serializers/ProductionIncreaseSerializer.kt @@ -16,18 +16,18 @@ internal class ProductionIncreaseSerializer : JsonSerializer<ProductionIncrease> override fun serialize( productionIncrease: ProductionIncrease, typeOfSrc: Type, - context: JsonSerializationContext + context: JsonSerializationContext, ): JsonElement { val production = productionIncrease.production val json = context.serialize(production) - return if (!json.isJsonNull && !productionIncrease.isSellable) { JsonPrimitive("(${json.asString})") } else json + return if (!json.isJsonNull && !productionIncrease.isSellable) JsonPrimitive("(${json.asString})") else json } @Throws(JsonParseException::class) override fun deserialize( json: JsonElement, typeOfT: Type, - context: JsonDeserializationContext + context: JsonDeserializationContext, ): ProductionIncrease { var prodJson = json diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/serializers/ResourceTypesSerializer.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/serializers/ResourceTypesSerializer.kt index 2383685c..ebbee8fd 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/serializers/ResourceTypesSerializer.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/serializers/ResourceTypesSerializer.kt @@ -15,7 +15,7 @@ internal class ResourceTypesSerializer : JsonSerializer<List<ResourceType>>, Jso override fun serialize( resources: List<ResourceType>, typeOfSrc: Type, - context: JsonSerializationContext + context: JsonSerializationContext, ): JsonElement { val s = resources.map { it.symbol }.joinToString("") return JsonPrimitive(s) @@ -25,6 +25,6 @@ internal class ResourceTypesSerializer : JsonSerializer<List<ResourceType>>, Jso override fun deserialize( json: JsonElement, typeOfT: Type, - context: JsonDeserializationContext + context: JsonDeserializationContext, ): List<ResourceType> = json.asString.map { ResourceType.fromSymbol(it) } } diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/serializers/ScienceProgressSerializer.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/serializers/ScienceProgressSerializer.kt index 1d9f8349..1193c94b 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/serializers/ScienceProgressSerializer.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/serializers/ScienceProgressSerializer.kt @@ -1,6 +1,13 @@ package org.luxons.sevenwonders.engine.data.serializers -import com.google.gson.* +import com.google.gson.JsonDeserializationContext +import com.google.gson.JsonDeserializer +import com.google.gson.JsonElement +import com.google.gson.JsonNull +import com.google.gson.JsonParseException +import com.google.gson.JsonPrimitive +import com.google.gson.JsonSerializationContext +import com.google.gson.JsonSerializer import org.luxons.sevenwonders.engine.boards.Science import org.luxons.sevenwonders.engine.boards.ScienceType import org.luxons.sevenwonders.engine.effects.ScienceProgress @@ -11,7 +18,7 @@ internal class ScienceProgressSerializer : JsonSerializer<ScienceProgress>, Json override fun serialize( scienceProgress: ScienceProgress, typeOfSrc: Type, - context: JsonSerializationContext + context: JsonSerializationContext, ): JsonElement { val science = scienceProgress.science diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/BonusPerBoardElement.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/BonusPerBoardElement.kt index 95eaae99..41dbd937 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/BonusPerBoardElement.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/BonusPerBoardElement.kt @@ -8,7 +8,7 @@ import org.luxons.sevenwonders.model.cards.Color enum class BoardElementType { CARD, BUILT_WONDER_STAGES, - DEFEAT_TOKEN + DEFEAT_TOKEN, } internal data class BonusPerBoardElement( @@ -16,16 +16,14 @@ internal data class BonusPerBoardElement( val type: BoardElementType, val gold: Int = 0, val points: Int = 0, - val colors: List<Color>? = null // only relevant if type=CARD + val colors: List<Color>? = null, // only relevant if type=CARD ) : Effect { override fun applyTo(player: Player) = player.board.addGold(gold * nbMatchingElementsFor(player)) override fun computePoints(player: Player): Int = points * nbMatchingElementsFor(player) - private fun nbMatchingElementsFor(player: Player): Int = boards - .map(player::getBoard) - .sumBy { nbMatchingElementsIn(it) } + private fun nbMatchingElementsFor(player: Player): Int = boards.sumBy { nbMatchingElementsIn(player.getBoard(it)) } private fun nbMatchingElementsIn(board: Board): Int = when (type) { BoardElementType.CARD -> board.getNbCardsOfColor(colors!!) diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/Discount.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/Discount.kt index 28ffb49d..83a45e28 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/Discount.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/Discount.kt @@ -7,7 +7,7 @@ import org.luxons.sevenwonders.model.resources.ResourceType internal data class Discount( val resourceTypes: List<ResourceType> = emptyList(), val providers: List<Provider> = emptyList(), - val discountedPrice: Int = 1 + val discountedPrice: Int = 1, ) : InstantOwnBoardEffect() { public override fun applyTo(board: Board) { diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/DiscardMove.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/DiscardMove.kt index 6637cc6c..7635e1a3 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/DiscardMove.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/DiscardMove.kt @@ -5,8 +5,7 @@ import org.luxons.sevenwonders.engine.cards.Card import org.luxons.sevenwonders.model.PlayerMove import org.luxons.sevenwonders.model.Settings -internal class DiscardMove(move: PlayerMove, card: Card, player: PlayerContext) : - CardFromHandMove(move, card, player) { +internal class DiscardMove(move: PlayerMove, card: Card, player: PlayerContext) : CardFromHandMove(move, card, player) { override fun place(discardedCards: MutableList<Card>, settings: Settings) { discardedCards.add(card) diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/Move.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/Move.kt index 2841d0c0..b0035f63 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/Move.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/Move.kt @@ -10,7 +10,7 @@ import org.luxons.sevenwonders.model.resources.ResourceTransactions internal abstract class Move( val move: PlayerMove, val card: Card, - val playerContext: PlayerContext + val playerContext: PlayerContext, ) { val type: MoveType = move.type @@ -21,9 +21,8 @@ internal abstract class Move( abstract fun activate(discardedCards: List<Card>, settings: Settings) } -class InvalidMoveException internal constructor(move: Move, message: String) : IllegalArgumentException( - "Player ${move.playerContext.index} cannot perform move ${move.type}: $message" -) +class InvalidMoveException internal constructor(move: Move, message: String) : + IllegalArgumentException("Player ${move.playerContext.index} cannot perform move ${move.type}: $message") internal fun MoveType.resolve(move: PlayerMove, card: Card, context: PlayerContext, discardedCards: List<Card>): Move = when (this) { diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/PlayFreeDiscardedCardMove.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/PlayFreeDiscardedCardMove.kt index 9a15349d..bd2eeb86 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/PlayFreeDiscardedCardMove.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/PlayFreeDiscardedCardMove.kt @@ -10,7 +10,7 @@ internal class PlayFreeDiscardedCardMove( move: PlayerMove, card: Card, playerContext: PlayerContext, - discardedCards: List<Card> + discardedCards: List<Card>, ) : Move(move, card, playerContext) { init { diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/resources/BestPriceCalculator.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/resources/BestPriceCalculator.kt index dd2d2cae..e5f27c05 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/resources/BestPriceCalculator.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/resources/BestPriceCalculator.kt @@ -15,7 +15,7 @@ data class TransactionPlan(val price: Int, val possibleTransactions: Set<Resourc private class ResourcePool( val provider: Provider?, private val rules: TradingRules, - choices: List<Set<ResourceType>> + choices: List<Set<ResourceType>>, ) { val choices: Set<MutableSet<ResourceType>> = choices.mapTo(HashSet()) { it.toMutableSet() } diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/resources/Production.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/resources/Production.kt index 4f9bbe90..3eb59bd5 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/resources/Production.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/resources/Production.kt @@ -6,7 +6,7 @@ import java.util.EnumSet data class Production internal constructor( private val fixedResources: MutableResources = mutableResourcesOf(), // cannot be a Set because the same choices can be there multiple times - private val alternativeResources: MutableList<Set<ResourceType>> = mutableListOf() + private val alternativeResources: MutableList<Set<ResourceType>> = mutableListOf(), ) { fun getFixedResources(): Resources = fixedResources @@ -43,7 +43,7 @@ data class Production internal constructor( private fun containedInAlternatives( resources: MutableResources, - alternatives: MutableList<Set<ResourceType>> + alternatives: MutableList<Set<ResourceType>>, ): Boolean { if (resources.isEmpty()) { return true diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/resources/ResourceTransactions.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/resources/ResourceTransactions.kt index be9b9e76..c3e0fefa 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/resources/ResourceTransactions.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/resources/ResourceTransactions.kt @@ -7,9 +7,9 @@ import org.luxons.sevenwonders.model.resources.Provider import org.luxons.sevenwonders.model.resources.ResourceTransaction import org.luxons.sevenwonders.model.resources.ResourceTransactions -fun Map<Provider, Resources>.toTransactions(): ResourceTransactions = - filterValues { !it.isEmpty() } - .map { (p, res) -> ResourceTransaction(p, res.toCountedResourcesList()) } +fun Map<Provider, Resources>.toTransactions(): ResourceTransactions = // + filterValues { !it.isEmpty() } // + .map { (p, res) -> ResourceTransaction(p, res.toCountedResourcesList()) } // .toSet() fun ResourceTransactions.asResources(): Resources = flatMap { it.resources }.asResources() diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/resources/Resources.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/resources/Resources.kt index 3d9654ed..b2dfc964 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/resources/Resources.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/resources/Resources.kt @@ -64,7 +64,7 @@ interface Resources { } class MutableResources( - override val quantities: MutableMap<ResourceType, Int> = mutableMapOf() + override val quantities: MutableMap<ResourceType, Int> = mutableMapOf(), ) : Resources { fun add(type: ResourceType, quantity: Int) { diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/wonders/Wonder.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/wonders/Wonder.kt index 0e1b37f0..81c23160 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/wonders/Wonder.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/wonders/Wonder.kt @@ -13,7 +13,7 @@ internal class Wonder( val name: String, val initialResource: ResourceType, val stages: List<WonderStage>, - val image: String + val image: String, ) { val nbBuiltStages: Int get() = stages.count { it.isBuilt } @@ -54,14 +54,13 @@ private object Buildability { isBuildable = false, minPrice = Int.MAX_VALUE, cheapestTransactions = emptySet(), - playabilityLevel = PlayabilityLevel.INCOMPATIBLE_WITH_BOARD + playabilityLevel = PlayabilityLevel.INCOMPATIBLE_WITH_BOARD, ) - internal fun requirementDependent(satisfaction: RequirementsSatisfaction) = - WonderBuildability( - isBuildable = satisfaction.satisfied, - minPrice = satisfaction.minPrice, - cheapestTransactions = satisfaction.cheapestTransactions, - playabilityLevel = satisfaction.level - ) + fun requirementDependent(satisfaction: RequirementsSatisfaction) = WonderBuildability( + isBuildable = satisfaction.satisfied, + minPrice = satisfaction.minPrice, + cheapestTransactions = satisfaction.cheapestTransactions, + playabilityLevel = satisfaction.level, + ) } diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/wonders/WonderStage.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/wonders/WonderStage.kt index 974c6a7a..80b69f52 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/wonders/WonderStage.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/wonders/WonderStage.kt @@ -9,7 +9,7 @@ import org.luxons.sevenwonders.model.resources.ResourceTransactions internal class WonderStage( val requirements: Requirements, - val effects: List<Effect> + val effects: List<Effect>, ) { var cardBack: CardBack? = null private set diff --git a/sw-engine/src/main/resources/org/luxons/sevenwonders/engine/data/wonders.json b/sw-engine/src/main/resources/org/luxons/sevenwonders/engine/data/wonders.json index 3fa5063f..9049ca5e 100644 --- a/sw-engine/src/main/resources/org/luxons/sevenwonders/engine/data/wonders.json +++ b/sw-engine/src/main/resources/org/luxons/sevenwonders/engine/data/wonders.json @@ -12,16 +12,14 @@ "effects": { "points": 3 } - }, - { + }, { "requirements": { "resources": "OO" }, "effects": { "production": "(W/S/O/C)" } - }, - { + }, { "requirements": { "resources": "GG" }, @@ -42,16 +40,14 @@ "effects": { "production": "(W/S/O/C)" } - }, - { + }, { "requirements": { "resources": "WW" }, "effects": { "production": "(G/P/L)" } - }, - { + }, { "requirements": { "resources": "SSS" }, @@ -63,411 +59,380 @@ "image": "alexandriaB.png" } } - }, - { - "name": "Babylon", - "sides": { - "A": { - "initialResource": "C", - "stages": [ - { - "requirements": { - "resources": "CC" - }, - "effects": { - "points": 3 - } + }, { + "name": "Babylon", + "sides": { + "A": { + "initialResource": "C", + "stages": [ + { + "requirements": { + "resources": "CC" }, - { - "requirements": { - "resources": "WWW" - }, - "effects": { - "science": "any" - } + "effects": { + "points": 3 + } + }, { + "requirements": { + "resources": "WWW" }, - { - "requirements": { - "resources": "CCCC" - }, - "effects": { - "points": 7 - } + "effects": { + "science": "any" } - ], - "image": "babylonA.png" - }, - "B": { - "initialResource": "C", - "stages": [ - { - "requirements": { - "resources": "CL" - }, - "effects": { - "points": 3 - } + }, { + "requirements": { + "resources": "CCCC" }, - { - "requirements": { - "resources": "WWG" - }, - "effects": { - "action": "PLAY_LAST_CARD" - } + "effects": { + "points": 7 + } + } + ], + "image": "babylonA.png" + }, + "B": { + "initialResource": "C", + "stages": [ + { + "requirements": { + "resources": "CL" }, - { - "requirements": { - "resources": "CCCP" - }, - "effects": { - "science": "any" - } + "effects": { + "points": 3 } - ], - "image": "babylonB.png" - } + }, { + "requirements": { + "resources": "WWG" + }, + "effects": { + "action": "PLAY_LAST_CARD" + } + }, { + "requirements": { + "resources": "CCCP" + }, + "effects": { + "science": "any" + } + } + ], + "image": "babylonB.png" } - }, - { - "name": "Ephesos", - "sides": { - "A": { - "initialResource": "P", - "stages": [ - { - "requirements": { - "resources": "SS" - }, - "effects": { - "points": 3 - } + } +}, { + "name": "Ephesos", + "sides": { + "A": { + "initialResource": "P", + "stages": [ + { + "requirements": { + "resources": "SS" }, - { - "requirements": { - "resources": "WW" - }, - "effects": { - "gold": 9 - } + "effects": { + "points": 3 + } + }, { + "requirements": { + "resources": "WW" }, - { - "requirements": { - "resources": "PP" - }, - "effects": { - "points": 7 - } + "effects": { + "gold": 9 } - ], - "image": "ephesosA.png" - }, - "B": { - "initialResource": "P", - "stages": [ - { - "requirements": { - "resources": "SS" - }, - "effects": { - "gold": 4, - "points": 2 - } + }, { + "requirements": { + "resources": "PP" }, - { - "requirements": { - "resources": "WW" - }, - "effects": { - "gold": 4, - "points": 3 - } + "effects": { + "points": 7 + } + } + ], + "image": "ephesosA.png" + }, + "B": { + "initialResource": "P", + "stages": [ + { + "requirements": { + "resources": "SS" }, - { - "requirements": { - "resources": "GPL" - }, - "effects": { - "gold": 4, - "points": 5 - } + "effects": { + "gold": 4, + "points": 2 } - ], - "image": "ephesosB.png" - } + }, { + "requirements": { + "resources": "WW" + }, + "effects": { + "gold": 4, + "points": 3 + } + }, { + "requirements": { + "resources": "GPL" + }, + "effects": { + "gold": 4, + "points": 5 + } + } + ], + "image": "ephesosB.png" } - }, - { - "name": "Gizah", - "sides": { - "A": { - "initialResource": "S", - "stages": [ - { - "requirements": { - "resources": "SS" - }, - "effects": { - "points": 3 - } + } +}, { + "name": "Gizah", + "sides": { + "A": { + "initialResource": "S", + "stages": [ + { + "requirements": { + "resources": "SS" }, - { - "requirements": { - "resources": "WWW" - }, - "effects": { - "points": 5 - } + "effects": { + "points": 3 + } + }, { + "requirements": { + "resources": "WWW" }, - { - "requirements": { - "resources": "SSSS" - }, - "effects": { - "points": 7 - } + "effects": { + "points": 5 } - ], - "image": "gizahA.png" - }, - "B": { - "initialResource": "S", - "stages": [ - { - "requirements": { - "resources": "WW" - }, - "effects": { - "points": 3 - } + }, { + "requirements": { + "resources": "SSSS" }, - { - "requirements": { - "resources": "SSS" - }, - "effects": { - "points": 5 - } + "effects": { + "points": 7 + } + } + ], + "image": "gizahA.png" + }, + "B": { + "initialResource": "S", + "stages": [ + { + "requirements": { + "resources": "WW" }, - { - "requirements": { - "resources": "CCC" - }, - "effects": { - "points": 5 - } + "effects": { + "points": 3 + } + }, { + "requirements": { + "resources": "SSS" }, - { - "requirements": { - "resources": "SSSSP" - }, - "effects": { - "points": 7 - } + "effects": { + "points": 5 } - ], - "image": "gizahB.png" - } + }, { + "requirements": { + "resources": "CCC" + }, + "effects": { + "points": 5 + } + }, { + "requirements": { + "resources": "SSSSP" + }, + "effects": { + "points": 7 + } + } + ], + "image": "gizahB.png" } - }, - { - "name": "Halikarnassus", - "sides": { - "A": { - "initialResource": "L", - "stages": [ - { - "requirements": { - "resources": "CC" - }, - "effects": { - "points": 3 - } + } +}, { + "name": "Halikarnassus", + "sides": { + "A": { + "initialResource": "L", + "stages": [ + { + "requirements": { + "resources": "CC" }, - { - "requirements": { - "resources": "OOO" - }, - "effects": { - "action": "PLAY_DISCARDED" - } + "effects": { + "points": 3 + } + }, { + "requirements": { + "resources": "OOO" }, - { - "requirements": { - "resources": "LL" - }, - "effects": { - "points": 7 - } + "effects": { + "action": "PLAY_DISCARDED" } - ], - "image": "halikarnassusA.png" - }, - "B": { - "initialResource": "L", - "stages": [ - { - "requirements": { - "resources": "OO" - }, - "effects": { - "points": 2, - "action": "PLAY_DISCARDED" - } + }, { + "requirements": { + "resources": "LL" }, - { - "requirements": { - "resources": "CCC" - }, - "effects": { - "points": 1, - "action": "PLAY_DISCARDED" - } + "effects": { + "points": 7 + } + } + ], + "image": "halikarnassusA.png" + }, + "B": { + "initialResource": "L", + "stages": [ + { + "requirements": { + "resources": "OO" }, - { - "requirements": { - "resources": "GPL" - }, - "effects": { - "action": "PLAY_DISCARDED" - } + "effects": { + "points": 2, + "action": "PLAY_DISCARDED" } - ], - "image": "halikarnassusB.png" - } + }, { + "requirements": { + "resources": "CCC" + }, + "effects": { + "points": 1, + "action": "PLAY_DISCARDED" + } + }, { + "requirements": { + "resources": "GPL" + }, + "effects": { + "action": "PLAY_DISCARDED" + } + } + ], + "image": "halikarnassusB.png" } - }, - { - "name": "Olympia", - "sides": { - "A": { - "initialResource": "W", - "stages": [ - { - "requirements": { - "resources": "WW" - }, - "effects": { - "points": 3 - } + } +}, { + "name": "Olympia", + "sides": { + "A": { + "initialResource": "W", + "stages": [ + { + "requirements": { + "resources": "WW" }, - { - "requirements": { - "resources": "SS" - }, - "effects": { - "action": "ONE_FREE_PER_AGE" - } + "effects": { + "points": 3 + } + }, { + "requirements": { + "resources": "SS" }, - { - "requirements": { - "resources": "OO" - }, - "effects": { - "points": 7 - } + "effects": { + "action": "ONE_FREE_PER_AGE" } - ], - "image": "olympiaA.png" - }, - "B": { - "initialResource": "W", - "stages": [ - { - "requirements": { - "resources": "WW" - }, - "effects": { - "discount": { - "resourceTypes": "WSOC", - "providers": [ - "LEFT_PLAYER", - "RIGHT_PLAYER" - ], - "discountedPrice": 1 - } - } + }, { + "requirements": { + "resources": "OO" }, - { - "requirements": { - "resources": "SS" - }, - "effects": { - "points": 5 - } + "effects": { + "points": 7 + } + } + ], + "image": "olympiaA.png" + }, + "B": { + "initialResource": "W", + "stages": [ + { + "requirements": { + "resources": "WW" }, - { - "requirements": { - "resources": "OOL" - }, - "effects": { - "action": "COPY_GUILD" + "effects": { + "discount": { + "resourceTypes": "WSOC", + "providers": [ + "LEFT_PLAYER", "RIGHT_PLAYER" + ], + "discountedPrice": 1 } } - ], - "image": "olympiaB.png" - } + }, { + "requirements": { + "resources": "SS" + }, + "effects": { + "points": 5 + } + }, { + "requirements": { + "resources": "OOL" + }, + "effects": { + "action": "COPY_GUILD" + } + } + ], + "image": "olympiaB.png" } - }, - { - "name": "Rhodos", - "sides": { - "A": { - "initialResource": "O", - "stages": [ - { - "requirements": { - "resources": "WW" - }, - "effects": { - "points": 3 - } + } +}, { + "name": "Rhodos", + "sides": { + "A": { + "initialResource": "O", + "stages": [ + { + "requirements": { + "resources": "WW" }, - { - "requirements": { - "resources": "CCC" - }, - "effects": { - "military": 2 - } + "effects": { + "points": 3 + } + }, { + "requirements": { + "resources": "CCC" }, - { - "requirements": { - "resources": "OOOO" - }, - "effects": { - "points": 7 - } + "effects": { + "military": 2 } - ], - "image": "rhodosA.png" - }, - "B": { - "initialResource": "O", - "stages": [ - { - "requirements": { - "resources": "SSS" - }, - "effects": { - "gold": 3, - "military": 1, - "points": 3 - } + }, { + "requirements": { + "resources": "OOOO" }, - { - "requirements": { - "resources": "OOOO" - }, - "effects": { - "gold": 4, - "military": 1, - "points": 4 - } + "effects": { + "points": 7 } - ], - "image": "rhodosB.png" - } + } + ], + "image": "rhodosA.png" + }, + "B": { + "initialResource": "O", + "stages": [ + { + "requirements": { + "resources": "SSS" + }, + "effects": { + "gold": 3, + "military": 1, + "points": 3 + } + }, { + "requirements": { + "resources": "OOOO" + }, + "effects": { + "gold": 4, + "military": 1, + "points": 4 + } + } + ], + "image": "rhodosB.png" } } +} ] 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 9e8e3e52..783d3eab 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 @@ -107,7 +107,7 @@ class GameTest { return MoveExpectation( turn.playerIndex, PlayerMove(MoveType.PLAY_FREE_DISCARDED, card.name, noTransactions()), - PlayedMove(turn.playerIndex, MoveType.PLAY_FREE_DISCARDED, card.toPlayedCard(), noTransactions()) + PlayedMove(turn.playerIndex, MoveType.PLAY_FREE_DISCARDED, card.toPlayedCard(), noTransactions()), ) } @@ -115,11 +115,11 @@ class GameTest { turnInfo: PlayerTurnInfo, moveType: MoveType, card: HandCard, - transactions: ResourceTransactions + transactions: ResourceTransactions, ): MoveExpectation = MoveExpectation( turnInfo.playerIndex, PlayerMove(moveType, card.name, transactions), - PlayedMove(turnInfo.playerIndex, moveType, card.toPlayedCard(), transactions) + PlayedMove(turnInfo.playerIndex, moveType, card.toPlayedCard(), transactions), ) private fun createPickGuildMove(turnInfo: PlayerTurnInfo): MoveExpectation { @@ -131,7 +131,7 @@ class GameTest { return MoveExpectation( turnInfo.playerIndex, PlayerMove(MoveType.COPY_GUILD, card.name), - PlayedMove(turnInfo.playerIndex, MoveType.COPY_GUILD, card.toPlayedCard(), noTransactions()) + PlayedMove(turnInfo.playerIndex, MoveType.COPY_GUILD, card.toPlayedCard(), noTransactions()), ) } diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/boards/BoardTest.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/boards/BoardTest.kt index 165fbaa1..909d5e99 100644 --- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/boards/BoardTest.kt +++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/boards/BoardTest.kt @@ -50,7 +50,7 @@ class BoardTest { @Theory fun removeGold_successfulWhenNotTooMuch( @FromDataPoints("gold") initialGold: Int, - @FromDataPoints("gold") goldRemoved: Int + @FromDataPoints("gold") goldRemoved: Int, ) { assumeTrue(goldRemoved >= 0) assumeTrue(initialGold >= goldRemoved) @@ -63,7 +63,7 @@ class BoardTest { @Theory fun removeGold_failsWhenTooMuch( @FromDataPoints("gold") initialGold: Int, - @FromDataPoints("gold") goldRemoved: Int + @FromDataPoints("gold") goldRemoved: Int, ) { assumeTrue(goldRemoved >= 0) assumeTrue(initialGold < goldRemoved) @@ -79,7 +79,7 @@ class BoardTest { type: ResourceType, @FromDataPoints("nbCards") nbCards: Int, @FromDataPoints("nbCards") nbOtherCards: Int, - color: Color + color: Color, ) { val board = testBoard(initialResource = type) addCards(board, nbCards, nbOtherCards, color) @@ -93,7 +93,7 @@ class BoardTest { @FromDataPoints("nbCards") nbCards2: Int, @FromDataPoints("nbCards") nbOtherCards: Int, color1: Color, - color2: Color + color2: Color, ) { val board = testBoard(initialResource = type) addCards(board, nbCards1, color1) diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/boards/MilitaryTest.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/boards/MilitaryTest.kt index 509d8670..a7aff760 100644 --- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/boards/MilitaryTest.kt +++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/boards/MilitaryTest.kt @@ -15,7 +15,7 @@ class MilitaryTest { @Theory fun victory_addsCorrectPoints( @FromDataPoints("ages") age: Int, - @FromDataPoints("points") nbPointsPerVictory: Int + @FromDataPoints("points") nbPointsPerVictory: Int, ) { val military = createMilitary(age, nbPointsPerVictory, 0) val initialPoints = military.totalPoints diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/boards/ScienceTest.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/boards/ScienceTest.kt index e3f6f47d..90d9ece3 100644 --- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/boards/ScienceTest.kt +++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/boards/ScienceTest.kt @@ -104,7 +104,7 @@ class ScienceTest { intArrayOf(0, 0, 1, 3, 16), intArrayOf(0, 0, 2, 2, 16), intArrayOf(0, 0, 3, 1, 16), - intArrayOf(0, 0, 4, 0, 16) + intArrayOf(0, 0, 4, 0, 16), ) @JvmStatic 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 5f22acb3..414213c3 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 @@ -25,7 +25,7 @@ class CardTest { val boards = listOf( Board(Wonder("TestWonder", ResourceType.WOOD, emptyList(), ""), 0, settings), Board(Wonder("TestWonder", ResourceType.STONE, emptyList(), ""), 1, settings), - Board(Wonder("TestWonder", ResourceType.PAPYRUS, emptyList(), ""), 2, settings) + Board(Wonder("TestWonder", ResourceType.PAPYRUS, emptyList(), ""), 2, settings), ) val table = Table(boards) diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/cards/HandsTest.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/cards/HandsTest.kt index f7bb45c0..97920f3e 100644 --- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/cards/HandsTest.kt +++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/cards/HandsTest.kt @@ -38,7 +38,7 @@ class HandsTest { @Theory fun isEmpty_falseWhenAtLeast1_allSame( @FromDataPoints("nbPlayers") nbPlayers: Int, - @FromDataPoints("nbCardsPerPlayer") nbCardsPerPlayer: Int + @FromDataPoints("nbCardsPerPlayer") nbCardsPerPlayer: Int, ) { assumeTrue(nbCardsPerPlayer >= 1) val hands = createHands(nbPlayers, nbCardsPerPlayer) @@ -54,7 +54,7 @@ class HandsTest { @Theory fun maxOneCardRemains_falseWhenAtLeast2_allSame( @FromDataPoints("nbPlayers") nbPlayers: Int, - @FromDataPoints("nbCardsPerPlayer") nbCardsPerPlayer: Int + @FromDataPoints("nbCardsPerPlayer") nbCardsPerPlayer: Int, ) { assumeTrue(nbCardsPerPlayer >= 2) val hands = createHands(nbPlayers, nbCardsPerPlayer) @@ -64,7 +64,7 @@ class HandsTest { @Theory fun maxOneCardRemains_trueWhenAtMost1_allSame( @FromDataPoints("nbPlayers") nbPlayers: Int, - @FromDataPoints("nbCardsPerPlayer") nbCardsPerPlayer: Int + @FromDataPoints("nbCardsPerPlayer") nbCardsPerPlayer: Int, ) { assumeTrue(nbCardsPerPlayer <= 1) val hands = createHands(nbPlayers, nbCardsPerPlayer) 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 889675a4..d2ef7930 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 @@ -76,7 +76,7 @@ class RequirementsTest { fun resourceRequirement_ownProduction( initialResource: ResourceType, producedResource: ResourceType, - requiredResource: ResourceType + requiredResource: ResourceType, ) { assumeTrue(initialResource != requiredResource) @@ -98,7 +98,7 @@ class RequirementsTest { fun resourceRequirement_boughtResource( initialResource: ResourceType, boughtResource: ResourceType, - requiredResource: ResourceType + requiredResource: ResourceType, ) { assumeTrue(initialResource != requiredResource) @@ -119,7 +119,7 @@ class RequirementsTest { if (neighbourHasResource) { val transactions = setOf( createTransactions(Provider.LEFT_PLAYER, requiredResource), - createTransactions(Provider.RIGHT_PLAYER, requiredResource) + createTransactions(Provider.RIGHT_PLAYER, requiredResource), ) assertEquals(RequirementsSatisfaction.metWithHelp(2, transactions), satisfaction) } else { diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/converters/BoardsKtTest.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/converters/BoardsKtTest.kt index c1b17d4a..3706b533 100644 --- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/converters/BoardsKtTest.kt +++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/converters/BoardsKtTest.kt @@ -74,11 +74,7 @@ class BoardsKtTest { val green2 = testCard(color = Color.GREEN).toTableCard() val cards = listOf(res1, green1, green2, res2, blue1, res3) val cols = cards.toColumns() - val expectedCols = listOf( - listOf(res1, res2, res3), - listOf(blue1), - listOf(green1, green2) - ) + val expectedCols = listOf(listOf(res1, res2, res3), listOf(blue1), listOf(green1, green2)) assertEquals(expectedCols, cols) } } diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/data/serializers/NumericEffectSerializerTest.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/data/serializers/NumericEffectSerializerTest.kt index 6a399977..520db340 100644 --- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/data/serializers/NumericEffectSerializerTest.kt +++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/data/serializers/NumericEffectSerializerTest.kt @@ -28,7 +28,8 @@ class NumericEffectSerializerTest { .registerTypeAdapter(RawPointsIncrease::class.java, NumericEffectSerializer()) .registerTypeAdapter(GoldIncrease::class.java, NumericEffectSerializer()) // ProductionIncrease is not a numeric effect, it is here for negative testing purpose - .registerTypeAdapter(ProductionIncrease::class.java, NumericEffectSerializer()).create() + .registerTypeAdapter(ProductionIncrease::class.java, NumericEffectSerializer()) + .create() } @Test diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/data/serializers/ProductionSerializerTest.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/data/serializers/ProductionSerializerTest.kt index 4a58e493..314bc43c 100644 --- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/data/serializers/ProductionSerializerTest.kt +++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/data/serializers/ProductionSerializerTest.kt @@ -25,7 +25,8 @@ class ProductionSerializerTest { .registerTypeAdapter(MutableResources::class.java, ResourcesSerializer()) .registerTypeAdapter(ResourceType::class.java, ResourceTypeSerializer()) .registerTypeAdapter(resourceTypeList, ResourceTypesSerializer()) - .registerTypeAdapter(Production::class.java, ProductionSerializer()).create() + .registerTypeAdapter(Production::class.java, ProductionSerializer()) + .create() } private fun create(wood: Int, stone: Int, clay: Int): Production { diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/data/serializers/ResourcesSerializerTest.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/data/serializers/ResourcesSerializerTest.kt index 8a7e4f98..bc5808a0 100644 --- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/data/serializers/ResourcesSerializerTest.kt +++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/data/serializers/ResourcesSerializerTest.kt @@ -21,7 +21,7 @@ class ResourcesSerializerTest { @Before fun setUp() { - gson = GsonBuilder() + gson = GsonBuilder() // .registerTypeAdapter(Resources::class.java, ResourcesSerializer()) .registerTypeAdapter(MutableResources::class.java, ResourcesSerializer()) .create() diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/BonusPerBoardElementTest.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/BonusPerBoardElementTest.kt index 1bb92f13..a40f9420 100644 --- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/BonusPerBoardElementTest.kt +++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/BonusPerBoardElementTest.kt @@ -34,7 +34,7 @@ class BonusPerBoardElementTest { nbOtherCards: Int, points: Int, gold: Int, - color: Color + color: Color, ) { val board = table.getBoard(0, boardPosition) addCards(board, nbCards, nbOtherCards, color) @@ -49,7 +49,7 @@ class BonusPerBoardElementTest { boardPosition: RelativeBoardPosition, nbDefeatTokens: Int, points: Int, - gold: Int + gold: Int, ) { val board = table.getBoard(0, boardPosition) repeat(nbDefeatTokens) { @@ -81,7 +81,7 @@ class BonusPerBoardElementTest { nbOtherCards: Int, points: Int, gold: Int, - color: Color + color: Color, ) { val board = table.getBoard(0, boardPosition) addCards(board, nbCards, nbOtherCards, color) diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/DiscountTest.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/DiscountTest.kt index 7df5ac35..64d6546a 100644 --- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/DiscountTest.kt +++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/DiscountTest.kt @@ -30,7 +30,7 @@ class DiscountTest { discountedType: ResourceType, provider: Provider, otherType: ResourceType, - otherProvider: Provider + otherProvider: Provider, ) { Assume.assumeTrue(otherProvider != provider) Assume.assumeTrue(otherType != discountedType) diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/ProductionIncreaseTest.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/ProductionIncreaseTest.kt index 699803d0..88fb57ad 100644 --- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/ProductionIncreaseTest.kt +++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/ProductionIncreaseTest.kt @@ -21,7 +21,7 @@ class ProductionIncreaseTest { fun apply_boardContainsAddedResourceType( initialType: ResourceType, addedType: ResourceType, - extraType: ResourceType + extraType: ResourceType, ) { val board = testBoard(initialType) val effect = ProductionIncrease(fixedProduction(addedType), false) @@ -41,7 +41,7 @@ class ProductionIncreaseTest { fun apply_boardContainsAddedResourceType_sellable( initialType: ResourceType, addedType: ResourceType, - extraType: ResourceType + extraType: ResourceType, ) { val board = testBoard(initialType) val effect = ProductionIncrease(fixedProduction(addedType), true) diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/ScienceProgressTest.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/ScienceProgressTest.kt index 551018fc..7bf63988 100644 --- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/ScienceProgressTest.kt +++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/ScienceProgressTest.kt @@ -23,7 +23,7 @@ class ScienceProgressTest { compasses: Int, wheels: Int, tablets: Int, - jokers: Int + jokers: Int, ) { val board = testBoard(ResourceType.ORE) val initialScience = createScience(initCompasses, initWheels, initTablets, initJokers) diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/SpecialAbilityActivationTest.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/SpecialAbilityActivationTest.kt index 6931e38f..50be6c24 100644 --- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/SpecialAbilityActivationTest.kt +++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/SpecialAbilityActivationTest.kt @@ -77,15 +77,15 @@ class SpecialAbilityActivationTest { @DataPoints internal fun guilds(): Array<Card> { val bonus = BonusPerBoardElement( - listOf(RelativeBoardPosition.LEFT, RelativeBoardPosition.RIGHT), - BoardElementType.CARD, + boards = listOf(RelativeBoardPosition.LEFT, RelativeBoardPosition.RIGHT), + type = BoardElementType.CARD, points = 1, - colors = listOf(Color.GREY, Color.BROWN) + colors = listOf(Color.GREY, Color.BROWN), ) val bonus2 = BonusPerBoardElement( - listOf(RelativeBoardPosition.LEFT, RelativeBoardPosition.SELF, RelativeBoardPosition.RIGHT), - BoardElementType.BUILT_WONDER_STAGES, - points = 1 + boards = listOf(RelativeBoardPosition.LEFT, RelativeBoardPosition.SELF, RelativeBoardPosition.RIGHT), + type = BoardElementType.BUILT_WONDER_STAGES, + points = 1, ) return arrayOf(createGuildCard(1, bonus), createGuildCard(2, bonus2)) } diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/resources/ResourceTransactionsTest.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/resources/ResourceTransactionsTest.kt index 71c75d70..7b08be9a 100644 --- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/resources/ResourceTransactionsTest.kt +++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/resources/ResourceTransactionsTest.kt @@ -14,12 +14,12 @@ class ResourceTransactionsTest { fun toTransactions() { val transactionMap = mapOf( Provider.LEFT_PLAYER to (1 of WOOD) + (1 of CLAY), - Provider.RIGHT_PLAYER to (1 of WOOD) + Provider.RIGHT_PLAYER to (1 of WOOD), ) val expectedNormalized = setOf( createTransaction(Provider.LEFT_PLAYER, WOOD, CLAY), - createTransaction(Provider.RIGHT_PLAYER, WOOD) + createTransaction(Provider.RIGHT_PLAYER, WOOD), ) assertEquals(expectedNormalized, transactionMap.toTransactions().toSet()) diff --git a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/resources/TradingRulesTest.kt b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/resources/TradingRulesTest.kt index 0b2e5261..1ee329d3 100644 --- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/resources/TradingRulesTest.kt +++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/resources/TradingRulesTest.kt @@ -21,7 +21,7 @@ class TradingRulesTest { overriddenCost: Int, overriddenProvider: Provider, provider: Provider, - type: ResourceType + type: ResourceType, ) { assumeTrue(defaultCost != overriddenCost) assumeTrue(overriddenProvider != provider) @@ -68,7 +68,7 @@ class TradingRulesTest { overriddenProvider: Provider, overriddenType: ResourceType, provider: Provider, - type: ResourceType + type: ResourceType, ) { assumeTrue(overriddenProvider != provider || overriddenType != type) val rules = TradingRules(defaultCost) @@ -83,7 +83,7 @@ class TradingRulesTest { overriddenCost: Int, overriddenType: ResourceType, provider: Provider, - type: ResourceType + type: ResourceType, ) { assumeTrue(overriddenType != type) val rules = TradingRules(defaultCost) @@ -98,7 +98,7 @@ class TradingRulesTest { overriddenCost: Int, overriddenProvider: Provider, provider: Provider, - type: ResourceType + type: ResourceType, ) { assumeTrue(overriddenProvider != provider) val rules = TradingRules(defaultCost) @@ -106,7 +106,7 @@ class TradingRulesTest { val boughtResources = createTransactions( createTransaction(provider, type), - createTransaction(overriddenProvider, type) + createTransaction(overriddenProvider, type), ) assertEquals(defaultCost + overriddenCost, rules.computeCost(boughtResources)) 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 332718f9..a1b42b49 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 @@ -22,14 +22,17 @@ import org.luxons.sevenwonders.model.Settings import org.luxons.sevenwonders.model.boards.RelativeBoardPosition import org.luxons.sevenwonders.model.cards.CardBack import org.luxons.sevenwonders.model.cards.Color -import org.luxons.sevenwonders.model.resources.* +import org.luxons.sevenwonders.model.resources.CountedResource +import org.luxons.sevenwonders.model.resources.Provider +import org.luxons.sevenwonders.model.resources.ResourceTransaction +import org.luxons.sevenwonders.model.resources.ResourceTransactions +import org.luxons.sevenwonders.model.resources.ResourceType +import org.luxons.sevenwonders.model.resources.noTransactions internal const val SEED: Long = 42 -internal fun testSettings(initialGold: Int = 0): Settings = Settings( - randomSeedForTests = SEED, - initialGold = initialGold -) +internal fun testSettings(initialGold: Int = 0): Settings = + Settings(randomSeedForTests = SEED, initialGold = initialGold) internal fun testTable(nbPlayers: Int = 5): Table = testTable(nbPlayers, testSettings()) @@ -40,7 +43,7 @@ private fun testBoards(count: Int, settings: Settings): List<Board> = List(count internal fun testBoard( initialResource: ResourceType = ResourceType.WOOD, initialGold: Int = 0, - vararg production: ResourceType + vararg production: ResourceType, ): Board { val settings = testSettings(initialGold = initialGold) val board = testBoard(settings, initialResource) @@ -69,7 +72,8 @@ internal fun createTransactions(vararg transactions: ResourceTransaction): Resou internal fun createTransaction(provider: Provider, vararg resources: ResourceType): ResourceTransaction = ResourceTransaction(provider, resources.map { CountedResource(1, it) }) -internal fun createRequirements(vararg types: ResourceType): Requirements = Requirements(resources = resourcesOf(*types)) +internal fun createRequirements(vararg types: ResourceType): Requirements = + Requirements(resources = resourcesOf(*types)) internal fun sampleCards(nbCards: Int, fromIndex: Int = 0, color: Color = Color.BLUE): List<Card> = List(nbCards) { i -> testCard("Test Card ${fromIndex + i}", color) } @@ -83,7 +87,7 @@ internal fun testCard( name: String = "Test Card", color: Color = Color.BLUE, requirements: Requirements = Requirements(), - effect: Effect? = null + effect: Effect? = null, ): Card { val effects = if (effect == null) emptyList() else listOf(effect) return Card(name, color, requirements, effects, null, emptyList(), "path/to/card/image", CardBack("image-III")) |