summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw-client/src/commonMain/kotlin/org/luxons/sevenwonders/client/SevenWondersClient.kt10
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/Moves.kt5
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/actions/Actions.kt4
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/RequirementsSatisfaction.kt16
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Boards.kt10
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Table.kt2
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/GameDefinition.kt22
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/definitions/WonderDefinition.kt2
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/serializers/ScienceProgressSerializer.kt11
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/BonusPerBoardElement.kt6
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/SpecialAbility.kt2
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/BuildWonderMove.kt2
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/CopyGuildMove.kt2
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/DiscardMove.kt2
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/Move.kt2
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/PlayCardMove.kt2
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/PlayFreeCardMove.kt2
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/PlayFreeDiscardedCardMove.kt2
-rw-r--r--sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/cards/RequirementsTest.kt12
-rw-r--r--sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/converters/BoardsKtTest.kt6
-rw-r--r--sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/test/TestUtils.kt26
-rw-r--r--sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameController.kt4
-rw-r--r--sw-server/src/main/kotlin/org/luxons/sevenwonders/server/lobby/Lobby.kt4
-rw-r--r--sw-server/src/test/kotlin/org/luxons/sevenwonders/server/test/TestUtils.kt10
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameScene.kt32
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Hand.kt12
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/ApiActions.kt2
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Reducers.kt10
28 files changed, 92 insertions, 130 deletions
diff --git a/sw-client/src/commonMain/kotlin/org/luxons/sevenwonders/client/SevenWondersClient.kt b/sw-client/src/commonMain/kotlin/org/luxons/sevenwonders/client/SevenWondersClient.kt
index 3267773f..f438e236 100644
--- a/sw-client/src/commonMain/kotlin/org/luxons/sevenwonders/client/SevenWondersClient.kt
+++ b/sw-client/src/commonMain/kotlin/org/luxons/sevenwonders/client/SevenWondersClient.kt
@@ -15,16 +15,16 @@ import org.hildan.krossbow.stomp.conversions.kxserialization.convertAndSend
import org.hildan.krossbow.stomp.conversions.kxserialization.subscribe
import org.hildan.krossbow.stomp.conversions.kxserialization.withJsonConversions
import org.hildan.krossbow.stomp.sendEmptyMsg
-import org.luxons.sevenwonders.model.Settings
import org.luxons.sevenwonders.model.PlayerMove
import org.luxons.sevenwonders.model.PlayerTurnInfo
-import org.luxons.sevenwonders.model.wonders.AssignedWonder
+import org.luxons.sevenwonders.model.Settings
import org.luxons.sevenwonders.model.api.ConnectedPlayer
import org.luxons.sevenwonders.model.api.LobbyDTO
import org.luxons.sevenwonders.model.api.SEVEN_WONDERS_WS_ENDPOINT
import org.luxons.sevenwonders.model.api.actions.*
import org.luxons.sevenwonders.model.api.errors.ErrorDTO
import org.luxons.sevenwonders.model.cards.PreparedCard
+import org.luxons.sevenwonders.model.wonders.AssignedWonder
class SevenWondersClient {
@@ -122,13 +122,13 @@ class SevenWondersSession(private val stompSession: StompSessionWithKxSerializat
}
fun watchPlayerReady(gameId: Long): Flow<String> =
- stompSession.subscribe("/topic/game/$gameId/playerReady", String.serializer())
+ stompSession.subscribe("/topic/game/$gameId/playerReady", String.serializer())
fun watchPreparedCards(gameId: Long): Flow<PreparedCard> =
- stompSession.subscribe("/topic/game/$gameId/prepared", PreparedCard.serializer())
+ stompSession.subscribe("/topic/game/$gameId/prepared", PreparedCard.serializer())
fun watchTurns(): Flow<PlayerTurnInfo> =
- stompSession.subscribe("/user/queue/game/turn", PlayerTurnInfo.serializer())
+ stompSession.subscribe("/user/queue/game/turn", PlayerTurnInfo.serializer())
suspend fun sayReady() {
stompSession.sendEmptyMsg("/app/game/sayReady")
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/Moves.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/Moves.kt
index 54142ad2..bea94b64 100644
--- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/Moves.kt
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/Moves.kt
@@ -15,8 +15,7 @@ enum class Action(val message: String) {
PLAY("Pick the card you want to play or discard."),
PLAY_2("Pick the first card you want to play or discard. Note that you have the ability to play these 2 last cards. You will choose how to play the last one during your next turn."),
PLAY_LAST("You have the special ability to play your last card. Choose how you want to play it."),
- PLAY_FREE_DISCARDED("Pick a card from the discarded deck, you can play it for free (but you cannot discard for 3 " +
- "gold coins or upgrade your wonder with it."),
+ PLAY_FREE_DISCARDED("Pick a card from the discarded deck, you can play it for free (but you cannot discard for 3 gold coins or upgrade your wonder with it)."),
PICK_NEIGHBOR_GUILD("Choose a Guild card (purple) that you want to copy from one of your neighbours."),
WAIT("Please wait for other players to perform extra actions."),
WATCH_SCORE("The game is over! Look at the scoreboard to see the final ranking!");
@@ -55,7 +54,7 @@ fun PlayerTurnInfo.getBoard(position: RelativeBoardPosition): Board =
// TODO move to server code
fun Collection<PlayerTurnInfo>.hideHandsAndWaitForReadiness() =
- map { it.copy(action = Action.SAY_READY, hand = null) }
+ map { it.copy(action = Action.SAY_READY, hand = null) }
@Serializable
data class PlayedMove(
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/actions/Actions.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/actions/Actions.kt
index 4a721a94..67c64e32 100644
--- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/actions/Actions.kt
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/actions/Actions.kt
@@ -1,9 +1,9 @@
package org.luxons.sevenwonders.model.api.actions
import kotlinx.serialization.Serializable
-import org.luxons.sevenwonders.model.wonders.AssignedWonder
-import org.luxons.sevenwonders.model.Settings
import org.luxons.sevenwonders.model.PlayerMove
+import org.luxons.sevenwonders.model.Settings
+import org.luxons.sevenwonders.model.wonders.AssignedWonder
/**
* The action to choose the player's name. This is the first action that should be called.
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,
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 da0ae124..27b3cad0 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
@@ -43,9 +43,7 @@ class RequirementsTest {
val board = testBoard(ResourceType.CLAY, boardGold)
val player = singleBoardPlayer(board)
- assertEquals(boardGold >= requiredGold, requirements.areMetWithHelpBy(board,
- noTransactions()
- ))
+ assertEquals(boardGold >= requiredGold, requirements.areMetWithHelpBy(board, noTransactions()))
val satisfaction = requirements.assess(player)
if (boardGold >= requiredGold) {
@@ -66,9 +64,7 @@ class RequirementsTest {
val board = testBoard(initialResource, 0)
val player = singleBoardPlayer(board)
- assertEquals(initialResource == requiredResource, requirements.areMetWithHelpBy(board,
- noTransactions()
- ))
+ assertEquals(initialResource == requiredResource, requirements.areMetWithHelpBy(board, noTransactions()))
if (initialResource == requiredResource) {
val satisfaction = requirements.assess(player)
@@ -90,9 +86,7 @@ class RequirementsTest {
board.production.addFixedResource(producedResource, 1)
val player = singleBoardPlayer(board)
- assertEquals(producedResource == requiredResource, requirements.areMetWithHelpBy(board,
- noTransactions()
- ))
+ assertEquals(producedResource == requiredResource, requirements.areMetWithHelpBy(board, noTransactions()))
if (producedResource == requiredResource) {
val satisfaction = requirements.assess(player)
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 96c5e500..c1b17d4a 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
@@ -75,9 +75,9 @@ class BoardsKtTest {
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)
+ listOf(res1, res2, res3),
+ listOf(blue1),
+ listOf(green1, green2)
)
assertEquals(expectedCols, cols)
}
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 4db574e2..332718f9 100644
--- a/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/test/TestUtils.kt
+++ b/sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/test/TestUtils.kt
@@ -2,32 +2,27 @@ package org.luxons.sevenwonders.engine.test
import org.luxons.sevenwonders.engine.Player
import org.luxons.sevenwonders.engine.PlayerContext
-import org.luxons.sevenwonders.model.resources.CountedResource
-import org.luxons.sevenwonders.model.Settings
-import org.luxons.sevenwonders.model.PlayerMove
import org.luxons.sevenwonders.engine.boards.Board
-import org.luxons.sevenwonders.model.boards.RelativeBoardPosition
import org.luxons.sevenwonders.engine.boards.Science
import org.luxons.sevenwonders.engine.boards.ScienceType
import org.luxons.sevenwonders.engine.boards.Table
import org.luxons.sevenwonders.engine.cards.Card
-import org.luxons.sevenwonders.model.cards.CardBack
-import org.luxons.sevenwonders.model.cards.Color
import org.luxons.sevenwonders.engine.cards.Requirements
import org.luxons.sevenwonders.engine.effects.Effect
import org.luxons.sevenwonders.engine.effects.ScienceProgress
import org.luxons.sevenwonders.engine.moves.Move
-import org.luxons.sevenwonders.model.MoveType
import org.luxons.sevenwonders.engine.moves.resolve
import org.luxons.sevenwonders.engine.resources.Production
-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
import org.luxons.sevenwonders.engine.resources.resourcesOf
import org.luxons.sevenwonders.engine.wonders.Wonder
import org.luxons.sevenwonders.engine.wonders.WonderStage
+import org.luxons.sevenwonders.model.MoveType
+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.CardBack
+import org.luxons.sevenwonders.model.cards.Color
+import org.luxons.sevenwonders.model.resources.*
internal const val SEED: Long = 42
@@ -72,8 +67,7 @@ internal fun createTransactions(provider: Provider, vararg resources: ResourceTy
internal fun createTransactions(vararg transactions: ResourceTransaction): ResourceTransactions = transactions.toSet()
internal fun createTransaction(provider: Provider, vararg resources: ResourceType): ResourceTransaction =
- ResourceTransaction(provider,
- resources.map { CountedResource(1, it) })
+ ResourceTransaction(provider, resources.map { CountedResource(1, it) })
internal fun createRequirements(vararg types: ResourceType): Requirements = Requirements(resources = resourcesOf(*types))
@@ -92,9 +86,7 @@ internal fun testCard(
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")
- )
+ return Card(name, color, requirements, effects, null, emptyList(), "path/to/card/image", CardBack("image-III"))
}
internal fun addCards(board: Board, nbCardsOfColor: Int, nbOtherCards: Int, color: Color) {
diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameController.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameController.kt
index 40a9407d..c15f7a68 100644
--- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameController.kt
+++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameController.kt
@@ -93,10 +93,10 @@ class GameController(
}
private fun sendPlayerReady(gameId: Long, player: Player) =
- template.convertAndSend("/topic/game/$gameId/playerReady", "\"${player.username}\"")
+ template.convertAndSend("/topic/game/$gameId/playerReady", "\"${player.username}\"")
private fun sendPreparedCard(gameId: Long, preparedCard: PreparedCard) =
- template.convertAndSend("/topic/game/$gameId/prepared", preparedCard)
+ template.convertAndSend("/topic/game/$gameId/prepared", preparedCard)
private fun sendTurnInfo(players: List<Player>, game: Game, hideHands: Boolean) {
val turns = game.getCurrentTurnInfo()
diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/lobby/Lobby.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/lobby/Lobby.kt
index 2962e5df..ed8add56 100644
--- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/lobby/Lobby.kt
+++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/lobby/Lobby.kt
@@ -2,10 +2,10 @@ package org.luxons.sevenwonders.server.lobby
import org.luxons.sevenwonders.engine.Game
import org.luxons.sevenwonders.engine.data.GameDefinition
-import org.luxons.sevenwonders.model.wonders.AssignedWonder
-import org.luxons.sevenwonders.model.wonders.PreGameWonder
import org.luxons.sevenwonders.model.Settings
import org.luxons.sevenwonders.model.api.State
+import org.luxons.sevenwonders.model.wonders.AssignedWonder
+import org.luxons.sevenwonders.model.wonders.PreGameWonder
import org.luxons.sevenwonders.model.wonders.withRandomSide
class Lobby(
diff --git a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/test/TestUtils.kt b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/test/TestUtils.kt
index e4921ab4..194fb8f1 100644
--- a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/test/TestUtils.kt
+++ b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/test/TestUtils.kt
@@ -8,10 +8,12 @@ import org.springframework.messaging.MessageChannel
import org.springframework.messaging.simp.SimpMessagingTemplate
import kotlin.test.assertNotNull
-fun mockSimpMessagingTemplate(): SimpMessagingTemplate = SimpMessagingTemplate(object : MessageChannel {
- override fun send(message: Message<*>): Boolean = true
- override fun send(message: Message<*>, timeout: Long): Boolean = true
-})
+fun mockSimpMessagingTemplate(): SimpMessagingTemplate = SimpMessagingTemplate(
+ object : MessageChannel {
+ override fun send(message: Message<*>): Boolean = true
+ override fun send(message: Message<*>, timeout: Long): Boolean = true
+ }
+)
fun runAsyncTest(timeoutMillis: Long = 10000, block: suspend CoroutineScope.() -> Unit) = runBlocking {
val result = withTimeoutOrNull(timeoutMillis, block)
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameScene.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameScene.kt
index 778fe9d7..3545113b 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameScene.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameScene.kt
@@ -214,19 +214,19 @@ private class GameScene(props: GameSceneProps) : RComponent<GameSceneProps, RSta
fun RBuilder.gameScene() = gameScene {}
private val gameScene: RClass<GameSceneProps> =
- connectStateAndDispatch<GameSceneStateProps, GameSceneDispatchProps, GameSceneProps>(
- clazz = GameScene::class,
- mapDispatchToProps = { dispatch, _ ->
- prepareMove = { move -> dispatch(RequestPrepareMove(move)) }
- unprepareMove = { dispatch(RequestUnprepareMove()) }
- sayReady = { dispatch(RequestSayReady()) }
- leaveGame = { dispatch(RequestLeaveGame()) }
- },
- mapStateToProps = { state, _ ->
- playerIsReady = state.currentPlayer?.isReady == true
- players = state.gameState?.players ?: emptyList()
- gameState = state.gameState
- preparedMove = state.gameState?.currentPreparedMove
- preparedCard = state.gameState?.currentPreparedCard
- }
- )
+ connectStateAndDispatch<GameSceneStateProps, GameSceneDispatchProps, GameSceneProps>(
+ clazz = GameScene::class,
+ mapDispatchToProps = { dispatch, _ ->
+ prepareMove = { move -> dispatch(RequestPrepareMove(move)) }
+ unprepareMove = { dispatch(RequestUnprepareMove()) }
+ sayReady = { dispatch(RequestSayReady()) }
+ leaveGame = { dispatch(RequestLeaveGame()) }
+ },
+ mapStateToProps = { state, _ ->
+ playerIsReady = state.currentPlayer?.isReady == true
+ players = state.gameState?.players ?: emptyList()
+ gameState = state.gameState
+ preparedMove = state.gameState?.currentPreparedMove
+ preparedCard = state.gameState?.currentPreparedCard
+ }
+ )
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Hand.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Hand.kt
index 17365bdd..315e25e8 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Hand.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Hand.kt
@@ -112,14 +112,16 @@ class HandComponent(props: HandProps) : RComponent<HandProps, RState>(props) {
}
private fun RElementBuilder<IButtonGroupProps>.playCardButton(card: HandCard, handAction: HandAction) {
- bpButton(title = "${handAction.buttonTitle} (${cardPlayabilityInfo(card.playability)})",
+ bpButton(
+ title = "${handAction.buttonTitle} (${cardPlayabilityInfo(card.playability)})",
large = true,
intent = Intent.SUCCESS,
disabled = !card.playability.isPlayable,
onClick = {
val transactions = card.playability.cheapestTransactions.first()
props.prepareMove(PlayerMove(handAction.moveType, card.name, transactions))
- }) {
+ }
+ ) {
bpIcon(handAction.icon)
if (card.playability.isPlayable && !card.playability.isFree) {
priceInfo(card.playability.minPrice)
@@ -129,14 +131,16 @@ class HandComponent(props: HandProps) : RComponent<HandProps, RState>(props) {
private fun RElementBuilder<IButtonGroupProps>.upgradeWonderButton(card: HandCard) {
val wonderBuildability = props.turnInfo.wonderBuildability
- bpButton(title = "UPGRADE WONDER (${wonderBuildabilityInfo(wonderBuildability)})",
+ bpButton(
+ title = "UPGRADE WONDER (${wonderBuildabilityInfo(wonderBuildability)})",
large = true,
intent = Intent.PRIMARY,
disabled = !wonderBuildability.isBuildable,
onClick = {
val transactions = wonderBuildability.cheapestTransactions.first()
props.prepareMove(PlayerMove(MoveType.UPGRADE_WONDER, card.name, transactions))
- }) {
+ }
+ ) {
bpIcon("key-shift")
if (wonderBuildability.isBuildable && !wonderBuildability.isFree) {
priceInfo(wonderBuildability.minPrice)
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/ApiActions.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/ApiActions.kt
index 53cdeaf4..d259da81 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/ApiActions.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/ApiActions.kt
@@ -1,7 +1,7 @@
package org.luxons.sevenwonders.ui.redux
-import org.luxons.sevenwonders.model.Settings
import org.luxons.sevenwonders.model.PlayerMove
+import org.luxons.sevenwonders.model.Settings
import org.luxons.sevenwonders.model.wonders.AssignedWonder
import redux.RAction
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Reducers.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Reducers.kt
index 047e948a..7eca24b8 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Reducers.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Reducers.kt
@@ -55,9 +55,7 @@ private fun currentLobbyReducer(currentLobby: LobbyDTO?, action: RAction): Lobby
is EnterLobbyAction -> action.lobby
is UpdateLobbyAction -> action.lobby
is PlayerReadyEvent -> currentLobby?.let { l ->
- l.copy(players = l.players.map { p ->
- if (p.username == action.username) p.copy(isReady = true) else p
- })
+ l.copy(players = l.players.map { p -> if (p.username == action.username) p.copy(isReady = true) else p })
}
else -> currentLobby
}
@@ -73,9 +71,9 @@ private fun gameStateReducer(gameState: GameState?, action: RAction): GameState?
is PreparedCardEvent -> gameState?.copy(
preparedCardsByUsername = gameState.preparedCardsByUsername + (action.card.username to action.card.cardBack)
)
- is PlayerReadyEvent -> gameState?.copy(players = gameState.players.map { p ->
- if (p.username == action.username) p.copy(isReady = true) else p
- })
+ is PlayerReadyEvent -> gameState?.copy(
+ players = gameState.players.map { p -> if (p.username == action.username) p.copy(isReady = true) else p }
+ )
is TurnInfoEvent -> gameState?.copy(
players = gameState.players.map { p -> p.copy(isReady = false) },
turnInfo = action.turnInfo,
bgstack15