From 8c15e4c7e3a41caef24e93885f1600903f358078 Mon Sep 17 00:00:00 2001 From: Joffrey Bion Date: Sat, 23 May 2020 02:03:55 +0200 Subject: Add "leave game" feature for end of game --- .../org/luxons/sevenwonders/ui/redux/sagas/GameSagas.kt | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'sw-ui') 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 48592778..b9f456e5 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,13 +4,9 @@ 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.PlayerReadyEvent -import org.luxons.sevenwonders.ui.redux.PreparedCardEvent -import org.luxons.sevenwonders.ui.redux.PreparedMoveEvent -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.redux.* +import org.luxons.sevenwonders.ui.router.Navigate +import org.luxons.sevenwonders.ui.router.Route suspend fun SwSagaContext.gameSaga(session: SevenWondersSession) { val game = getState().gameState ?: error("Game saga run without a current game") @@ -24,7 +20,9 @@ suspend fun SwSagaContext.gameSaga(session: SevenWondersSession) { launch { onEach { session.prepareMove(it.move) } } launch { onEach { session.unprepareMove() } } - // TODO await game end and cancel this scope to unsubscribe everything + next() + session.leaveGame() + dispatch(Navigate(Route.GAME_BROWSER)) } console.log("End of game saga") } -- cgit