diff options
author | Joffrey Bion <joffrey.bion@booking.com> | 2020-05-26 10:20:02 +0200 |
---|---|---|
committer | Joffrey Bion <joffrey.bion@booking.com> | 2020-05-26 10:20:02 +0200 |
commit | 27e7e39608987f6d354b0c9c52eee10e1fa31ba2 (patch) | |
tree | afd1fcdf745cbd51d1f324230e95be03e68b7041 | |
parent | Make bots explore more by choosing random cards instead of first (diff) | |
download | seven-wonders-27e7e39608987f6d354b0c9c52eee10e1fa31ba2.tar.gz seven-wonders-27e7e39608987f6d354b0c9c52eee10e1fa31ba2.tar.bz2 seven-wonders-27e7e39608987f6d354b0c9c52eee10e1fa31ba2.zip |
Fix race condition bewteen next turn and prepared move
Resolves:
https://github.com/joffrey-bion/seven-wonders/issues/24
-rw-r--r-- | sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/GameController.kt | 6 | ||||
-rw-r--r-- | sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Reducers.kt | 3 |
2 files changed, 5 insertions, 4 deletions
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 dc5dffdb..e86e7b54 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 @@ -62,8 +62,7 @@ class GameController( * the connected user's information */ @MessageMapping("/game/prepareMove") - @SendToUser("/queue/game/preparedMove") - fun prepareMove(action: PrepareMoveAction, principal: Principal): PlayerMove { + fun prepareMove(action: PrepareMoveAction, principal: Principal) { val player = principal.player val game = player.game val preparedCardBack = game.prepareMove(player.index, action.move) @@ -78,8 +77,9 @@ class GameController( if (game.endOfGameReached()) { player.lobby.setEndOfGame() } + } else { + template.convertAndSendToUser(player.username, "/queue/game/preparedMove", action.move) } - return action.move } @MessageMapping("/game/unprepareMove") 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 c21f6deb..1ff0d0ec 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 @@ -78,7 +78,8 @@ private fun gameStateReducer(gameState: GameState?, action: RAction): GameState? }) is TurnInfoEvent -> gameState?.copy( players = gameState.players.map { p -> p.copy(isReady = false) }, - turnInfo = action.turnInfo + turnInfo = action.turnInfo, + currentPreparedMove = null ) else -> gameState } |