summaryrefslogtreecommitdiff
path: root/sw-ui/src/main/kotlin/org/luxons
diff options
context:
space:
mode:
authorjoffrey-bion <joffrey.bion@gmail.com>2021-02-11 01:31:19 +0100
committerjoffrey-bion <joffrey.bion@gmail.com>2021-02-11 01:38:14 +0100
commit3d0d4b1c12d8805f2dc4e641969966ec48b557cb (patch)
tree4f48b7da2f793e663d438f7b62e794c264f15d03 /sw-ui/src/main/kotlin/org/luxons
parentFix text inputs (diff)
downloadseven-wonders-3d0d4b1c12d8805f2dc4e641969966ec48b557cb.tar.gz
seven-wonders-3d0d4b1c12d8805f2dc4e641969966ec48b557cb.tar.bz2
seven-wonders-3d0d4b1c12d8805f2dc4e641969966ec48b557cb.zip
Make screen pulse red when everyone is waiting
Resolves: https://github.com/joffrey-bion/seven-wonders/issues/109
Diffstat (limited to 'sw-ui/src/main/kotlin/org/luxons')
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameScene.kt12
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameStyles.kt13
-rw-r--r--sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Reducers.kt1
3 files changed, 26 insertions, 0 deletions
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 2dd6135a..9c1c852a 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
@@ -57,6 +57,9 @@ private class GameScene(props: GameSceneProps) : RComponent<GameSceneProps, RSta
styledDiv {
css {
height = 100.pct
+ if (turnInfo.everyoneIsWaitingForMe()) {
+ +GameStyles.pulsatingRed
+ }
}
turnInfo.scoreBoard?.let {
scoreTableOverlay(it, props.players, props.leaveGame)
@@ -90,6 +93,15 @@ private class GameScene(props: GameSceneProps) : RComponent<GameSceneProps, RSta
}
}
+ private fun PlayerTurnInfo.everyoneIsWaitingForMe(): Boolean {
+ val onlyMeInTheGame = props.players.count { it.isHuman } == 1
+ if (onlyMeInTheGame || preparedMove != null) {
+ return false
+ }
+ val gameState = props.gameState ?: return false
+ return gameState.preparedCardsByUsername.values.count { it != null } == props.players.size - 1
+ }
+
private fun playerNeighbours(): Pair<PlayerDTO, PlayerDTO> {
val me = props.currentPlayer?.username ?: error("we shouldn't be trying to display this if there is no player")
val players = props.players
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameStyles.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameStyles.kt
index 443396d1..92445764 100644
--- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameStyles.kt
+++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameStyles.kt
@@ -3,6 +3,7 @@ package org.luxons.sevenwonders.ui.components.game
import kotlinx.css.*
import kotlinx.css.properties.*
import styled.StyleSheet
+import styled.animation
object GameStyles : StyleSheet("GameStyles", isStatic = true) {
@@ -84,4 +85,16 @@ object GameStyles : StyleSheet("GameStyles", isStatic = true) {
private fun scoreTagColorCss(color: Color) = css {
backgroundColor = color
}
+
+ val pulsatingRed by css {
+ animation(
+ duration = 2.s,
+ iterationCount = IterationCount.infinite,
+ direction = AnimationDirection.alternate,
+ ) {
+ to {
+ boxShadowInset(color = Color.red, blurRadius = 20.px, spreadRadius = 8.px)
+ }
+ }
+ }
}
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 61d7a60c..91dbf61f 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
@@ -95,6 +95,7 @@ private fun gameStateReducer(gameState: GameState?, action: RAction): GameState?
is TurnInfoEvent -> gameState?.copy(
players = gameState.players.map { p -> p.copy(isReady = false) },
turnInfo = action.turnInfo,
+ preparedCardsByUsername = emptyMap(),
currentPreparedMove = null,
)
is StartTransactionSelection -> gameState?.copy(transactionSelector = action.transactionSelector)
bgstack15