summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey Bion <joffrey.bion@booking.com>2020-09-07 23:36:44 +0200
committerJoffrey Bion <joffrey.bion@booking.com>2020-09-08 00:39:01 +0200
commit9cb098df0ad5978b0e9aac78b4c68c9d16759f0f (patch)
treeb7c4829c163a004a012a3da13183753fe4ee32e6
parentUse port 80 in docker image (diff)
downloadseven-wonders-9cb098df0ad5978b0e9aac78b4c68c9d16759f0f.tar.gz
seven-wonders-9cb098df0ad5978b0e9aac78b4c68c9d16759f0f.tar.bz2
seven-wonders-9cb098df0ad5978b0e9aac78b4c68c9d16759f0f.zip
Format with trailing comma
-rw-r--r--sw-bot/src/main/kotlin/org/luxons/sevenwonders/bot/SevenWondersBot.kt4
-rw-r--r--sw-client/src/commonMain/kotlin/org/luxons/sevenwonders/client/SevenWondersClient.kt49
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/Moves.kt11
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/Settings.kt2
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/TableState.kt2
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Lobby.kt12
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Player.kt4
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/actions/Actions.kt18
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/errors/Errors.kt8
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/boards/Boards.kt10
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/boards/RelativeBoardPosition.kt5
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/cards/Cards.kt10
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/resources/Resources.kt2
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/score/Score.kt2
-rw-r--r--sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/wonders/Wonders.kt10
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Game.kt11
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/Player.kt4
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/boards/Board.kt15
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/boards/Military.kt2
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/boards/Table.kt4
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/Cards.kt52
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/Decks.kt6
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/Requirements.kt2
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/cards/RequirementsSatisfaction.kt2
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Boards.kt67
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Cards.kt42
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/converters/Table.kt8
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/GameDefinition.kt18
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/definitions/CardDefinition.kt2
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/definitions/DecksDefinition.kt8
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/definitions/EffectsDefinition.kt2
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/definitions/WonderDefinition.kt6
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/serializers/ProductionIncreaseSerializer.kt6
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/data/serializers/ResourceTypesSerializer.kt4
-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.kt8
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/effects/Discount.kt2
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/DiscardMove.kt3
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/Move.kt7
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/moves/PlayFreeDiscardedCardMove.kt2
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/resources/BestPriceCalculator.kt2
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/resources/Production.kt4
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/resources/ResourceTransactions.kt6
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/resources/Resources.kt2
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/wonders/Wonder.kt17
-rw-r--r--sw-engine/src/main/kotlin/org/luxons/sevenwonders/engine/wonders/WonderStage.kt2
-rw-r--r--sw-engine/src/main/resources/org/luxons/sevenwonders/engine/data/wonders.json707
-rw-r--r--sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/GameTest.kt8
-rw-r--r--sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/boards/BoardTest.kt8
-rw-r--r--sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/boards/MilitaryTest.kt2
-rw-r--r--sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/boards/ScienceTest.kt2
-rw-r--r--sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/cards/CardTest.kt2
-rw-r--r--sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/cards/HandsTest.kt6
-rw-r--r--sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/cards/RequirementsTest.kt6
-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/data/serializers/NumericEffectSerializerTest.kt3
-rw-r--r--sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/data/serializers/ProductionSerializerTest.kt3
-rw-r--r--sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/data/serializers/ResourcesSerializerTest.kt2
-rw-r--r--sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/BonusPerBoardElementTest.kt6
-rw-r--r--sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/DiscountTest.kt2
-rw-r--r--sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/ProductionIncreaseTest.kt4
-rw-r--r--sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/ScienceProgressTest.kt2
-rw-r--r--sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/effects/SpecialAbilityActivationTest.kt12
-rw-r--r--sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/resources/ResourceTransactionsTest.kt4
-rw-r--r--sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/resources/TradingRulesTest.kt10
-rw-r--r--sw-engine/src/test/kotlin/org/luxons/sevenwonders/engine/test/TestUtils.kt20
-rw-r--r--sw-server/src/main/kotlin/org/luxons/sevenwonders/server/Converters.kt7
-rw-r--r--sw-server/src/main/kotlin/org/luxons/sevenwonders/server/api/Converters.kt5
-rw-r--r--sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/AnonymousUsersHandshakeHandler.kt2
-rw-r--r--sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/TopicSubscriptionInterceptor.kt2
-rw-r--r--sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/WebSocketConfig.kt2
-rw-r--r--sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameBrowserController.kt2
-rw-r--r--sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameController.kt2
-rw-r--r--sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/HomeController.kt2
-rw-r--r--sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt3
-rw-r--r--sw-server/src/main/kotlin/org/luxons/sevenwonders/server/lobby/Lobby.kt14
-rw-r--r--sw-server/src/main/kotlin/org/luxons/sevenwonders/server/lobby/Player.kt2
-rw-r--r--sw-server/src/main/kotlin/org/luxons/sevenwonders/server/repositories/PlayerRepository.kt3
-rw-r--r--sw-server/src/test/kotlin/org/luxons/sevenwonders/server/controllers/LobbyControllerTest.kt6
-rw-r--r--sw-server/src/test/kotlin/org/luxons/sevenwonders/server/lobby/LobbyTest.kt7
-rw-r--r--sw-server/src/test/kotlin/org/luxons/sevenwonders/server/repositories/LobbyRepositoryTest.kt6
-rw-r--r--sw-server/src/test/kotlin/org/luxons/sevenwonders/server/repositories/PlayerRepositoryTest.kt6
-rw-r--r--sw-server/src/test/kotlin/org/luxons/sevenwonders/server/test/TestUtils.kt2
-rw-r--r--sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpButtons.kt16
-rw-r--r--sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpCallout.kt1
-rw-r--r--sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpCard.kt1
-rw-r--r--sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpDivider.kt1
-rw-r--r--sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpHtmlTable.kt1
-rw-r--r--sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpIcon.kt5
-rw-r--r--sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpInputs.kt10
-rw-r--r--sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpNonIdealState.kt1
-rw-r--r--sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpOverlay.kt21
-rw-r--r--sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpPopover.kt1
-rw-r--r--sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpTag.kt11
-rw-r--r--sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjs.kt10
-rw-r--r--sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjsHelpers.kt26
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Board.kt4
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/BoardSummary.kt40
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/CardImage.kt6
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameScene.kt40
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Hand.kt34
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/PreparedMove.kt4
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/ScoreTable.kt15
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Tokens.kt20
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/CreateGameForm.kt9
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/GameList.kt10
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/PlayerInfo.kt4
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/home/ChooseNameForm.kt12
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/Lobby.kt18
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/RadialList.kt10
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/RadialMath.kt8
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/RadialPlayerList.kt23
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Reducers.kt16
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Store.kt2
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Utils.kt8
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/GameBrowserSagas.kt2
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/GameSagas.kt9
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/LobbySagas.kt14
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/SagasFramework.kt6
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/router/Router.kt2
-rw-r--r--sw-ui/src/main/resources/index.html6
-rw-r--r--sw-ui/src/test/kotlin/org/luxons/sevenwonders/ui/redux/sagas/SagasFrameworkTest.kt2
-rw-r--r--sw-ui/src/test/kotlin/org/luxons/sevenwonders/ui/utils/CoroutineUtilsTest.kt4
123 files changed, 983 insertions, 814 deletions
diff --git a/sw-bot/src/main/kotlin/org/luxons/sevenwonders/bot/SevenWondersBot.kt b/sw-bot/src/main/kotlin/org/luxons/sevenwonders/bot/SevenWondersBot.kt
index c03ee201..8ceae2c2 100644
--- a/sw-bot/src/main/kotlin/org/luxons/sevenwonders/bot/SevenWondersBot.kt
+++ b/sw-bot/src/main/kotlin/org/luxons/sevenwonders/bot/SevenWondersBot.kt
@@ -24,13 +24,13 @@ import kotlin.time.hours
data class BotConfig(
val minActionDelayMillis: Long = 500,
val maxActionDelayMillis: Long = 1000,
- val globalTimeout: Duration = 10.hours
+ val globalTimeout: Duration = 10.hours,
)
@OptIn(ExperimentalTime::class, ExperimentalCoroutinesApi::class)
class SevenWondersBot(
private val displayName: String,
- private val botConfig: BotConfig = BotConfig()
+ private val botConfig: BotConfig = BotConfig(),
) {
private val client = SevenWondersClient()
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 86831b13..05c6bf94 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
@@ -1,6 +1,10 @@
package org.luxons.sevenwonders.client
-import kotlinx.coroutines.*
+import kotlinx.coroutines.CoroutineStart
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.async
+import kotlinx.coroutines.coroutineScope
+import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
import kotlinx.serialization.DeserializationStrategy
@@ -22,7 +26,15 @@ 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.actions.AddBotAction
+import org.luxons.sevenwonders.model.api.actions.ChooseNameAction
+import org.luxons.sevenwonders.model.api.actions.CreateGameAction
+import org.luxons.sevenwonders.model.api.actions.Icon
+import org.luxons.sevenwonders.model.api.actions.JoinGameAction
+import org.luxons.sevenwonders.model.api.actions.PrepareMoveAction
+import org.luxons.sevenwonders.model.api.actions.ReassignWondersAction
+import org.luxons.sevenwonders.model.api.actions.ReorderPlayersAction
+import org.luxons.sevenwonders.model.api.actions.UpdateSettingsAction
import org.luxons.sevenwonders.model.api.errors.ErrorDTO
import org.luxons.sevenwonders.model.cards.PreparedCard
import org.luxons.sevenwonders.model.wonders.AssignedWonder
@@ -48,7 +60,7 @@ private suspend inline fun <reified T : Any, reified U : Any> StompSessionWithKx
receiveDestination: String,
payload: T? = null,
serializer: SerializationStrategy<T>,
- deserializer: DeserializationStrategy<U>
+ deserializer: DeserializationStrategy<U>,
): U = coroutineScope {
val sub = async(start = CoroutineStart.UNDISPATCHED) {
subscribe(receiveDestination, deserializer).first()
@@ -69,7 +81,7 @@ class SevenWondersSession(private val stompSession: StompSessionWithKxSerializat
receiveDestination = "/user/queue/nameChoice",
payload = ChooseNameAction(displayName, icon),
serializer = ChooseNameAction.serializer(),
- deserializer = ConnectedPlayer.serializer()
+ deserializer = ConnectedPlayer.serializer(),
)
fun watchGames(): Flow<List<LobbyDTO>> =
@@ -80,7 +92,7 @@ class SevenWondersSession(private val stompSession: StompSessionWithKxSerializat
receiveDestination = "/user/queue/lobby/joined",
payload = CreateGameAction(gameName),
serializer = CreateGameAction.serializer(),
- deserializer = LobbyDTO.serializer()
+ deserializer = LobbyDTO.serializer(),
)
suspend fun joinGame(gameId: Long): LobbyDTO = stompSession.request(
@@ -88,7 +100,7 @@ class SevenWondersSession(private val stompSession: StompSessionWithKxSerializat
receiveDestination = "/user/queue/lobby/joined",
payload = JoinGameAction(gameId),
serializer = JoinGameAction.serializer(),
- deserializer = LobbyDTO.serializer()
+ deserializer = LobbyDTO.serializer(),
)
suspend fun leaveLobby() {
@@ -100,19 +112,30 @@ class SevenWondersSession(private val stompSession: StompSessionWithKxSerializat
}
suspend fun reorderPlayers(players: List<String>) {
- stompSession.convertAndSend("/app/lobby/reorderPlayers", ReorderPlayersAction(players), ReorderPlayersAction.serializer())
+ stompSession.convertAndSend(
+ destination = "/app/lobby/reorderPlayers",
+ body = ReorderPlayersAction(players),
+ serializer = ReorderPlayersAction.serializer(),
+ )
}
suspend fun reassignWonders(wonders: List<AssignedWonder>) {
- stompSession.convertAndSend("/app/lobby/reassignWonders", ReassignWondersAction(wonders), ReassignWondersAction.serializer())
+ stompSession.convertAndSend(
+ destination = "/app/lobby/reassignWonders",
+ body = ReassignWondersAction(wonders),
+ serializer = ReassignWondersAction.serializer(),
+ )
}
suspend fun updateSettings(settings: Settings) {
- stompSession.convertAndSend("/app/lobby/updateSettings", UpdateSettingsAction(settings), UpdateSettingsAction.serializer())
+ stompSession.convertAndSend(
+ destination = "/app/lobby/updateSettings",
+ body = UpdateSettingsAction(settings),
+ serializer = UpdateSettingsAction.serializer(),
+ )
}
- fun watchLobbyUpdates(): Flow<LobbyDTO> =
- stompSession.subscribe("/user/queue/lobby/updated", LobbyDTO.serializer())
+ fun watchLobbyUpdates(): Flow<LobbyDTO> = stompSession.subscribe("/user/queue/lobby/updated", LobbyDTO.serializer())
suspend fun awaitGameStart(gameId: Long): PlayerTurnInfo {
val startEvents = stompSession.subscribe("/user/queue/lobby/$gameId/started", PlayerTurnInfo.serializer())
@@ -137,13 +160,13 @@ class SevenWondersSession(private val stompSession: StompSessionWithKxSerializat
}
fun watchOwnMoves(): Flow<PlayerMove> =
- stompSession.subscribe(destination = "/user/queue/game/preparedMove", deserializer = PlayerMove.serializer())
+ stompSession.subscribe("/user/queue/game/preparedMove", PlayerMove.serializer())
suspend fun prepareMove(move: PlayerMove) {
stompSession.convertAndSend(
destination = "/app/game/prepareMove",
body = PrepareMoveAction(move),
- serializer = PrepareMoveAction.serializer()
+ serializer = PrepareMoveAction.serializer(),
)
}
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 bea94b64..bee7fb15 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
@@ -40,7 +40,7 @@ data class PlayerTurnInfo(
val preparedMove: PlayedMove?,
val neighbourGuildCards: List<HandCard>,
val discardedCards: List<HandCard>?, // only present when the player can actually see them
- val scoreBoard: ScoreBoard? = null
+ val scoreBoard: ScoreBoard? = null,
) {
val currentAge: Int = table.currentAge
val message: String = action.message
@@ -53,22 +53,21 @@ fun PlayerTurnInfo.getBoard(position: RelativeBoardPosition): Board =
table.boards[position.getIndexFrom(playerIndex, table.boards.size)]
// TODO move to server code
-fun Collection<PlayerTurnInfo>.hideHandsAndWaitForReadiness() =
- map { it.copy(action = Action.SAY_READY, hand = null) }
+fun Collection<PlayerTurnInfo>.hideHandsAndWaitForReadiness() = map { it.copy(action = Action.SAY_READY, hand = null) }
@Serializable
data class PlayedMove(
val playerIndex: Int,
val type: MoveType,
val card: TableCard,
- val transactions: ResourceTransactions
+ val transactions: ResourceTransactions,
)
@Serializable
data class PlayerMove(
val type: MoveType,
val cardName: String,
- val transactions: ResourceTransactions = noTransactions()
+ val transactions: ResourceTransactions = noTransactions(),
)
enum class MoveType {
@@ -77,5 +76,5 @@ enum class MoveType {
PLAY_FREE_DISCARDED,
UPGRADE_WONDER,
DISCARD,
- COPY_GUILD;
+ COPY_GUILD,
}
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/Settings.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/Settings.kt
index 21be1c1b..a6c949ea 100644
--- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/Settings.kt
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/Settings.kt
@@ -12,7 +12,7 @@ data class Settings(
val defaultTradingCost: Int = 2,
val pointsPer3Gold: Int = 1,
val lostPointsPerDefeat: Int = 1,
- val wonPointsPerVictoryPerAge: Map<Int, Int> = mapOf(1 to 1, 2 to 3, 3 to 5)
+ val wonPointsPerVictoryPerAge: Map<Int, Int> = mapOf(1 to 1, 2 to 3, 3 to 5),
) {
val random: Random by lazy { randomSeedForTests?.let { Random(it) } ?: Random }
}
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/TableState.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/TableState.kt
index 1f1ed3ee..d27fccb5 100644
--- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/TableState.kt
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/TableState.kt
@@ -11,7 +11,7 @@ data class TableState(
val boards: List<Board>,
val currentAge: Age,
val handRotationDirection: HandRotationDirection,
- val lastPlayedMoves: List<PlayedMove>
+ val lastPlayedMoves: List<PlayedMove>,
) {
val nbPlayers: Int = boards.size
}
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Lobby.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Lobby.kt
index 324482bb..e1e978f7 100644
--- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Lobby.kt
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Lobby.kt
@@ -6,7 +6,9 @@ import org.luxons.sevenwonders.model.wonders.PreGameWonder
const val SEVEN_WONDERS_WS_ENDPOINT = "/seven-wonders-websocket"
enum class State {
- LOBBY, PLAYING, FINISHED
+ LOBBY,
+ PLAYING,
+ FINISHED,
}
@Serializable
@@ -18,7 +20,7 @@ data class LobbyDTO(
val allWonders: List<PreGameWonder>,
val state: State,
val hasEnoughPlayers: Boolean,
- val maxPlayersReached: Boolean
+ val maxPlayersReached: Boolean,
) {
private val wondersByName = allWonders.associateBy { it.name }
@@ -28,8 +30,8 @@ data class LobbyDTO(
state != State.LOBBY -> Actionability(false, "Cannot join: the game has already started")
maxPlayersReached -> Actionability(false, "Cannot join: the game is full")
playerNameAlreadyUsed(userDisplayName) -> Actionability(
- false,
- "Cannot join: already a player named '$userDisplayName' in this game"
+ canDo = false,
+ tooltip = "Cannot join: already a player named '$userDisplayName' in this game",
)
else -> Actionability(true, "Join game")
}
@@ -46,5 +48,5 @@ data class LobbyDTO(
@Serializable
data class Actionability(
val canDo: Boolean,
- val tooltip: String
+ val tooltip: String,
)
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Player.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Player.kt
index 7161b53d..db4365f5 100644
--- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Player.kt
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/Player.kt
@@ -14,7 +14,7 @@ interface BasicPlayerInfo {
data class ConnectedPlayer(
override val username: String,
override val displayName: String,
- override val icon: Icon?
+ override val icon: Icon?,
) : BasicPlayerInfo
@Serializable
@@ -24,5 +24,5 @@ data class PlayerDTO(
override val icon: Icon?,
val wonder: AssignedWonder,
val isGameOwner: Boolean,
- val isReady: Boolean
+ val isReady: Boolean,
) : BasicPlayerInfo
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 67c64e32..ee5caef8 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
@@ -17,12 +17,12 @@ class ChooseNameAction(
/**
* The player's icon.
*/
- val icon: Icon?
+ val icon: Icon?,
)
@Serializable
data class Icon(
- val name: String
+ val name: String,
)
/**
@@ -33,7 +33,7 @@ class CreateGameAction(
/**
* The name of the game to create.
*/
- val gameName: String
+ val gameName: String,
)
/**
@@ -44,7 +44,7 @@ class JoinGameAction(
/**
* The ID of the game to join.
*/
- val gameId: Long
+ val gameId: Long,
)
/**
@@ -55,7 +55,7 @@ class PrepareMoveAction(
/**
* The move to prepare.
*/
- val move: PlayerMove
+ val move: PlayerMove,
)
/**
@@ -67,7 +67,7 @@ class ReorderPlayersAction(
/**
* The list of usernames of the players, in the new order.
*/
- val orderedPlayers: List<String>
+ val orderedPlayers: List<String>,
)
/**
@@ -79,7 +79,7 @@ class ReassignWondersAction(
/**
* The list of wonders assigned to each player, in the players' order.
*/
- val assignedWonders: List<AssignedWonder>
+ val assignedWonders: List<AssignedWonder>,
)
/**
@@ -90,7 +90,7 @@ class UpdateSettingsAction(
/**
* The new values for the settings.
*/
- val settings: Settings
+ val settings: Settings,
)
/**
@@ -101,5 +101,5 @@ class AddBotAction(
/**
* The display name for the bot to add.
*/
- val botDisplayName: String
+ val botDisplayName: String,
)
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/errors/Errors.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/errors/Errors.kt
index dea6ce5b..61dba320 100644
--- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/errors/Errors.kt
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/api/errors/Errors.kt
@@ -3,7 +3,9 @@ package org.luxons.sevenwonders.model.api.errors
import kotlinx.serialization.Serializable
enum class ErrorType {
- VALIDATION, CLIENT, SERVER
+ VALIDATION,
+ CLIENT,
+ SERVER,
}
@Serializable
@@ -11,12 +13,12 @@ data class ErrorDTO(
val code: String,
val message: String,
val type: ErrorType,
- val details: List<ValidationErrorDTO> = emptyList()
+ val details: List<ValidationErrorDTO> = emptyList(),
)
@Serializable
data class ValidationErrorDTO(
val path: String,
val message: String,
- val rejectedValue: String? = null
+ val rejectedValue: String? = null,
)
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/boards/Boards.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/boards/Boards.kt
index e080b929..1899c408 100644
--- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/boards/Boards.kt
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/boards/Boards.kt
@@ -17,19 +17,19 @@ data class Board(
val playedCards: List<List<TableCard>>,
val gold: Int,
val bluePoints: Int,
- val canPlayAnyCardForFree: Boolean
+ val canPlayAnyCardForFree: Boolean,
)
@Serializable
data class Requirements(
val gold: Int = 0,
- val resources: List<CountedResource> = emptyList()
+ val resources: List<CountedResource> = emptyList(),
)
@Serializable
data class Production(
val fixedResources: List<CountedResource>,
- val alternativeResources: List<Set<ResourceType>>
+ val alternativeResources: List<Set<ResourceType>>,
)
@Serializable
@@ -37,7 +37,7 @@ data class Military(
val nbShields: Int,
val victoryPoints: Int,
val totalPoints: Int,
- val nbDefeatTokens: Int
+ val nbDefeatTokens: Int,
)
@Serializable
@@ -45,5 +45,5 @@ data class Science(
val jokers: Int,
val nbWheels: Int,
val nbCompasses: Int,
- val nbTablets: Int
+ val nbTablets: Int,
)
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/boards/RelativeBoardPosition.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/boards/RelativeBoardPosition.kt
index f2450c5d..202dd0f8 100644
--- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/boards/RelativeBoardPosition.kt
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/boards/RelativeBoardPosition.kt
@@ -8,10 +8,7 @@ enum class RelativeBoardPosition(private val offset: Int) {
fun getIndexFrom(playerIndex: Int, nbPlayers: Int): Int = (playerIndex + offset) floorMod nbPlayers
}
-fun neighboursPositions() = listOf(
- RelativeBoardPosition.LEFT,
- RelativeBoardPosition.RIGHT
-)
+fun neighboursPositions() = listOf(RelativeBoardPosition.LEFT, RelativeBoardPosition.RIGHT)
private infix fun Int.floorMod(divisor: Int): Int {
val rem = this % divisor
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/cards/Cards.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/cards/Cards.kt
index f26baf0e..238e2612 100644
--- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/cards/Cards.kt
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/cards/Cards.kt
@@ -24,7 +24,7 @@ data class TableCard(
override val chainChildren: List<String>,
override val image: String,
override val back: CardBack,
- val playedDuringLastMove: Boolean
+ val playedDuringLastMove: Boolean,
) : Card
/**
@@ -40,13 +40,13 @@ data class HandCard(
override val chainChildren: List<String>,
override val image: String,
override val back: CardBack,
- val playability: CardPlayability
+ val playability: CardPlayability,
) : Card
@Serializable
data class PreparedCard(
val username: String,
- val cardBack: CardBack?
+ val cardBack: CardBack?,
)
@Serializable
@@ -82,7 +82,7 @@ data class CardPlayability(
val isChainable: Boolean = false,
val minPrice: Int = Int.MAX_VALUE,
val cheapestTransactions: Set<ResourceTransactions> = setOf(noTransactions()),
- val playabilityLevel: PlayabilityLevel
+ val playabilityLevel: PlayabilityLevel,
) {
val isFree: Boolean = minPrice == 0
@@ -92,7 +92,7 @@ data class CardPlayability(
isChainable = false,
minPrice = 0,
cheapestTransactions = setOf(noTransactions()),
- playabilityLevel = PlayabilityLevel.SPECIAL_FREE
+ playabilityLevel = PlayabilityLevel.SPECIAL_FREE,
)
}
}
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/resources/Resources.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/resources/Resources.kt
index 4985c008..0ebb837d 100644
--- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/resources/Resources.kt
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/resources/Resources.kt
@@ -31,7 +31,7 @@ enum class ResourceType(val symbol: Char) {
@Serializable
data class CountedResource(
val count: Int,
- val type: ResourceType
+ val type: ResourceType,
)
@Serializable
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/score/Score.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/score/Score.kt
index 1896ecd3..c1f5e4d3 100644
--- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/score/Score.kt
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/score/Score.kt
@@ -9,7 +9,7 @@ class ScoreBoard(val scores: Collection<PlayerScore>)
data class PlayerScore(
val playerIndex: Int,
val boardGold: Int,
- val pointsByCategory: Map<ScoreCategory, Int>
+ val pointsByCategory: Map<ScoreCategory, Int>,
) : Comparable<PlayerScore> {
val totalPoints = pointsByCategory.values.sum()
diff --git a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/wonders/Wonders.kt b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/wonders/Wonders.kt
index fcecd010..a99f4f58 100644
--- a/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/wonders/Wonders.kt
+++ b/sw-common-model/src/commonMain/kotlin/org/luxons/sevenwonders/model/wonders/Wonders.kt
@@ -13,14 +13,14 @@ typealias WonderName = String
@Serializable
data class PreGameWonder(
val name: WonderName,
- val images: Map<WonderSide, String>
+ val images: Map<WonderSide, String>,
)
@Serializable
data class AssignedWonder(
val name: WonderName,
val side: WonderSide,
- val image: String
+ val image: String,
)
@Serializable
@@ -43,7 +43,7 @@ data class ApiWonder(
val stages: List<ApiWonderStage>,
val image: String,
val nbBuiltStages: Int,
- val buildability: WonderBuildability
+ val buildability: WonderBuildability,
)
@Serializable
@@ -51,7 +51,7 @@ data class ApiWonderStage(
val cardBack: CardBack?,
val isBuilt: Boolean,
val requirements: Requirements,
- val builtDuringLastMove: Boolean
+ val builtDuringLastMove: Boolean,
)
@Serializable
@@ -59,7 +59,7 @@ data class WonderBuildability(
val isBuildable: Boolean,
val minPrice: Int,
val cheapestTransactions: Set<ResourceTransactions>,
- val playabilityLevel: PlayabilityLevel
+ val playabilityLevel: PlayabilityLevel,
) {
val isFree: Boolean = minPrice == 0
}
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"))
diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/Converters.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/Converters.kt
index 3958260c..aef121ee 100644
--- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/Converters.kt
+++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/Converters.kt
@@ -6,8 +6,11 @@ import org.springframework.validation.ObjectError
fun ObjectError.toDTO() = (this as? FieldError)?.fieldError() ?: objectError()
-fun FieldError.fieldError(): ValidationErrorDTO =
- ValidationErrorDTO("$objectName.$field", "Invalid value for field '$field': $defaultMessage", rejectedValue?.toString())
+fun FieldError.fieldError(): ValidationErrorDTO = ValidationErrorDTO(
+ path = "$objectName.$field",
+ message = "Invalid value for field '$field': $defaultMessage",
+ rejectedValue = rejectedValue?.toString(),
+)
fun ObjectError.objectError(): ValidationErrorDTO =
ValidationErrorDTO(objectName, "Invalid value for object '$objectName': $defaultMessage")
diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/api/Converters.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/api/Converters.kt
index 61bcad89..12f346a2 100644
--- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/api/Converters.kt
+++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/api/Converters.kt
@@ -14,8 +14,7 @@ fun Lobby.toDTO(): LobbyDTO = LobbyDTO(
allWonders = allWonders,
state = state,
hasEnoughPlayers = hasEnoughPlayers(),
- maxPlayersReached = maxPlayersReached()
+ maxPlayersReached = maxPlayersReached(),
)
-private fun Player.toDTO(wonder: AssignedWonder) =
- PlayerDTO(username, displayName, icon, wonder, isGameOwner, isReady)
+private fun Player.toDTO(wonder: AssignedWonder) = PlayerDTO(username, displayName, icon, wonder, isGameOwner, isReady)
diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/AnonymousUsersHandshakeHandler.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/AnonymousUsersHandshakeHandler.kt
index 56b3400f..06b46d17 100644
--- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/AnonymousUsersHandshakeHandler.kt
+++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/AnonymousUsersHandshakeHandler.kt
@@ -16,7 +16,7 @@ internal class AnonymousUsersHandshakeHandler : DefaultHandshakeHandler() {
override fun determineUser(
request: ServerHttpRequest,
wsHandler: WebSocketHandler,
- attributes: Map<String, Any>
+ attributes: Map<String, Any>,
): Principal? {
var p = super.determineUser(request, wsHandler, attributes)
if (p == null) {
diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/TopicSubscriptionInterceptor.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/TopicSubscriptionInterceptor.kt
index d8181f8a..d32fa0a6 100644
--- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/TopicSubscriptionInterceptor.kt
+++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/TopicSubscriptionInterceptor.kt
@@ -11,7 +11,7 @@ import org.springframework.stereotype.Component
@Component
class TopicSubscriptionInterceptor(
- private val destinationAccessValidator: DestinationAccessValidator
+ private val destinationAccessValidator: DestinationAccessValidator,
) : ChannelInterceptor {
override fun preSend(message: Message<*>, channel: MessageChannel): Message<*>? {
diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/WebSocketConfig.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/WebSocketConfig.kt
index 1911f5b9..aad1c2ce 100644
--- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/WebSocketConfig.kt
+++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/config/WebSocketConfig.kt
@@ -14,7 +14,7 @@ import org.springframework.web.socket.server.support.DefaultHandshakeHandler
@Configuration
@EnableWebSocketMessageBroker
class WebSocketConfig(
- private val topicSubscriptionInterceptor: TopicSubscriptionInterceptor
+ private val topicSubscriptionInterceptor: TopicSubscriptionInterceptor,
) : WebSocketMessageBrokerConfigurer {
override fun configureMessageBroker(config: MessageBrokerRegistry) {
diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameBrowserController.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameBrowserController.kt
index c3dcf87c..3236a6c9 100644
--- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameBrowserController.kt
+++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameBrowserController.kt
@@ -27,7 +27,7 @@ class GameBrowserController(
private val lobbyController: LobbyController,
private val lobbyRepository: LobbyRepository,
private val playerRepository: PlayerRepository,
- private val template: SimpMessagingTemplate
+ private val template: SimpMessagingTemplate,
) {
/**
* Gets the created or updated games. The list of existing games is received on this topic at once upon
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 c15f7a68..f3d8aaef 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
@@ -20,7 +20,7 @@ import java.security.Principal
@Controller
class GameController(
private val template: SimpMessagingTemplate,
- private val playerRepository: PlayerRepository
+ private val playerRepository: PlayerRepository,
) {
private val Principal.player
get() = playerRepository.find(name)
diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/HomeController.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/HomeController.kt
index 4a9fe0a2..c34756a8 100644
--- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/HomeController.kt
+++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/HomeController.kt
@@ -18,7 +18,7 @@ import java.security.Principal
@Api(name = "Home")
@Controller
class HomeController(
- private val playerRepository: PlayerRepository
+ private val playerRepository: PlayerRepository,
) {
/**
diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt
index 1c8cf17e..64e75a8f 100644
--- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt
+++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt
@@ -31,8 +31,7 @@ class LobbyController(
private val lobbyRepository: LobbyRepository,
private val playerRepository: PlayerRepository,
private val template: SimpMessagingTemplate,
- @Value("\${server.port}")
- private val serverPort: String
+ @Value("\${server.port}") private val serverPort: String,
) {
private val Principal.player: Player
get() = playerRepository.find(name)
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 ed8add56..6ebe39c1 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
@@ -12,7 +12,7 @@ class Lobby(
val id: Long,
val name: String,
var owner: Player,
- private val gameDefinition: GameDefinition
+ private val gameDefinition: GameDefinition,
) {
private val players: MutableList<Player> = ArrayList(gameDefinition.maxPlayers)
@@ -49,8 +49,7 @@ class Lobby(
assignedWonders.add(pickRandomWonder())
}
- private fun pickRandomWonder(): AssignedWonder =
- allWonders.filter { !it.isAssigned() }.random().withRandomSide()
+ private fun pickRandomWonder(): AssignedWonder = allWonders.filter { !it.isAssigned() }.random().withRandomSide()
private fun PreGameWonder.isAssigned() = name in assignedWonders.map { it.name }
@@ -122,11 +121,9 @@ class Lobby(
state = State.FINISHED
}
- internal class GameAlreadyStartedException(name: String) :
- IllegalStateException("Game '$name' has already started")
+ internal class GameAlreadyStartedException(name: String) : IllegalStateException("Game '$name' has already started")
- internal class PlayerOverflowException(max: Int) :
- IllegalStateException("Maximum $max players allowed")
+ internal class PlayerOverflowException(max: Int) : IllegalStateException("Maximum $max players allowed")
internal class PlayerUnderflowException(min: Int) :
IllegalStateException("Minimum $min players required to start a game")
@@ -134,8 +131,7 @@ class Lobby(
internal class PlayerNameAlreadyUsedException(displayName: String, gameName: String) :
IllegalArgumentException("Name '$displayName' is already used by a player in game '$gameName'")
- internal class UnknownPlayerException(username: String) :
- IllegalArgumentException("Unknown player '$username'")
+ internal class UnknownPlayerException(username: String) : IllegalArgumentException("Unknown player '$username'")
internal class PlayerListMismatchException(usernames: List<String>) :
IllegalArgumentException("Newly ordered usernames $usernames don't match the current player list")
diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/lobby/Player.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/lobby/Player.kt
index 95b37643..94ae9742 100644
--- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/lobby/Player.kt
+++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/lobby/Player.kt
@@ -7,7 +7,7 @@ import org.luxons.sevenwonders.server.ApiMisuseException
class Player(
val username: String,
var displayName: String,
- var icon: Icon? = null
+ var icon: Icon? = null,
) {
var index: Int = -1
diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/repositories/PlayerRepository.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/repositories/PlayerRepository.kt
index e76bdaea..c5dd6215 100644
--- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/repositories/PlayerRepository.kt
+++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/repositories/PlayerRepository.kt
@@ -25,5 +25,4 @@ class PlayerRepository {
fun remove(username: String): Player = players.remove(username) ?: throw PlayerNotFoundException(username)
}
-internal class PlayerNotFoundException(username: String) :
- ApiMisuseException("Player '$username' doesn't exist")
+internal class PlayerNotFoundException(username: String) : ApiMisuseException("Player '$username' doesn't exist")
diff --git a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/controllers/LobbyControllerTest.kt b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/controllers/LobbyControllerTest.kt
index 2f6e2cdb..73a24ef0 100644
--- a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/controllers/LobbyControllerTest.kt
+++ b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/controllers/LobbyControllerTest.kt
@@ -15,7 +15,11 @@ import org.luxons.sevenwonders.server.repositories.PlayerNotFoundException
import org.luxons.sevenwonders.server.repositories.PlayerRepository
import org.luxons.sevenwonders.server.test.mockSimpMessagingTemplate
import java.util.HashMap
-import kotlin.test.*
+import kotlin.test.assertEquals
+import kotlin.test.assertFailsWith
+import kotlin.test.assertFalse
+import kotlin.test.assertSame
+import kotlin.test.assertTrue
class LobbyControllerTest {
diff --git a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/lobby/LobbyTest.kt b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/lobby/LobbyTest.kt
index 1742dc93..4125810f 100644
--- a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/lobby/LobbyTest.kt
+++ b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/lobby/LobbyTest.kt
@@ -17,7 +17,12 @@ import org.luxons.sevenwonders.server.lobby.Lobby.PlayerNameAlreadyUsedException
import org.luxons.sevenwonders.server.lobby.Lobby.PlayerOverflowException
import org.luxons.sevenwonders.server.lobby.Lobby.PlayerUnderflowException
import org.luxons.sevenwonders.server.lobby.Lobby.UnknownPlayerException
-import kotlin.test.*
+import kotlin.test.assertEquals
+import kotlin.test.assertFailsWith
+import kotlin.test.assertFalse
+import kotlin.test.assertNotNull
+import kotlin.test.assertSame
+import kotlin.test.assertTrue
@RunWith(Theories::class)
class LobbyTest {
diff --git a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/repositories/LobbyRepositoryTest.kt b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/repositories/LobbyRepositoryTest.kt
index 898a56fc..c59dc49f 100644
--- a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/repositories/LobbyRepositoryTest.kt
+++ b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/repositories/LobbyRepositoryTest.kt
@@ -3,7 +3,11 @@ package org.luxons.sevenwonders.server.repositories
import org.junit.Before
import org.junit.Test
import org.luxons.sevenwonders.server.lobby.Player
-import kotlin.test.*
+import kotlin.test.assertFailsWith
+import kotlin.test.assertNotNull
+import kotlin.test.assertSame
+import kotlin.test.assertTrue
+import kotlin.test.fail
class LobbyRepositoryTest {
diff --git a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/repositories/PlayerRepositoryTest.kt b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/repositories/PlayerRepositoryTest.kt
index b5c849a7..fc016903 100644
--- a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/repositories/PlayerRepositoryTest.kt
+++ b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/repositories/PlayerRepositoryTest.kt
@@ -2,7 +2,11 @@ package org.luxons.sevenwonders.server.repositories
import org.junit.Before
import org.junit.Test
-import kotlin.test.*
+import kotlin.test.assertEquals
+import kotlin.test.assertFailsWith
+import kotlin.test.assertFalse
+import kotlin.test.assertSame
+import kotlin.test.assertTrue
class PlayerRepositoryTest {
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 194fb8f1..efd40a6d 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
@@ -12,7 +12,7 @@ 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 {
diff --git a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpButtons.kt b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpButtons.kt
index 8b6ce30a..7438e0ba 100644
--- a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpButtons.kt
+++ b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpButtons.kt
@@ -1,4 +1,5 @@
@file:JsModule("@blueprintjs/core")
+
package com.palantir.blueprintjs
import org.w3c.dom.HTMLElement
@@ -14,10 +15,13 @@ import react.ReactElement
external interface IActionProps : IIntentProps, IProps {
/** Whether this action is non-interactive. */
var disabled: Boolean?
+
/** Name of a Blueprint UI icon (or an icon element) to render before the text. */
var icon: IconName?
+
/** Click event handler. */
var onClick: ((event: MouseEvent) -> Unit)?
+
/** Action text. Can be any single React renderable. */
var text: String?
}
@@ -25,12 +29,14 @@ external interface IActionProps : IIntentProps, IProps {
external interface IButtonProps : IActionProps {
// artificially added to allow title on button (should probably be on more general props)
var title: String?
+
/**
* If set to `true`, the button will display in an active state.
* This is equivalent to setting `className={Classes.ACTIVE}`.
* @default false
*/
var active: Boolean?
+
/**
* Text alignment within button. By default, icons and text will be centered
* within the button. Passing `"left"` or `"right"` will align the button
@@ -39,26 +45,35 @@ external interface IButtonProps : IActionProps {
* @default Alignment.CENTER
*/
var alignText: Alignment?
+
/** A ref handler that receives the native HTML element backing this component. */
var elementRef: ((ref: HTMLElement?) -> Any)?
+
/** Whether this button should expand to fill its container. */
var fill: Boolean?
+
/** Whether this button should use large styles. */
var large: Boolean?
+
/**
* If set to `true`, the button will display a centered loading spinner instead of its contents.
* The width of the button is not affected by the value of this prop.
* @default false
*/
var loading: Boolean?
+
/** Whether this button should use minimal styles. */
var minimal: Boolean?
+
/** Whether this button should use outlined styles. */
var outlined: Boolean?
+
/** Name of a Blueprint UI icon (or an icon element) to render after the text. */
var rightIcon: IconName?
+
/** Whether this button should use small styles. */
var small: Boolean?
+
/**
* HTML `type` attribute of button. Accepted values are `"button"`, `"submit"`, and `"reset"`.
* Note that this prop has no effect on `AnchorButton`; it only affects `Button`.
@@ -76,6 +91,7 @@ abstract external class AbstractButton : PureComponent<IButtonProps, IButtonStat
external class Button : AbstractButton {
override fun render(): ReactElement
}
+
external class AnchorButton : AbstractButton {
override fun render(): ReactElement
}
diff --git a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpCallout.kt b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpCallout.kt
index a812d6e4..15d8a3f9 100644
--- a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpCallout.kt
+++ b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpCallout.kt
@@ -1,4 +1,5 @@
@file:JsModule("@blueprintjs/core")
+
package com.palantir.blueprintjs
import react.PureComponent
diff --git a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpCard.kt b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpCard.kt
index dc8961f1..be9977ec 100644
--- a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpCard.kt
+++ b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpCard.kt
@@ -1,4 +1,5 @@
@file:JsModule("@blueprintjs/core")
+
package com.palantir.blueprintjs
import org.w3c.dom.events.MouseEvent
diff --git a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpDivider.kt b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpDivider.kt
index 8ccef232..84f5ae31 100644
--- a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpDivider.kt
+++ b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpDivider.kt
@@ -1,4 +1,5 @@
@file:JsModule("@blueprintjs/core")
+
package com.palantir.blueprintjs
import react.PureComponent
diff --git a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpHtmlTable.kt b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpHtmlTable.kt
index 1a602882..a8d45145 100644
--- a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpHtmlTable.kt
+++ b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpHtmlTable.kt
@@ -1,4 +1,5 @@
@file:JsModule("@blueprintjs/core")
+
package com.palantir.blueprintjs
import react.PureComponent
diff --git a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpIcon.kt b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpIcon.kt
index ab277617..54d6bde8 100644
--- a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpIcon.kt
+++ b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpIcon.kt
@@ -1,4 +1,5 @@
@file:JsModule("@blueprintjs/core")
+
package com.palantir.blueprintjs
import react.PureComponent
@@ -13,11 +14,13 @@ external interface IIconProps : IIntentProps, IProps {
* surrounding text.
*/
var color: String?
+
/**
* String for the `title` attribute on the rendered element, which will appear
* on hover as a native browser tooltip.
*/
var htmlTitle: String?
+
/**
* Name of a Blueprint UI icon, or an icon element, to render. This prop is
* required because it determines the content of the component, but it can
@@ -35,6 +38,7 @@ external interface IIconProps : IIntentProps, IProps {
* `<Element />` instead.
*/
var icon: IconName
+
/**
* Size of the icon, in pixels. Blueprint contains 16px and 20px SVG icon
* images, and chooses the appropriate resolution based on this prop.
@@ -48,6 +52,7 @@ external interface IIconProps : IIntentProps, IProps {
* @default "span"
*/
var tagName: String? // keyof JSX.IntrinsicElements
+
/**
* Description string. This string does not appear in normal browsers, but
* it increases accessibility. For instance, screen readers will use it for
diff --git a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpInputs.kt b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpInputs.kt
index 4eaadb78..90178a9b 100644
--- a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpInputs.kt
+++ b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpInputs.kt
@@ -1,4 +1,5 @@
@file:JsModule("@blueprintjs/core")
+
package com.palantir.blueprintjs
import org.w3c.dom.HTMLInputElement
@@ -13,30 +14,39 @@ external interface IInputGroupProps : IControlledProps, IIntentProps, IProps {
* @default false
*/
var disabled: Boolean?
+
/**
* Whether the component should take up the full width of its container.
*/
var fill: Boolean?
+
/** Ref handler that receives HTML `<input>` element backing this component. */
var inputRef: ((ref: HTMLInputElement?) -> Any)?
+
/**
* Name of a Blueprint UI icon (or an icon element) to render on the left side of the input group,
* before the user's cursor.
*/
var leftIcon: IconName?
+
/** Whether this input should use large styles. */
var large: Boolean?
+
/** Whether this input should use small styles. */
var small: Boolean?
+
/** Placeholder text in the absence of any value. */
var placeholder: String?
+
/**
* Element to render on right side of input.
* For best results, use a minimal button, tag, or small spinner.
*/
var rightElement: ReactElement?
+
/** Whether the input (and any buttons) should appear with rounded caps. */
var round: Boolean?
+
/**
* HTML `input` type attribute.
* @default "text"
diff --git a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpNonIdealState.kt b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpNonIdealState.kt
index f6ca7aec..7bc4fa0d 100644
--- a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpNonIdealState.kt
+++ b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpNonIdealState.kt
@@ -1,4 +1,5 @@
@file:JsModule("@blueprintjs/core")
+
package com.palantir.blueprintjs
import react.PureComponent
diff --git a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpOverlay.kt b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpOverlay.kt
index 254b5bb3..7c2f3c43 100644
--- a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpOverlay.kt
+++ b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpOverlay.kt
@@ -1,4 +1,5 @@
@file:JsModule("@blueprintjs/core")
+
package com.palantir.blueprintjs
import org.w3c.dom.HTMLElement
@@ -14,11 +15,13 @@ external interface IOverlayableProps : IOverlayLifecycleProps {
* @default true
*/
var autoFocus: Boolean?
+
/**
* Whether pressing the `esc` key should invoke `onClose`.
* @default true
*/
var canEscapeKeyClose: Boolean?
+
/**
* Whether the overlay should prevent focus from leaving itself. That is, if the user attempts
* to focus an element outside the overlay and this prop is enabled, then the overlay will
@@ -27,6 +30,7 @@ external interface IOverlayableProps : IOverlayLifecycleProps {
* @default true
*/
var enforceFocus: Boolean?
+
/**
* If `true` and `usePortal={true}`, the `Portal` containing the children is created and attached
* to the DOM when the overlay is opened for the first time; otherwise this happens when the
@@ -35,6 +39,7 @@ external interface IOverlayableProps : IOverlayLifecycleProps {
* @default true
*/
var lazy: Boolean?
+
/**
* Indicates how long (in milliseconds) the overlay's enter/leave transition takes.
* This is used by React `CSSTransition` to know when a transition completes and must match
@@ -43,6 +48,7 @@ external interface IOverlayableProps : IOverlayLifecycleProps {
* @default 300
*/
var transitionDuration: Int?
+
/**
* Whether the overlay should be wrapped in a `Portal`, which renders its contents in a new
* element attached to `portalContainer` prop.
@@ -56,17 +62,20 @@ external interface IOverlayableProps : IOverlayLifecycleProps {
* @default true
*/
var usePortal: Boolean?
+
/**
* Space-delimited string of class names applied to the `Portal` element if
* `usePortal={true}`.
*/
var portalClassName: String?
+
/**
* The container element into which the overlay renders its contents, when `usePortal` is `true`.
* This prop is ignored if `usePortal` is `false`.
* @default document.body
*/
var portalContainer: HTMLElement?
+
/**
* A callback that is invoked when user interaction causes the overlay to close, such as
* clicking on the overlay or pressing the `esc` key (if enabled).
@@ -77,53 +86,63 @@ external interface IOverlayableProps : IOverlayLifecycleProps {
*/
var onClose: ((Event) -> Unit)?
}
+
external interface IOverlayLifecycleProps {
/**
* Lifecycle method invoked just before the CSS _close_ transition begins on
* a child. Receives the DOM element of the child being closed.
*/
var onClosing: ((node: HTMLElement) -> Unit)?
+
/**
* Lifecycle method invoked just after the CSS _close_ transition ends but
* before the child has been removed from the DOM. Receives the DOM element
* of the child being closed.
*/
var onClosed: ((node: HTMLElement) -> Unit)?
+
/**
* Lifecycle method invoked just after mounting the child in the DOM but
* just before the CSS _open_ transition begins. Receives the DOM element of
* the child being opened.
*/
var onOpening: ((node: HTMLElement) -> Unit)?
+
/**
* Lifecycle method invoked just after the CSS _open_ transition ends.
* Receives the DOM element of the child being opened.
*/
var onOpened: ((node: HTMLElement) -> Unit)?
}
+
external interface IBackdropProps {
/** CSS class names to apply to backdrop element. */
var backdropClassName: String?
+
/** HTML props for the backdrop element. */
var backdropProps: RProps? // React.HTMLProps<HTMLDivElement>?
+
/**
* Whether clicking outside the overlay element (either on backdrop when present or on document)
* should invoke `onClose`.
* @default true
*/
var canOutsideClickClose: Boolean?
+
/**
* Whether a container-spanning backdrop element should be rendered behind the contents.
* @default true
*/
var hasBackdrop: Boolean?
}
+
external interface IOverlayProps : IOverlayableProps, IBackdropProps, IProps {
/**
* Toggles the visibility of the overlay and its children.
* This prop is required because the component is controlled.
*/
var isOpen: Boolean
+
/**
* Name of the transition for internal `CSSTransition`.
* Providing your own name here will require defining new CSS transition properties.
@@ -131,9 +150,11 @@ external interface IOverlayProps : IOverlayableProps, IBackdropProps, IProps {
*/
var transitionName: String?
}
+
external interface IOverlayState : RState {
var hasEverOpened: Boolean?
}
+
external class Overlay : PureComponent<IOverlayProps, IOverlayState> {
override fun render(): ReactElement
}
diff --git a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpPopover.kt b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpPopover.kt
index 1c610579..57093a25 100644
--- a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpPopover.kt
+++ b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpPopover.kt
@@ -1,4 +1,5 @@
@file:JsModule("@blueprintjs/core")
+
package com.palantir.blueprintjs
import org.w3c.dom.HTMLDivElement
diff --git a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpTag.kt b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpTag.kt
index 7a2a04f2..a3727af9 100644
--- a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpTag.kt
+++ b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpTag.kt
@@ -1,4 +1,5 @@
@file:JsModule("@blueprintjs/core")
+
package com.palantir.blueprintjs
import org.w3c.dom.events.MouseEvent
@@ -12,13 +13,16 @@ external interface ITagProps : IProps, IIntentProps {
* @default false
*/
var active: Boolean?
+
/**
* Whether the tag should take up the full width of its container.
* @default false
*/
var fill: Boolean?
+
/** Name of a Blueprint UI icon (or an icon element) to render before the children. */
var icon: IconName?
+
/**
* Whether the tag should visually respond to user interactions. If set
* to `true`, hovering over the tag will change its color and mouse cursor.
@@ -28,16 +32,19 @@ external interface ITagProps : IProps, IIntentProps {
* @default false
*/
var interactive: Boolean?
+
/**
* Whether this tag should use large styles.
* @default false
*/
var large: Boolean?
+
/**
* Whether this tag should use minimal styles.
* @default false
*/
var minimal: Boolean?
+
/**
* Whether tag content should be allowed to occupy multiple lines.
* If false, a single line of text will be truncated with an ellipsis if
@@ -46,18 +53,22 @@ external interface ITagProps : IProps, IIntentProps {
* @default false
*/
var multiline: Boolean?
+
/**
* Callback invoked when the tag is clicked.
* Recommended when `interactive` is `true`.
*/
var onClick: ((e: MouseEvent) -> Unit)?
+
/**
* Click handler for remove button.
* The remove button will only be rendered if this prop is defined.
*/
var onRemove: ((e: MouseEvent, tagProps: ITagProps) -> Unit)?
+
/** Name of a Blueprint UI icon (or an icon element) to render after the children. */
var rightIcon: IconName?
+
/**
* Whether this tag should have rounded ends.
* @default false
diff --git a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjs.kt b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjs.kt
index 7da41fc9..8063f98e 100644
--- a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjs.kt
+++ b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjs.kt
@@ -1,4 +1,5 @@
@file:JsModule("@blueprintjs/core")
+
package com.palantir.blueprintjs
import org.w3c.dom.events.Event
@@ -59,26 +60,33 @@ external interface IProps : RProps {
/** A space-delimited list of class names to pass along to a child element. */
var className: String?
}
+
external interface IIntentProps {
/** Visual intent color to apply to element. */
var intent: Intent?
}
+
/** Interface for a link, with support for customizing target window. */
external interface ILinkProps {
/** Link URL. */
var href: String?
+
/** Link target attribute. Use `"_blank"` to open in a new window. */
var target: String?
}
+
/** Interface for a controlled input. */
external interface IControlledProps {
/** Initial value of the input, for uncontrolled usage. */
var defaultValue: String?
+
/** Change event handler. Use `event.target.value` for new value. */
var onChange: ((Event) -> Unit)?
+
/** Form value of the input, for controlled usage. */
var value: String?
}
+
/**
* An interface for an option in a list, such as in a `<select>` or `RadioGroup`.
* These props can be spread directly to an `<option>` or `<Radio>` element.
@@ -86,8 +94,10 @@ external interface IControlledProps {
external interface IOptionProps : IProps {
/** Whether this option is non-interactive. */
var disabled: Boolean?
+
/** Label text for this option. If omitted, `value` is used as the label. */
var label: String?
+
/** Value of this option. */
var value: Any? // String | Number
}
diff --git a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjsHelpers.kt b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjsHelpers.kt
index 9132de58..5ad0cc7c 100644
--- a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjsHelpers.kt
+++ b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjsHelpers.kt
@@ -17,7 +17,7 @@ fun RBuilder.bpIcon(
title: String? = null,
alt: String? = null,
className: String? = null,
- block: RHandler<IIconProps> = {}
+ block: RHandler<IIconProps> = {},
): ReactElement = child(Icon::class) {
attrs {
this.icon = name
@@ -40,7 +40,7 @@ fun RBuilder.bpButton(
rightIcon: IconName? = null,
intent: Intent = Intent.NONE,
onClick: ((event: MouseEvent) -> Unit)? = {},
- block: RHandler<IButtonProps> = {}
+ block: RHandler<IButtonProps> = {},
): ReactElement = child(Button::class) {
attrs {
this.title = title
@@ -59,7 +59,7 @@ fun RBuilder.bpButton(
fun RBuilder.bpButtonGroup(
large: Boolean = false,
minimal: Boolean = false,
- block: RHandler<IButtonGroupProps> = {}
+ block: RHandler<IButtonGroupProps> = {},
): ReactElement = child(ButtonGroup::class) {
attrs {
this.large = large
@@ -72,7 +72,7 @@ fun RBuilder.bpInputGroup(
large: Boolean = false,
placeholder: String = "",
rightElement: ReactElement? = null,
- onChange: (Event) -> Unit
+ onChange: (Event) -> Unit,
): ReactElement = child(InputGroup::class) {
attrs {
this.large = large
@@ -90,7 +90,7 @@ fun RBuilder.bpTag(
fill: Boolean? = null,
active: Boolean? = null,
icon: String? = null,
- block: RHandler<ITagProps> = {}
+ block: RHandler<ITagProps> = {},
): ReactElement = child(Tag::class) {
attrs {
this.intent = intent
@@ -110,7 +110,7 @@ fun RBuilder.bpNonIdealState(
description: ReactElement? = null,
action: ReactElement? = null,
children: ReactElement? = null,
- block: RHandler<INonIdealStateProps> = {}
+ block: RHandler<INonIdealStateProps> = {},
): ReactElement = child(NonIdealState::class) {
attrs {
this.icon = icon
@@ -128,7 +128,7 @@ fun RBuilder.bpNonIdealState(
description: ReactElement? = null,
action: ReactElement? = null,
children: ReactElement? = null,
- block: RHandler<INonIdealStateProps> = {}
+ block: RHandler<INonIdealStateProps> = {},
): ReactElement = bpNonIdealState(icon, buildElement { h2 { +title } }, description, action, children, block)
fun RBuilder.bpOverlay(
@@ -140,7 +140,7 @@ fun RBuilder.bpOverlay(
canEscapeKeyClose: Boolean = true,
canOutsideClickClose: Boolean = true,
onClose: () -> Unit = {},
- block: RHandler<IOverlayProps> = {}
+ block: RHandler<IOverlayProps> = {},
): ReactElement = child(Overlay::class) {
attrs {
this.isOpen = isOpen
@@ -167,7 +167,7 @@ fun RBuilder.bpPopover(
popoverClassName: String? = null,
portalClassName: String? = null,
onClose: () -> Unit = {},
- block: RHandler<IPopoverProps> = {}
+ block: RHandler<IPopoverProps> = {},
): ReactElement = child(Popover::class) {
attrs {
this.interactionKind = interactionKind
@@ -189,7 +189,7 @@ fun RBuilder.bpCallout(
intent: Intent? = Intent.NONE,
icon: IconName? = null,
title: String? = null,
- block: RHandler<ICalloutProps> = {}
+ block: RHandler<ICalloutProps> = {},
): ReactElement = child(Callout::class) {
attrs {
if (icon != null) {
@@ -206,7 +206,7 @@ fun RBuilder.bpCard(
interactive: Boolean = false,
className: String? = null,
onClick: () -> Unit = {},
- block: RHandler<ICardProps> = {}
+ block: RHandler<ICardProps> = {},
): ReactElement = child(Card::class) {
attrs {
this.elevation = elevation
@@ -222,7 +222,7 @@ fun RBuilder.bpHtmlTable(
interactive: Boolean = false,
condensed: Boolean = false,
striped: Boolean = false,
- block: RHandler<IHTMLTableProps> = {}
+ block: RHandler<IHTMLTableProps> = {},
): ReactElement = child(HTMLTable::class) {
attrs {
this.bordered = bordered
@@ -235,7 +235,7 @@ fun RBuilder.bpHtmlTable(
fun RBuilder.bpDivider(
tagName: String? = null,
- block: RHandler<IDividerProps> = {}
+ block: RHandler<IDividerProps> = {},
): ReactElement = child(Divider::class) {
attrs {
if (tagName != null) {
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Board.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Board.kt
index 419aa71b..9cc72c31 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Board.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Board.kt
@@ -74,7 +74,7 @@ private fun RBuilder.tableCard(card: TableCard, indexInColumn: Int, block: Style
transform {
translate(
tx = (indexInColumn * xOffset).pct,
- ty = (indexInColumn * yOffset).pct
+ ty = (indexInColumn * yOffset).pct,
)
}
maxWidth = 100.pct
@@ -153,7 +153,7 @@ private fun RBuilder.boardToken(tokenName: String, count: Int, block: StyledDOMB
tokenName = tokenName,
count = count,
countPosition = TokenCountPosition.RIGHT,
- brightText = true
+ brightText = true,
) {
css {
filter = "drop-shadow(0.2rem 0.2rem 0.5rem black)"
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/BoardSummary.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/BoardSummary.kt
index 05a043bf..4f1459de 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/BoardSummary.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/BoardSummary.kt
@@ -11,12 +11,16 @@ import org.luxons.sevenwonders.ui.components.gameBrowser.playerInfo
import react.RBuilder
import react.ReactElement
import react.buildElement
-import styled.*
+import styled.StyledDOMBuilder
+import styled.css
+import styled.getClassName
+import styled.styledDiv
+import styled.styledHr
enum class BoardSummarySide(
val tokenCountPosition: TokenCountPosition,
val alignment: Align,
- val popoverPosition: PopoverPosition
+ val popoverPosition: PopoverPosition,
) {
LEFT(TokenCountPosition.RIGHT, Align.flexStart, PopoverPosition.RIGHT),
TOP(TokenCountPosition.OVER, Align.flexStart, PopoverPosition.BOTTOM),
@@ -27,13 +31,13 @@ fun RBuilder.boardSummaryWithPopover(
player: PlayerDTO,
board: Board,
boardSummarySide: BoardSummarySide,
- block: StyledDOMBuilder<DIV>.() -> Unit = {}
+ block: StyledDOMBuilder<DIV>.() -> Unit = {},
) {
val popoverClass = GameStyles.getClassName { it::fullBoardPreviewPopover }
bpPopover(
content = createFullBoardPreview(board),
position = boardSummarySide.popoverPosition,
- popoverClassName = popoverClass
+ popoverClassName = popoverClass,
) {
boardSummary(player, board, boardSummarySide, block)
}
@@ -50,14 +54,14 @@ private fun createFullBoardPreview(board: Board): ReactElement = buildElement {
private fun RBuilder.boardSummary(
player: PlayerDTO,
board: Board,
- boardSummarySide: BoardSummarySide,
- block: StyledDOMBuilder<DIV>.() -> Unit = {}
+ side: BoardSummarySide,
+ block: StyledDOMBuilder<DIV>.() -> Unit = {},
) {
styledDiv {
css {
display = Display.flex
flexDirection = FlexDirection.column
- alignItems = boardSummarySide.alignment
+ alignItems = side.alignment
padding(all = 0.5.rem)
backgroundColor = Color.paleGoldenrod.withAlpha(0.5)
zIndex = 50 // above table cards
@@ -77,13 +81,13 @@ private fun RBuilder.boardSummary(
styledDiv {
css {
display = Display.flex
- flexDirection = if (boardSummarySide == BoardSummarySide.TOP) FlexDirection.row else FlexDirection.column
- alignItems = boardSummarySide.alignment
+ flexDirection = if (side == BoardSummarySide.TOP) FlexDirection.row else FlexDirection.column
+ alignItems = side.alignment
}
val tokenSize = 2.rem
- generalCounts(board, tokenSize, boardSummarySide.tokenCountPosition)
+ generalCounts(board, tokenSize, side.tokenCountPosition)
bpDivider()
- scienceTokens(board, tokenSize, boardSummarySide.tokenCountPosition)
+ scienceTokens(board, tokenSize, side.tokenCountPosition)
}
block()
}
@@ -92,7 +96,7 @@ private fun RBuilder.boardSummary(
private fun StyledDOMBuilder<DIV>.generalCounts(
board: Board,
tokenSize: LinearDimension,
- countPosition: TokenCountPosition
+ countPosition: TokenCountPosition,
) {
goldIndicator(amount = board.gold, imgSize = tokenSize, amountPosition = countPosition)
tokenWithCount(
@@ -100,41 +104,41 @@ private fun StyledDOMBuilder<DIV>.generalCounts(
count = board.bluePoints,
imgSize = tokenSize,
countPosition = countPosition,
- brightText = countPosition == TokenCountPosition.OVER
+ brightText = countPosition == TokenCountPosition.OVER,
)
tokenWithCount(
tokenName = "military/shield",
count = board.military.nbShields,
imgSize = tokenSize,
countPosition = countPosition,
- brightText = countPosition == TokenCountPosition.OVER
+ brightText = countPosition == TokenCountPosition.OVER,
)
}
private fun RBuilder.scienceTokens(
board: Board,
tokenSize: LinearDimension,
- sciencePosition: TokenCountPosition
+ sciencePosition: TokenCountPosition,
) {
tokenWithCount(
tokenName = "science/compass",
count = board.science.nbCompasses,
imgSize = tokenSize,
countPosition = sciencePosition,
- brightText = sciencePosition == TokenCountPosition.OVER
+ brightText = sciencePosition == TokenCountPosition.OVER,
)
tokenWithCount(
tokenName = "science/cog",
count = board.science.nbWheels,
imgSize = tokenSize,
countPosition = sciencePosition,
- brightText = sciencePosition == TokenCountPosition.OVER
+ brightText = sciencePosition == TokenCountPosition.OVER,
)
tokenWithCount(
tokenName = "science/tablet",
count = board.science.nbTablets,
imgSize = tokenSize,
countPosition = sciencePosition,
- brightText = sciencePosition == TokenCountPosition.OVER
+ brightText = sciencePosition == TokenCountPosition.OVER,
)
}
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/CardImage.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/CardImage.kt
index a2d0b8f2..79836f70 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/CardImage.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/CardImage.kt
@@ -15,7 +15,7 @@ fun RBuilder.cardImage(
card: Card,
faceDown: Boolean = false,
highlightColor: Color? = null,
- block: StyledDOMBuilder<IMG>.() -> Unit = {}
+ block: StyledDOMBuilder<IMG>.() -> Unit = {},
) {
if (faceDown) {
cardBackImage(card.back, highlightColor, block)
@@ -36,7 +36,7 @@ fun RBuilder.cardImage(
fun RBuilder.cardBackImage(
cardBack: CardBack,
highlightColor: Color? = null,
- block: StyledDOMBuilder<IMG>.() -> Unit = {}
+ block: StyledDOMBuilder<IMG>.() -> Unit = {},
) {
styledImg(src = "/images/cards/back/${cardBack.image}") {
css {
@@ -75,7 +75,7 @@ private fun CSSBuilder.highlightStyle(highlightColor: Color?) {
offsetY = 0.px,
blurRadius = 1.rem,
spreadRadius = 0.1.rem,
- color = highlightColor
+ color = highlightColor,
)
}
}
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 3545113b..fbd6d8c5 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
@@ -1,17 +1,38 @@
package org.luxons.sevenwonders.ui.components.game
-import com.palantir.blueprintjs.*
+import com.palantir.blueprintjs.Elevation
+import com.palantir.blueprintjs.Intent
+import com.palantir.blueprintjs.bpButton
+import com.palantir.blueprintjs.bpButtonGroup
+import com.palantir.blueprintjs.bpCallout
+import com.palantir.blueprintjs.bpCard
+import com.palantir.blueprintjs.bpNonIdealState
+import com.palantir.blueprintjs.bpOverlay
import kotlinx.css.*
import kotlinx.css.properties.*
import kotlinx.html.DIV
-import org.luxons.sevenwonders.model.*
+import org.luxons.sevenwonders.model.Action
+import org.luxons.sevenwonders.model.PlayerMove
+import org.luxons.sevenwonders.model.PlayerTurnInfo
import org.luxons.sevenwonders.model.api.PlayerDTO
import org.luxons.sevenwonders.model.boards.Board
import org.luxons.sevenwonders.model.boards.RelativeBoardPosition
import org.luxons.sevenwonders.model.cards.HandCard
+import org.luxons.sevenwonders.model.getBoard
+import org.luxons.sevenwonders.model.getOwnBoard
import org.luxons.sevenwonders.ui.components.GlobalStyles
-import org.luxons.sevenwonders.ui.redux.*
-import react.*
+import org.luxons.sevenwonders.ui.redux.GameState
+import org.luxons.sevenwonders.ui.redux.RequestLeaveGame
+import org.luxons.sevenwonders.ui.redux.RequestPrepareMove
+import org.luxons.sevenwonders.ui.redux.RequestSayReady
+import org.luxons.sevenwonders.ui.redux.RequestUnprepareMove
+import org.luxons.sevenwonders.ui.redux.connectStateAndDispatch
+import react.RBuilder
+import react.RClass
+import react.RComponent
+import react.RProps
+import react.RState
+import react.ReactElement
import styled.StyledDOMBuilder
import styled.css
import styled.getClassName
@@ -193,17 +214,12 @@ private class GameScene(props: GameSceneProps) : RComponent<GameSceneProps, RSta
disabled = isReady,
intent = intent,
icon = if (isReady) "tick-circle" else "play",
- onClick = { props.sayReady() }
+ onClick = { props.sayReady() },
) {
+"READY"
}
// not really a button, but nice for style
- bpButton(
- large = true,
- icon = "people",
- disabled = isReady,
- intent = intent
- ) {
+ bpButton(large = true, icon = "people", disabled = isReady, intent = intent) {
+"${props.players.count { it.isReady }}/${props.players.size}"
}
}
@@ -228,5 +244,5 @@ private val gameScene: RClass<GameSceneProps> =
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 315e25e8..c8fb8d61 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
@@ -1,14 +1,28 @@
package org.luxons.sevenwonders.ui.components.game
-import com.palantir.blueprintjs.*
+import com.palantir.blueprintjs.IButtonGroupProps
+import com.palantir.blueprintjs.IButtonProps
+import com.palantir.blueprintjs.IconName
+import com.palantir.blueprintjs.Intent
+import com.palantir.blueprintjs.bpButton
+import com.palantir.blueprintjs.bpButtonGroup
+import com.palantir.blueprintjs.bpIcon
import kotlinx.css.*
import kotlinx.css.properties.*
import kotlinx.html.DIV
-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.cards.CardPlayability
import org.luxons.sevenwonders.model.cards.HandCard
+import org.luxons.sevenwonders.model.getOwnBoard
import org.luxons.sevenwonders.model.wonders.WonderBuildability
-import react.*
+import react.RBuilder
+import react.RComponent
+import react.RElementBuilder
+import react.RProps
+import react.RState
import styled.StyledDOMBuilder
import styled.css
import styled.styledDiv
@@ -17,7 +31,7 @@ import kotlin.math.absoluteValue
private enum class HandAction(
val buttonTitle: String,
val moveType: MoveType,
- val icon: IconName
+ val icon: IconName,
) {
PLAY("PLAY", MoveType.PLAY, "play"),
PLAY_FREE("Play as this age's free card", MoveType.PLAY_FREE, "star"),
@@ -58,7 +72,7 @@ class HandComponent(props: HandProps) : RComponent<HandProps, RState>(props) {
private fun RBuilder.handCard(
card: HandCard,
- block: StyledDOMBuilder<DIV>.() -> Unit
+ block: StyledDOMBuilder<DIV>.() -> Unit,
) {
styledDiv {
css {
@@ -120,7 +134,7 @@ class HandComponent(props: HandProps) : RComponent<HandProps, RState>(props) {
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) {
@@ -139,7 +153,7 @@ class HandComponent(props: HandProps) : RComponent<HandProps, RState>(props) {
onClick = {
val transactions = wonderBuildability.cheapestTransactions.first()
props.prepareMove(PlayerMove(MoveType.UPGRADE_WONDER, card.name, transactions))
- }
+ },
) {
bpIcon("key-shift")
if (wonderBuildability.isBuildable && !wonderBuildability.isFree) {
@@ -154,7 +168,7 @@ class HandComponent(props: HandProps) : RComponent<HandProps, RState>(props) {
large = true,
intent = Intent.DANGER,
icon = "cross",
- onClick = { props.prepareMove(PlayerMove(MoveType.DISCARD, card.name)) }
+ onClick = { props.prepareMove(PlayerMove(MoveType.DISCARD, card.name)) },
)
}
}
@@ -189,7 +203,7 @@ private fun RElementBuilder<IButtonProps>.priceInfo(amount: Int) {
customCountStyle = {
fontFamily = "sans-serif"
fontSize = size * 0.8
- }
+ },
) {
css {
position = Position.absolute
@@ -251,7 +265,7 @@ private fun CSSBuilder.handCardImgStyle(isPlayable: Boolean) {
fun RBuilder.handCards(
turnInfo: PlayerTurnInfo,
preparedMove: PlayerMove?,
- prepareMove: (PlayerMove) -> Unit
+ prepareMove: (PlayerMove) -> Unit,
) {
child(HandComponent::class) {
attrs {
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/PreparedMove.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/PreparedMove.kt
index 083338a8..3cb230e0 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/PreparedMove.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/PreparedMove.kt
@@ -19,7 +19,7 @@ fun RBuilder.preparedMove(
card: HandCard,
move: PlayerMove,
unprepareMove: () -> Unit,
- block: StyledDOMBuilder<DIV>.() -> Unit
+ block: StyledDOMBuilder<DIV>.() -> Unit,
) {
styledDiv {
block()
@@ -45,7 +45,7 @@ fun RBuilder.preparedMove(
title = "Cancel prepared move",
small = true,
intent = Intent.DANGER,
- onClick = { unprepareMove() }
+ onClick = { unprepareMove() },
)
}
}
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/ScoreTable.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/ScoreTable.kt
index 28003cef..16c83c78 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/ScoreTable.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/ScoreTable.kt
@@ -1,6 +1,12 @@
package org.luxons.sevenwonders.ui.components.game
-import com.palantir.blueprintjs.*
+import com.palantir.blueprintjs.Intent
+import com.palantir.blueprintjs.bpButton
+import com.palantir.blueprintjs.bpCard
+import com.palantir.blueprintjs.bpHtmlTable
+import com.palantir.blueprintjs.bpIcon
+import com.palantir.blueprintjs.bpOverlay
+import com.palantir.blueprintjs.bpTag
import kotlinx.css.*
import kotlinx.html.TD
import kotlinx.html.TH
@@ -10,7 +16,12 @@ import org.luxons.sevenwonders.model.score.ScoreCategory
import org.luxons.sevenwonders.ui.components.GlobalStyles
import react.RBuilder
import react.dom.*
-import styled.*
+import styled.css
+import styled.getClassName
+import styled.inlineStyles
+import styled.styledDiv
+import styled.styledH1
+import styled.styledTd
fun RBuilder.scoreTableOverlay(scoreBoard: ScoreBoard, players: List<PlayerDTO>, leaveGame: () -> Unit) {
bpOverlay(isOpen = true) {
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Tokens.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Tokens.kt
index efdc3ba8..74dc232e 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Tokens.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Tokens.kt
@@ -6,10 +6,16 @@ import kotlinx.html.IMG
import kotlinx.html.title
import org.luxons.sevenwonders.ui.components.GlobalStyles
import react.RBuilder
-import styled.*
+import styled.StyledDOMBuilder
+import styled.css
+import styled.styledDiv
+import styled.styledImg
+import styled.styledSpan
enum class TokenCountPosition {
- LEFT, RIGHT, OVER
+ LEFT,
+ RIGHT,
+ OVER,
}
fun RBuilder.goldIndicator(
@@ -17,7 +23,7 @@ fun RBuilder.goldIndicator(
amountPosition: TokenCountPosition = TokenCountPosition.OVER,
imgSize: LinearDimension = 3.rem,
customCountStyle: CSSBuilder.() -> Unit = {},
- block: StyledDOMBuilder<DIV>.() -> Unit = {}
+ block: StyledDOMBuilder<DIV>.() -> Unit = {},
) {
tokenWithCount(
tokenName = "coin",
@@ -26,7 +32,7 @@ fun RBuilder.goldIndicator(
count = amount,
countPosition = amountPosition,
customCountStyle = customCountStyle,
- block = block
+ block = block,
)
}
@@ -38,7 +44,7 @@ fun RBuilder.tokenWithCount(
countPosition: TokenCountPosition = TokenCountPosition.RIGHT,
brightText: Boolean = false,
customCountStyle: CSSBuilder.() -> Unit = {},
- block: StyledDOMBuilder<DIV>.() -> Unit = {}
+ block: StyledDOMBuilder<DIV>.() -> Unit = {},
) {
styledDiv {
block()
@@ -85,7 +91,7 @@ fun RBuilder.tokenImage(
tokenName: String,
title: String = tokenName,
size: LinearDimension?,
- block: StyledDOMBuilder<IMG>.() -> Unit = {}
+ block: StyledDOMBuilder<IMG>.() -> Unit = {},
) {
styledImg(src = getTokenImagePath(tokenName)) {
css {
@@ -108,7 +114,7 @@ private fun getTokenImagePath(tokenName: String) = "/images/tokens/$tokenName.pn
private fun CSSBuilder.tokenCountStyle(
size: LinearDimension,
brightText: Boolean,
- customStyle: CSSBuilder.() -> Unit = {}
+ customStyle: CSSBuilder.() -> Unit = {},
) {
fontFamily = "Acme"
fontSize = size
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/CreateGameForm.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/CreateGameForm.kt
index a33c0507..e060af9c 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/CreateGameForm.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/CreateGameForm.kt
@@ -9,7 +9,12 @@ import org.luxons.sevenwonders.ui.redux.RequestCreateGame
import org.luxons.sevenwonders.ui.redux.connectDispatch
import org.w3c.dom.HTMLInputElement
import org.w3c.dom.events.Event
-import react.*
+import react.RBuilder
+import react.RClass
+import react.RComponent
+import react.RProps
+import react.RState
+import react.buildElement
import react.dom.*
import styled.css
import styled.styledDiv
@@ -44,7 +49,7 @@ private class CreateGameForm(props: CreateGameFormProps) : RComponent<CreateGame
val input = e.currentTarget as HTMLInputElement
setState(transformState = { CreateGameFormState(input.value) })
},
- rightElement = createGameButton()
+ rightElement = createGameButton(),
)
}
currentPlayerInfo()
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/GameList.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/GameList.kt
index 4d23974f..1e74070a 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/GameList.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/GameList.kt
@@ -1,6 +1,10 @@
package org.luxons.sevenwonders.ui.components.gameBrowser
-import com.palantir.blueprintjs.*
+import com.palantir.blueprintjs.Intent
+import com.palantir.blueprintjs.bpButton
+import com.palantir.blueprintjs.bpHtmlTable
+import com.palantir.blueprintjs.bpIcon
+import com.palantir.blueprintjs.bpTag
import kotlinx.css.*
import kotlinx.html.title
import org.luxons.sevenwonders.model.api.ConnectedPlayer
@@ -99,7 +103,7 @@ class GameListPresenter(props: GameListProps) : RComponent<GameListProps, RState
title = joinability.tooltip,
icon = "arrow-right",
disabled = !joinability.canDo,
- onClick = { props.joinGame(lobby.id) }
+ onClick = { props.joinGame(lobby.id) },
)
}
}
@@ -114,5 +118,5 @@ private val gameList = connectStateAndDispatch<GameListStateProps, GameListDispa
},
mapDispatchToProps = { dispatch, _ ->
joinGame = { gameId -> dispatch(RequestJoinGame(gameId = gameId)) }
- }
+ },
)
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/PlayerInfo.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/PlayerInfo.kt
index a6289649..40581ff4 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/PlayerInfo.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/PlayerInfo.kt
@@ -76,7 +76,7 @@ class PlayerInfoPresenter(props: PlayerInfoProps) : RComponent<PlayerInfoProps,
fun RBuilder.playerInfo(
playerDTO: PlayerDTO,
showUsername: Boolean = false,
- iconSize: Int = 30
+ iconSize: Int = 30,
) = child(PlayerInfoPresenter::class) {
attrs {
this.player = playerDTO
@@ -92,5 +92,5 @@ private val playerInfo = connectState(
mapStateToProps = { state, _ ->
player = state.connectedPlayer
showUsername = true
- }
+ },
)
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/home/ChooseNameForm.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/home/ChooseNameForm.kt
index c4d424fa..a63fef08 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/home/ChooseNameForm.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/home/ChooseNameForm.kt
@@ -8,7 +8,13 @@ import org.luxons.sevenwonders.ui.redux.RequestChooseName
import org.luxons.sevenwonders.ui.redux.connectDispatch
import org.w3c.dom.HTMLInputElement
import org.w3c.dom.events.Event
-import react.*
+import react.RBuilder
+import react.RClass
+import react.RComponent
+import react.RProps
+import react.RState
+import react.ReactElement
+import react.buildElement
import react.dom.*
private interface ChooseNameFormProps : RProps {
@@ -33,7 +39,7 @@ private class ChooseNameForm(props: ChooseNameFormProps) : RComponent<ChooseName
onChange = { e ->
val input = e.currentTarget as HTMLInputElement
setState(transformState = { ChooseNameFormState(input.value) })
- }
+ },
)
}
}
@@ -43,7 +49,7 @@ private class ChooseNameForm(props: ChooseNameFormProps) : RComponent<ChooseName
minimal = true,
icon = "arrow-right",
intent = Intent.PRIMARY,
- onClick = { e -> chooseUsername(e) }
+ onClick = { e -> chooseUsername(e) },
)
}
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/Lobby.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/Lobby.kt
index d304880f..3fa85b0a 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/Lobby.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/Lobby.kt
@@ -99,7 +99,7 @@ class LobbyPresenter(props: LobbyProps) : RComponent<LobbyProps, RState>(props)
icon = "play",
title = startability.tooltip,
disabled = !startability.canDo,
- onClick = { props.startGame() }
+ onClick = { props.startGame() },
) {
+"START"
}
@@ -141,7 +141,7 @@ class LobbyPresenter(props: LobbyProps) : RComponent<LobbyProps, RState>(props)
rightIcon = "desktop",
title = if (currentGame.maxPlayersReached) "Max players reached" else "Add a bot to this game",
disabled = currentGame.maxPlayersReached,
- onClick = { addBot(currentGame) }
+ onClick = { addBot(currentGame) },
)
}
@@ -157,7 +157,7 @@ class LobbyPresenter(props: LobbyProps) : RComponent<LobbyProps, RState>(props)
icon = "random",
rightIcon = "people",
title = "Re-order players randomly",
- onClick = { reorderPlayers(currentGame) }
+ onClick = { reorderPlayers(currentGame) },
) {
+"Reorder players"
}
@@ -171,7 +171,7 @@ class LobbyPresenter(props: LobbyProps) : RComponent<LobbyProps, RState>(props)
bpButton(
icon = "random",
title = "Re-assign wonders to players randomly",
- onClick = { randomizeWonders(currentGame) }
+ onClick = { randomizeWonders(currentGame) },
) {
+"Randomize wonders"
}
@@ -185,17 +185,17 @@ class LobbyPresenter(props: LobbyProps) : RComponent<LobbyProps, RState>(props)
bpButton(
icon = "random",
title = "Re-roll wonder sides randomly",
- onClick = { randomizeWonderSides(currentGame) }
+ onClick = { randomizeWonderSides(currentGame) },
)
bpButton(
title = "Choose side A for everyone",
- onClick = { setWonderSides(currentGame, WonderSide.A) }
+ onClick = { setWonderSides(currentGame, WonderSide.A) },
) {
+"A"
}
bpButton(
title = "Choose side B for everyone",
- onClick = { setWonderSides(currentGame, WonderSide.B) }
+ onClick = { setWonderSides(currentGame, WonderSide.B) },
) {
+"B"
}
@@ -220,7 +220,7 @@ class LobbyPresenter(props: LobbyProps) : RComponent<LobbyProps, RState>(props)
intent = Intent.DANGER,
icon = "arrow-left",
title = "Leave the lobby and go back to the game browser",
- onClick = { props.leaveLobby() }
+ onClick = { props.leaveLobby() },
) {
+"LEAVE"
}
@@ -241,5 +241,5 @@ private val lobby = connectStateAndDispatch<LobbyStateProps, LobbyDispatchProps,
leaveLobby = { dispatch(RequestLeaveLobby()) }
reorderPlayers = { orderedPlayers -> dispatch(RequestReorderPlayers(orderedPlayers)) }
reassignWonders = { wonders -> dispatch(RequestReassignWonders(wonders)) }
- }
+ },
)
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/RadialList.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/RadialList.kt
index e27e1cd8..97320b76 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/RadialList.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/RadialList.kt
@@ -7,7 +7,11 @@ import org.luxons.sevenwonders.ui.components.GlobalStyles
import react.RBuilder
import react.ReactElement
import react.dom.*
-import styled.*
+import styled.StyledDOMBuilder
+import styled.css
+import styled.styledDiv
+import styled.styledLi
+import styled.styledUl
fun <T> RBuilder.radialList(
items: List<T>,
@@ -17,7 +21,7 @@ fun <T> RBuilder.radialList(
itemWidth: Int,
itemHeight: Int,
options: RadialConfig = RadialConfig(),
- block: StyledDOMBuilder<DIV>.() -> Unit = {}
+ block: StyledDOMBuilder<DIV>.() -> Unit = {},
): ReactElement {
val containerWidth = options.diameter + itemWidth
val containerHeight = options.diameter + itemHeight
@@ -39,7 +43,7 @@ private fun <T> RBuilder.radialListItems(
items: List<T>,
renderItem: (T) -> ReactElement,
getKey: (T) -> String,
- radialConfig: RadialConfig
+ radialConfig: RadialConfig,
): ReactElement {
val offsets = offsetsFromCenter(items.size, radialConfig)
return styledUl {
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/RadialMath.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/RadialMath.kt
index d668ab9b..4b5eb509 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/RadialMath.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/RadialMath.kt
@@ -7,12 +7,12 @@ import kotlin.math.sin
data class CartesianCoords(
val x: Int,
- val y: Int
+ val y: Int,
)
data class PolarCoords(
val radius: Int,
- val angleDeg: Int
+ val angleDeg: Int,
)
private fun Int.toRadians() = (this * PI / 180.0)
@@ -22,7 +22,7 @@ private fun Double.yProjection(angleRad: Double) = project(angleRad, ::sin)
private fun PolarCoords.toCartesian() = CartesianCoords(
x = radius.toDouble().xProjection(angleDeg.toRadians()),
- y = radius.toDouble().yProjection(angleDeg.toRadians())
+ y = radius.toDouble().yProjection(angleDeg.toRadians()),
)
// Y-axis is pointing down in the browser, so the directions need to be reversed
@@ -38,7 +38,7 @@ data class RadialConfig(
val radius: Int = 120,
val spreadArcDegrees: Int = 360, // full circle
val firstItemAngleDegrees: Int = 0, // 12 o'clock
- val direction: Direction = Direction.CLOCKWISE
+ val direction: Direction = Direction.CLOCKWISE,
) {
val diameter: Int = radius * 2
}
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/RadialPlayerList.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/RadialPlayerList.kt
index ef1ee612..56d25cb2 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/RadialPlayerList.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/RadialPlayerList.kt
@@ -14,7 +14,7 @@ import styled.styledDiv
import styled.styledH4
fun RBuilder.radialPlayerList(players: List<PlayerDTO>, currentPlayer: PlayerDTO): ReactElement {
- val playerItems = players
+ val playerItems = players //
.map { PlayerItem.Player(it, it.username == currentPlayer.username) }
.growWithPlaceholders(targetSize = 3)
.withUserFirst(currentPlayer)
@@ -31,8 +31,8 @@ fun RBuilder.radialPlayerList(players: List<PlayerDTO>, currentPlayer: PlayerDTO
options = RadialConfig(
radius = 175,
firstItemAngleDegrees = 180, // self at the bottom
- direction = Direction.COUNTERCLOCKWISE // new players sit to the right of last player
- )
+ direction = Direction.COUNTERCLOCKWISE, // new players sit to the right of last player
+ ),
)
}
@@ -73,7 +73,7 @@ private sealed class PlayerItem {
player.isGameOwner -> Icon("badge")
else -> Icon("user")
},
- title = if (player.isGameOwner) "Game owner" else null
+ title = if (player.isGameOwner) "Game owner" else null,
)
}
}
@@ -87,19 +87,18 @@ private sealed class PlayerItem {
userIcon(
isMe = false,
icon = Icon("user"),
- title = "Waiting for player..."
+ title = "Waiting for player...",
)
}
}
}
-private fun RBuilder.userIcon(isMe: Boolean, icon: Icon, title: String?): ReactElement =
- bpIcon(
- name = icon.name,
- intent = if (isMe) Intent.WARNING else Intent.NONE,
- size = 50,
- title = title
- )
+private fun RBuilder.userIcon(isMe: Boolean, icon: Icon, title: String?): ReactElement = bpIcon(
+ name = icon.name,
+ intent = if (isMe) Intent.WARNING else Intent.NONE,
+ size = 50,
+ title = title,
+)
private fun RBuilder.playerElement(playerItem: PlayerItem) {
styledDiv {
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 7eca24b8..97d00ab7 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
@@ -15,7 +15,7 @@ data class SwState(
// they must be by ID to support updates to a sublist
val gamesById: Map<Long, LobbyDTO> = emptyMap(),
val currentLobby: LobbyDTO? = null,
- val gameState: GameState? = null
+ val gameState: GameState? = null,
) {
val currentPlayer: PlayerDTO? = (gameState?.players ?: currentLobby?.players)?.first {
it.username == connectedPlayer?.username
@@ -28,7 +28,7 @@ data class GameState(
val players: List<PlayerDTO>,
val turnInfo: PlayerTurnInfo?,
val preparedCardsByUsername: Map<String, CardBack?> = emptyMap(),
- val currentPreparedMove: PlayerMove? = null
+ val currentPreparedMove: PlayerMove? = null,
) {
val currentPreparedCard: HandCard?
get() = turnInfo?.hand?.firstOrNull { it.name == currentPreparedMove?.cardName }
@@ -38,7 +38,7 @@ fun rootReducer(state: SwState, action: RAction): SwState = state.copy(
gamesById = gamesReducer(state.gamesById, action),
connectedPlayer = currentPlayerReducer(state.connectedPlayer, action),
currentLobby = currentLobbyReducer(state.currentLobby, action),
- gameState = gameStateReducer(state.gameState, action)
+ gameState = gameStateReducer(state.gameState, action),
)
private fun gamesReducer(games: Map<Long, LobbyDTO>, action: RAction): Map<Long, LobbyDTO> = when (action) {
@@ -64,20 +64,22 @@ private fun gameStateReducer(gameState: GameState?, action: RAction): GameState?
is EnterGameAction -> GameState(
id = action.lobby.id,
players = action.lobby.players,
- turnInfo = action.turnInfo
+ turnInfo = action.turnInfo,
)
is PreparedMoveEvent -> gameState?.copy(currentPreparedMove = action.move)
is RequestUnprepareMove -> gameState?.copy(currentPreparedMove = null)
is PreparedCardEvent -> gameState?.copy(
- preparedCardsByUsername = gameState.preparedCardsByUsername + (action.card.username to action.card.cardBack)
+ 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 }
+ 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,
- currentPreparedMove = null
+ currentPreparedMove = null,
)
else -> gameState
}
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Store.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Store.kt
index 9011f389..71c5eec0 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Store.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Store.kt
@@ -22,7 +22,7 @@ private fun <A, T1, R> composeWithDevTools(function1: (T1) -> R, function2: (A)
fun configureStore(
sagaManager: SagaManager<SwState, RAction, WrapperAction>,
- initialState: SwState = INITIAL_STATE
+ initialState: SwState = INITIAL_STATE,
): Store<SwState, RAction, WrapperAction> {
val sagaEnhancer = applyMiddleware(sagaManager.createMiddleware())
return createStore(::rootReducer, initialState, composeWithDevTools(sagaEnhancer, rEnhancer()))
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Utils.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Utils.kt
index 67ac5304..b748c3a5 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Utils.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Utils.kt
@@ -12,7 +12,7 @@ import kotlin.reflect.KClass
inline fun <reified DP : RProps> connectDispatch(
clazz: KClass<out RComponent<DP, out RState>>,
- noinline mapDispatchToProps: DP.((RAction) -> WrapperAction, RProps) -> Unit
+ noinline mapDispatchToProps: DP.((RAction) -> WrapperAction, RProps) -> Unit,
): RClass<RProps> {
val connect = rConnect(mapDispatchToProps = mapDispatchToProps)
return connect.invoke(clazz.js.unsafeCast<RClass<DP>>())
@@ -20,7 +20,7 @@ inline fun <reified DP : RProps> connectDispatch(
inline fun <reified SP : RProps> connectState(
clazz: KClass<out RComponent<SP, out RState>>,
- noinline mapStateToProps: SP.(SwState, RProps) -> Unit
+ noinline mapStateToProps: SP.(SwState, RProps) -> Unit,
): RClass<RProps> {
val connect = rConnect(mapStateToProps = mapStateToProps)
return connect.invoke(clazz.js.unsafeCast<RClass<SP>>())
@@ -29,11 +29,11 @@ inline fun <reified SP : RProps> connectState(
inline fun <reified SP : RProps, reified DP : RProps, reified P : RProps> connectStateAndDispatch(
clazz: KClass<out RComponent<P, out RState>>,
noinline mapStateToProps: SP.(SwState, RProps) -> Unit,
- noinline mapDispatchToProps: DP.((RAction) -> WrapperAction, RProps) -> Unit
+ noinline mapDispatchToProps: DP.((RAction) -> WrapperAction, RProps) -> Unit,
): RClass<RProps> {
val connect = rConnect<SwState, RAction, WrapperAction, RProps, SP, DP, P>(
mapStateToProps = mapStateToProps,
- mapDispatchToProps = mapDispatchToProps
+ mapDispatchToProps = mapDispatchToProps,
)
return connect.invoke(clazz.js.unsafeCast<RClass<P>>())
}
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/GameBrowserSagas.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/GameBrowserSagas.kt
index aa81ae55..b6f3662a 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/GameBrowserSagas.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/GameBrowserSagas.kt
@@ -20,7 +20,7 @@ suspend fun SwSagaContext.gameBrowserSaga(session: SevenWondersSession) {
private class GameBrowserSaga(
private val session: SevenWondersSession,
- private val sagaContext: SwSagaContext
+ private val sagaContext: SwSagaContext,
) {
suspend fun run() {
coroutineScope {
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/GameSagas.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/GameSagas.kt
index b9f456e5..fb9bdfe2 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/GameSagas.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/GameSagas.kt
@@ -4,7 +4,14 @@ import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
import org.luxons.sevenwonders.client.SevenWondersSession
-import org.luxons.sevenwonders.ui.redux.*
+import org.luxons.sevenwonders.ui.redux.PlayerReadyEvent
+import org.luxons.sevenwonders.ui.redux.PreparedCardEvent
+import org.luxons.sevenwonders.ui.redux.PreparedMoveEvent
+import org.luxons.sevenwonders.ui.redux.RequestLeaveGame
+import org.luxons.sevenwonders.ui.redux.RequestPrepareMove
+import org.luxons.sevenwonders.ui.redux.RequestSayReady
+import org.luxons.sevenwonders.ui.redux.RequestUnprepareMove
+import org.luxons.sevenwonders.ui.redux.TurnInfoEvent
import org.luxons.sevenwonders.ui.router.Navigate
import org.luxons.sevenwonders.ui.router.Route
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/LobbySagas.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/LobbySagas.kt
index 044f8e78..37872017 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/LobbySagas.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/LobbySagas.kt
@@ -4,7 +4,13 @@ import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
import org.luxons.sevenwonders.client.SevenWondersSession
-import org.luxons.sevenwonders.ui.redux.*
+import org.luxons.sevenwonders.ui.redux.EnterGameAction
+import org.luxons.sevenwonders.ui.redux.RequestAddBot
+import org.luxons.sevenwonders.ui.redux.RequestLeaveLobby
+import org.luxons.sevenwonders.ui.redux.RequestReassignWonders
+import org.luxons.sevenwonders.ui.redux.RequestReorderPlayers
+import org.luxons.sevenwonders.ui.redux.RequestStartGame
+import org.luxons.sevenwonders.ui.redux.UpdateLobbyAction
import org.luxons.sevenwonders.ui.router.Navigate
import org.luxons.sevenwonders.ui.router.Route
import org.luxons.sevenwonders.ui.utils.awaitFirst
@@ -12,9 +18,7 @@ import org.luxons.sevenwonders.ui.utils.awaitFirst
suspend fun SwSagaContext.lobbySaga(session: SevenWondersSession) {
val lobby = getState().currentLobby ?: error("Lobby saga run without a current lobby")
coroutineScope {
- val lobbyUpdatesSubscription = session.watchLobbyUpdates()
- .map { UpdateLobbyAction(it) }
- .dispatchAllIn(this)
+ val lobbyUpdatesSubscription = session.watchLobbyUpdates().map { UpdateLobbyAction(it) }.dispatchAllIn(this)
launch {
onEach<RequestAddBot> { session.addBot(it.botDisplayName) }
@@ -39,7 +43,7 @@ suspend fun SwSagaContext.lobbySaga(session: SevenWondersSession) {
lobbyUpdatesSubscription.cancel()
startGameJob.cancel()
dispatch(Navigate(Route.GAME))
- }
+ },
)
}
}
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/SagasFramework.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/SagasFramework.kt
index df00f43f..3acf68e8 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/SagasFramework.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/SagasFramework.kt
@@ -15,7 +15,7 @@ import redux.RAction
@OptIn(ExperimentalCoroutinesApi::class)
class SagaManager<S, A : RAction, R>(
- private val monitor: ((A) -> Unit)? = null
+ private val monitor: ((A) -> Unit)? = null,
) {
private lateinit var context: SagaContext<S, A, R>
@@ -65,7 +65,7 @@ class SagaManager<S, A : RAction, R>(
@OptIn(FlowPreview::class, ExperimentalCoroutinesApi::class)
class SagaContext<S, A : RAction, R>(
private val reduxApi: MiddlewareApi<S, A, R>,
- private val actions: BroadcastChannel<A>
+ private val actions: BroadcastChannel<A>,
) {
/**
* Gets the current redux state.
@@ -112,7 +112,7 @@ class SagaContext<S, A : RAction, R>(
* cancelled.
*/
suspend inline fun <reified T : A> onEach(
- crossinline handle: suspend SagaContext<S, A, R>.(T) -> Unit
+ crossinline handle: suspend SagaContext<S, A, R>.(T) -> Unit,
) = onEach {
if (it is T) {
handle(it)
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/router/Router.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/router/Router.kt
index 3a22b1ed..b5dcb978 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/router/Router.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/router/Router.kt
@@ -18,7 +18,7 @@ data class Navigate(val route: Route) : RAction
suspend fun SwSagaContext.routerSaga(
startRoute: Route,
- runRouteSaga: suspend SwSagaContext.(Route) -> Unit
+ runRouteSaga: suspend SwSagaContext.(Route) -> Unit,
) {
coroutineScope {
window.location.hash = startRoute.path
diff --git a/sw-ui/src/main/resources/index.html b/sw-ui/src/main/resources/index.html
index d4fba7e6..304be751 100644
--- a/sw-ui/src/main/resources/index.html
+++ b/sw-ui/src/main/resources/index.html
@@ -7,10 +7,10 @@
<title>Seven Wonders</title>
<link href='https://fonts.googleapis.com/css2?family=Acme&display=swap' rel='stylesheet'>
<!-- Style dependencies -->
- <link href="https://unpkg.com/normalize.css@^7.0.0" rel="stylesheet" />
+ <link href="https://unpkg.com/normalize.css@^7.0.0" rel="stylesheet"/>
<!-- Blueprint stylesheets -->
- <link href="https://unpkg.com/@blueprintjs/icons@^3.4.0/lib/css/blueprint-icons.css" rel="stylesheet" />
- <link href="https://unpkg.com/@blueprintjs/core@^3.10.0/lib/css/blueprint.css" rel="stylesheet" />
+ <link href="https://unpkg.com/@blueprintjs/icons@^3.4.0/lib/css/blueprint-icons.css" rel="stylesheet"/>
+ <link href="https://unpkg.com/@blueprintjs/core@^3.10.0/lib/css/blueprint.css" rel="stylesheet"/>
</head>
<body>
<div id="root"></div>
diff --git a/sw-ui/src/test/kotlin/org/luxons/sevenwonders/ui/redux/sagas/SagasFrameworkTest.kt b/sw-ui/src/test/kotlin/org/luxons/sevenwonders/ui/redux/sagas/SagasFrameworkTest.kt
index fd23039c..f580fc93 100644
--- a/sw-ui/src/test/kotlin/org/luxons/sevenwonders/ui/redux/sagas/SagasFrameworkTest.kt
+++ b/sw-ui/src/test/kotlin/org/luxons/sevenwonders/ui/redux/sagas/SagasFrameworkTest.kt
@@ -36,7 +36,7 @@ private fun configureTestStore(initialState: State): TestRedux {
private data class TestRedux(
val store: Store<State, RAction, WrapperAction>,
- val sagas: SagaManager<State, RAction, WrapperAction>
+ val sagas: SagaManager<State, RAction, WrapperAction>,
)
@OptIn(ExperimentalCoroutinesApi::class)
diff --git a/sw-ui/src/test/kotlin/org/luxons/sevenwonders/ui/utils/CoroutineUtilsTest.kt b/sw-ui/src/test/kotlin/org/luxons/sevenwonders/ui/utils/CoroutineUtilsTest.kt
index d633f6f2..ba43c33f 100644
--- a/sw-ui/src/test/kotlin/org/luxons/sevenwonders/ui/utils/CoroutineUtilsTest.kt
+++ b/sw-ui/src/test/kotlin/org/luxons/sevenwonders/ui/utils/CoroutineUtilsTest.kt
@@ -12,12 +12,12 @@ class CoroutineUtilsTest {
fun awaitFirstTest(): dynamic = GlobalScope.promise {
val s = awaitFirst(
{ delay(100); "1" },
- { delay(200); "2" }
+ { delay(200); "2" },
)
assertEquals("1", s)
val s2 = awaitFirst(
{ delay(150); "1" },
- { delay(50); "2" }
+ { delay(50); "2" },
)
assertEquals("2", s2)
}
bgstack15