From 53cdfdfd3d7f4a8fed08ee475b2d5936155f6875 Mon Sep 17 00:00:00 2001 From: Joffrey Bion Date: Thu, 20 Aug 2020 15:36:49 +0200 Subject: Fix style & sort imports --- .../sevenwonders/ui/components/game/GameScene.kt | 32 +++++++++++----------- .../luxons/sevenwonders/ui/components/game/Hand.kt | 12 +++++--- .../org/luxons/sevenwonders/ui/redux/ApiActions.kt | 2 +- .../org/luxons/sevenwonders/ui/redux/Reducers.kt | 10 +++---- 4 files changed, 29 insertions(+), 27 deletions(-) (limited to 'sw-ui/src/main/kotlin') diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameScene.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameScene.kt index 778fe9d7..3545113b 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameScene.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameScene.kt @@ -214,19 +214,19 @@ private class GameScene(props: GameSceneProps) : RComponent = - connectStateAndDispatch( - clazz = GameScene::class, - mapDispatchToProps = { dispatch, _ -> - prepareMove = { move -> dispatch(RequestPrepareMove(move)) } - unprepareMove = { dispatch(RequestUnprepareMove()) } - sayReady = { dispatch(RequestSayReady()) } - leaveGame = { dispatch(RequestLeaveGame()) } - }, - mapStateToProps = { state, _ -> - playerIsReady = state.currentPlayer?.isReady == true - players = state.gameState?.players ?: emptyList() - gameState = state.gameState - preparedMove = state.gameState?.currentPreparedMove - preparedCard = state.gameState?.currentPreparedCard - } - ) + connectStateAndDispatch( + clazz = GameScene::class, + mapDispatchToProps = { dispatch, _ -> + prepareMove = { move -> dispatch(RequestPrepareMove(move)) } + unprepareMove = { dispatch(RequestUnprepareMove()) } + sayReady = { dispatch(RequestSayReady()) } + leaveGame = { dispatch(RequestLeaveGame()) } + }, + mapStateToProps = { state, _ -> + playerIsReady = state.currentPlayer?.isReady == true + players = state.gameState?.players ?: emptyList() + gameState = state.gameState + preparedMove = state.gameState?.currentPreparedMove + preparedCard = state.gameState?.currentPreparedCard + } + ) diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Hand.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Hand.kt index 17365bdd..315e25e8 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Hand.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Hand.kt @@ -112,14 +112,16 @@ class HandComponent(props: HandProps) : RComponent(props) { } private fun RElementBuilder.playCardButton(card: HandCard, handAction: HandAction) { - bpButton(title = "${handAction.buttonTitle} (${cardPlayabilityInfo(card.playability)})", + bpButton( + title = "${handAction.buttonTitle} (${cardPlayabilityInfo(card.playability)})", large = true, intent = Intent.SUCCESS, disabled = !card.playability.isPlayable, onClick = { val transactions = card.playability.cheapestTransactions.first() props.prepareMove(PlayerMove(handAction.moveType, card.name, transactions)) - }) { + } + ) { bpIcon(handAction.icon) if (card.playability.isPlayable && !card.playability.isFree) { priceInfo(card.playability.minPrice) @@ -129,14 +131,16 @@ class HandComponent(props: HandProps) : RComponent(props) { private fun RElementBuilder.upgradeWonderButton(card: HandCard) { val wonderBuildability = props.turnInfo.wonderBuildability - bpButton(title = "UPGRADE WONDER (${wonderBuildabilityInfo(wonderBuildability)})", + bpButton( + title = "UPGRADE WONDER (${wonderBuildabilityInfo(wonderBuildability)})", large = true, intent = Intent.PRIMARY, disabled = !wonderBuildability.isBuildable, onClick = { val transactions = wonderBuildability.cheapestTransactions.first() props.prepareMove(PlayerMove(MoveType.UPGRADE_WONDER, card.name, transactions)) - }) { + } + ) { bpIcon("key-shift") if (wonderBuildability.isBuildable && !wonderBuildability.isFree) { priceInfo(wonderBuildability.minPrice) diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/ApiActions.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/ApiActions.kt index 53cdeaf4..d259da81 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/ApiActions.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/ApiActions.kt @@ -1,7 +1,7 @@ package org.luxons.sevenwonders.ui.redux -import org.luxons.sevenwonders.model.Settings import org.luxons.sevenwonders.model.PlayerMove +import org.luxons.sevenwonders.model.Settings import org.luxons.sevenwonders.model.wonders.AssignedWonder import redux.RAction diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Reducers.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Reducers.kt index 047e948a..7eca24b8 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Reducers.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Reducers.kt @@ -55,9 +55,7 @@ private fun currentLobbyReducer(currentLobby: LobbyDTO?, action: RAction): Lobby is EnterLobbyAction -> action.lobby is UpdateLobbyAction -> action.lobby is PlayerReadyEvent -> currentLobby?.let { l -> - l.copy(players = l.players.map { p -> - if (p.username == action.username) p.copy(isReady = true) else p - }) + l.copy(players = l.players.map { p -> if (p.username == action.username) p.copy(isReady = true) else p }) } else -> currentLobby } @@ -73,9 +71,9 @@ private fun gameStateReducer(gameState: GameState?, action: RAction): GameState? is PreparedCardEvent -> gameState?.copy( preparedCardsByUsername = gameState.preparedCardsByUsername + (action.card.username to action.card.cardBack) ) - is PlayerReadyEvent -> gameState?.copy(players = gameState.players.map { p -> - if (p.username == action.username) p.copy(isReady = true) else p - }) + is PlayerReadyEvent -> gameState?.copy( + players = gameState.players.map { p -> if (p.username == action.username) p.copy(isReady = true) else p } + ) is TurnInfoEvent -> gameState?.copy( players = gameState.players.map { p -> p.copy(isReady = false) }, turnInfo = action.turnInfo, -- cgit