diff options
3 files changed, 4 insertions, 7 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 bd6e300e..47e01876 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 @@ -153,6 +153,8 @@ class GameController( synchronized(game) { lobby.removePlayer(player.username) logger.info("Game {}: player {} left the game", game.id, player) + template.convertAndSendToUser(player.username, "/queue/lobby/left", lobby.id) + // This could cause problems if the humans are faster than bots to leave a finished game, // but this case should be quite rare, so it does not matter much if (lobby.getPlayers().none { it.isHuman }) { 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 b1d730a0..61d7a60c 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 @@ -100,6 +100,7 @@ private fun gameStateReducer(gameState: GameState?, action: RAction): GameState? is StartTransactionSelection -> gameState?.copy(transactionSelector = action.transactionSelector) is CancelTransactionSelection -> gameState?.copy(transactionSelector = null) is RequestPrepareMove -> gameState?.copy(transactionSelector = null) + is LeaveLobbyAction -> null else -> gameState } diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/Sagas.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/Sagas.kt index 4e196afb..53ade155 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/Sagas.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/Sagas.kt @@ -87,12 +87,12 @@ private fun SwSagaContext.launchApiActionHandlersIn(scope: CoroutineScope, sessi scope.launchOnEach<RequestAddBot> { session.addBot(it.botDisplayName) } scope.launchOnEach<RequestReorderPlayers> { session.reorderPlayers(it.orderedPlayers) } scope.launchOnEach<RequestReassignWonders> { session.reassignWonders(it.wonders) } - // mapAction<RequestUpdateSettings> { updateSettings(it.settings) } scope.launchOnEach<RequestStartGame> { session.startGame() } scope.launchOnEach<RequestSayReady> { session.sayReady() } scope.launchOnEach<RequestPrepareMove> { session.prepareMove(it.move) } scope.launchOnEach<RequestUnprepareMove> { session.unprepareMove() } + scope.launchOnEach<RequestLeaveGame> { session.leaveGame() } } private fun SwSagaContext.launchApiEventHandlersIn(scope: CoroutineScope, session: SevenWondersSession) { @@ -118,10 +118,4 @@ private fun SwSagaContext.launchApiEventHandlersIn(scope: CoroutineScope, sessio dispatch(Navigate(Route.GAME)) } } - - // FIXME map this actions like others and await server event instead - scope.launchOnEach<RequestLeaveGame> { - session.leaveGame() - dispatch(Navigate(Route.GAME_BROWSER)) - } } |