diff options
author | Joffrey Bion <joffrey.bion@booking.com> | 2020-08-20 15:36:49 +0200 |
---|---|---|
committer | Joffrey Bion <joffrey.bion@booking.com> | 2020-08-20 15:44:47 +0200 |
commit | 53cdfdfd3d7f4a8fed08ee475b2d5936155f6875 (patch) | |
tree | 51410abd200b107b06c3ff144c77ba5a687a4480 /sw-engine/src/main/kotlin | |
parent | Upgrade to Spring Boot 2.3.3 (diff) | |
download | seven-wonders-53cdfdfd3d7f4a8fed08ee475b2d5936155f6875.tar.gz seven-wonders-53cdfdfd3d7f4a8fed08ee475b2d5936155f6875.tar.bz2 seven-wonders-53cdfdfd3d7f4a8fed08ee475b2d5936155f6875.zip |
Fix style & sort imports
Diffstat (limited to 'sw-engine/src/main/kotlin')
15 files changed, 29 insertions, 56 deletions
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 1c5ca8dc..e010c6aa 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 @@ -13,24 +13,16 @@ internal data class RequirementsSatisfaction( companion object { internal fun noRequirements() = - RequirementsSatisfaction(true, PlayabilityLevel.NO_REQUIREMENTS, 0, setOf( - noTransactions() - )) + RequirementsSatisfaction(true, PlayabilityLevel.NO_REQUIREMENTS, 0, setOf(noTransactions())) internal fun enoughResources() = - RequirementsSatisfaction(true, PlayabilityLevel.ENOUGH_RESOURCES, 0, setOf( - noTransactions() - )) + RequirementsSatisfaction(true, PlayabilityLevel.ENOUGH_RESOURCES, 0, setOf(noTransactions())) internal fun enoughGold(minPrice: Int) = - RequirementsSatisfaction(true, PlayabilityLevel.ENOUGH_GOLD, minPrice, setOf( - noTransactions() - )) + RequirementsSatisfaction(true, PlayabilityLevel.ENOUGH_GOLD, minPrice, setOf(noTransactions())) internal fun enoughResourcesAndGold(minPrice: Int) = - RequirementsSatisfaction(true, PlayabilityLevel.ENOUGH_GOLD_AND_RES, minPrice, setOf( - noTransactions() - )) + RequirementsSatisfaction(true, PlayabilityLevel.ENOUGH_GOLD_AND_RES, minPrice, setOf(noTransactions())) internal fun metWithHelp(minPrice: Int, cheapestTransactions: Set<ResourceTransactions>) = RequirementsSatisfaction(true, PlayabilityLevel.REQUIRES_HELP, minPrice, cheapestTransactions) 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 ba07ce3a..df321952 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 @@ -10,6 +10,8 @@ import org.luxons.sevenwonders.model.MoveType import org.luxons.sevenwonders.model.cards.Color import org.luxons.sevenwonders.model.cards.TableCard import org.luxons.sevenwonders.model.resources.CountedResource +import org.luxons.sevenwonders.model.wonders.ApiWonder +import org.luxons.sevenwonders.model.wonders.ApiWonderStage import org.luxons.sevenwonders.engine.boards.Board as InternalBoard import org.luxons.sevenwonders.engine.boards.Military as InternalMilitary import org.luxons.sevenwonders.engine.boards.Science as InternalScience @@ -22,8 +24,6 @@ import org.luxons.sevenwonders.model.boards.Military as ApiMilitary 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 -import org.luxons.sevenwonders.model.wonders.ApiWonder as ApiWonder -import org.luxons.sevenwonders.model.wonders.ApiWonderStage as ApiWonderStage internal fun InternalBoard.toApiBoard(player: Player, lastMove: Move?, currentAge: Age): ApiBoard = ApiBoard( @@ -83,9 +83,9 @@ internal fun InternalRequirements.toApiRequirements(): ApiRequirements = ) internal fun Resources.toCountedResourcesList(): List<CountedResource> = - quantities.filterValues { it > 0 } - .map { (type, count) -> CountedResource(count, type) } - .sortedBy { it.type } + quantities.filterValues { it > 0 } + .map { (type, count) -> CountedResource(count, type) } + .sortedBy { it.type } internal fun InternalMilitary.toApiMilitary(): ApiMilitary = ApiMilitary(nbShields, victoryPoints, totalPoints, nbDefeatTokens) 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 ccb73cc1..60ee5b21 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 @@ -1,9 +1,9 @@ package org.luxons.sevenwonders.engine.converters import org.luxons.sevenwonders.engine.SimplePlayer +import org.luxons.sevenwonders.engine.boards.Table import org.luxons.sevenwonders.engine.moves.Move import org.luxons.sevenwonders.model.PlayedMove -import org.luxons.sevenwonders.engine.boards.Table import org.luxons.sevenwonders.model.TableState internal fun Table.toTableState(): TableState = TableState( 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 b33c9d50..4228f6af 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,25 +7,15 @@ 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.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.data.serializers.* +import org.luxons.sevenwonders.engine.effects.* import org.luxons.sevenwonders.engine.resources.Production import org.luxons.sevenwonders.engine.resources.Resources import org.luxons.sevenwonders.model.Age -import org.luxons.sevenwonders.model.wonders.AssignedWonder import org.luxons.sevenwonders.model.Settings -import org.luxons.sevenwonders.model.wonders.PreGameWonder import org.luxons.sevenwonders.model.resources.ResourceType +import org.luxons.sevenwonders.model.wonders.AssignedWonder +import org.luxons.sevenwonders.model.wonders.PreGameWonder internal const val LAST_AGE: Age = 3 @@ -43,9 +33,7 @@ class GameDefinition internal constructor( val maxPlayers: Int = rules.maxPlayers val allWonders: List<PreGameWonder> = wonderDefinitions.map { w -> - PreGameWonder( - w.name, - w.sides.mapValues { (_, def) -> def.image }) + PreGameWonder(w.name, w.sides.mapValues { (_, def) -> def.image }) } private val wondersByName = wonderDefinitions.associateBy { it.name } 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 58964e83..e7f1e0fc 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 @@ -3,9 +3,9 @@ package org.luxons.sevenwonders.engine.data.definitions import org.luxons.sevenwonders.engine.cards.Requirements import org.luxons.sevenwonders.engine.wonders.Wonder import org.luxons.sevenwonders.engine.wonders.WonderStage +import org.luxons.sevenwonders.model.resources.ResourceType import org.luxons.sevenwonders.model.wonders.WonderName import org.luxons.sevenwonders.model.wonders.WonderSide -import org.luxons.sevenwonders.model.resources.ResourceType internal class WonderDefinition( val name: WonderName, 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 bad74e54..1d9f8349 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,13 +1,6 @@ package org.luxons.sevenwonders.engine.data.serializers -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 com.google.gson.* import org.luxons.sevenwonders.engine.boards.Science import org.luxons.sevenwonders.engine.boards.ScienceType import org.luxons.sevenwonders.engine.effects.ScienceProgress @@ -50,6 +43,6 @@ internal class ScienceProgressSerializer : JsonSerializer<ScienceProgress>, Json private fun deserializeScienceType(json: JsonElement, context: JsonDeserializationContext): ScienceType { return context.deserialize<ScienceType>(json, ScienceType::class.java) - ?: throw IllegalArgumentException("Invalid science level " + json.asString) + ?: throw IllegalArgumentException("Invalid science level " + json.asString) } } 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 046a7135..95eaae99 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 @@ -28,8 +28,8 @@ internal data class BonusPerBoardElement( .sumBy { nbMatchingElementsIn(it) } private fun nbMatchingElementsIn(board: Board): Int = when (type) { - BoardElementType.CARD -> board.getNbCardsOfColor(colors!!) - BoardElementType.BUILT_WONDER_STAGES -> board.wonder.nbBuiltStages - BoardElementType.DEFEAT_TOKEN -> board.military.nbDefeatTokens + BoardElementType.CARD -> board.getNbCardsOfColor(colors!!) + BoardElementType.BUILT_WONDER_STAGES -> board.wonder.nbBuiltStages + BoardElementType.DEFEAT_TOKEN -> board.military.nbDefeatTokens } } diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/SpecialAbility.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/SpecialAbility.kt index 9d1287f9..dfc69a41 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/SpecialAbility.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/SpecialAbility.kt @@ -28,7 +28,7 @@ enum class SpecialAbility { COPY_GUILD { override fun computePoints(player: Player): Int { val copiedGuild = player.board.copiedGuild - ?: throw IllegalStateException("The copied Guild has not been chosen, cannot compute points") + ?: throw IllegalStateException("The copied Guild has not been chosen, cannot compute points") return copiedGuild.effects.sumBy { it.computePoints(player) } } }; diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/BuildWonderMove.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/BuildWonderMove.kt index aaa26f7e..ff970c92 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/BuildWonderMove.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/BuildWonderMove.kt @@ -2,8 +2,8 @@ package org.luxons.sevenwonders.engine.moves import org.luxons.sevenwonders.engine.PlayerContext import org.luxons.sevenwonders.engine.cards.Card -import org.luxons.sevenwonders.model.Settings import org.luxons.sevenwonders.model.PlayerMove +import org.luxons.sevenwonders.model.Settings internal class BuildWonderMove(move: PlayerMove, card: Card, player: PlayerContext) : CardFromHandMove(move, card, player) { diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/CopyGuildMove.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/CopyGuildMove.kt index c3ba8e9a..c2da63dd 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/CopyGuildMove.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/CopyGuildMove.kt @@ -3,8 +3,8 @@ package org.luxons.sevenwonders.engine.moves import org.luxons.sevenwonders.engine.PlayerContext import org.luxons.sevenwonders.engine.cards.Card import org.luxons.sevenwonders.engine.effects.SpecialAbility -import org.luxons.sevenwonders.model.Settings import org.luxons.sevenwonders.model.PlayerMove +import org.luxons.sevenwonders.model.Settings import org.luxons.sevenwonders.model.boards.RelativeBoardPosition import org.luxons.sevenwonders.model.cards.Color 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 92fb4952..6637cc6c 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 @@ -2,8 +2,8 @@ package org.luxons.sevenwonders.engine.moves import org.luxons.sevenwonders.engine.PlayerContext import org.luxons.sevenwonders.engine.cards.Card -import org.luxons.sevenwonders.model.Settings 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) { 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 a1790baa..2841d0c0 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 @@ -2,9 +2,9 @@ package org.luxons.sevenwonders.engine.moves import org.luxons.sevenwonders.engine.PlayerContext import org.luxons.sevenwonders.engine.cards.Card -import org.luxons.sevenwonders.model.Settings import org.luxons.sevenwonders.model.MoveType import org.luxons.sevenwonders.model.PlayerMove +import org.luxons.sevenwonders.model.Settings import org.luxons.sevenwonders.model.resources.ResourceTransactions internal abstract class Move( diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/PlayCardMove.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/PlayCardMove.kt index 250424c7..01078919 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/PlayCardMove.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/PlayCardMove.kt @@ -2,8 +2,8 @@ package org.luxons.sevenwonders.engine.moves import org.luxons.sevenwonders.engine.PlayerContext import org.luxons.sevenwonders.engine.cards.Card -import org.luxons.sevenwonders.model.Settings import org.luxons.sevenwonders.model.PlayerMove +import org.luxons.sevenwonders.model.Settings internal class PlayCardMove(move: PlayerMove, card: Card, player: PlayerContext) : CardFromHandMove(move, card, player) { diff --git a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/PlayFreeCardMove.kt b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/PlayFreeCardMove.kt index acaa2c95..71c0824b 100644 --- a/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/PlayFreeCardMove.kt +++ b/sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/PlayFreeCardMove.kt @@ -2,8 +2,8 @@ package org.luxons.sevenwonders.engine.moves import org.luxons.sevenwonders.engine.PlayerContext import org.luxons.sevenwonders.engine.cards.Card -import org.luxons.sevenwonders.model.Settings import org.luxons.sevenwonders.model.PlayerMove +import org.luxons.sevenwonders.model.Settings internal class PlayFreeCardMove(move: PlayerMove, card: Card, playerContext: PlayerContext) : CardFromHandMove(move, card, playerContext) { 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 2fc03c92..9a15349d 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 @@ -3,8 +3,8 @@ package org.luxons.sevenwonders.engine.moves import org.luxons.sevenwonders.engine.PlayerContext import org.luxons.sevenwonders.engine.cards.Card import org.luxons.sevenwonders.engine.effects.SpecialAbility -import org.luxons.sevenwonders.model.Settings import org.luxons.sevenwonders.model.PlayerMove +import org.luxons.sevenwonders.model.Settings internal class PlayFreeDiscardedCardMove( move: PlayerMove, |