diff options
author | Joffrey Bion <joffrey.bion@booking.com> | 2020-05-23 02:03:55 +0200 |
---|---|---|
committer | Joffrey Bion <joffrey.bion@booking.com> | 2020-05-23 02:03:55 +0200 |
commit | 8c15e4c7e3a41caef24e93885f1600903f358078 (patch) | |
tree | 0977b65a606097482ae917466d184d288d24cf11 /sw-ui/src/main/kotlin/org | |
parent | Add score board UI at end of game (diff) | |
download | seven-wonders-8c15e4c7e3a41caef24e93885f1600903f358078.tar.gz seven-wonders-8c15e4c7e3a41caef24e93885f1600903f358078.tar.bz2 seven-wonders-8c15e4c7e3a41caef24e93885f1600903f358078.zip |
Add "leave game" feature for end of game
Diffstat (limited to 'sw-ui/src/main/kotlin/org')
-rw-r--r-- | sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/sagas/GameSagas.kt | 14 |
1 files changed, 6 insertions, 8 deletions
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<RequestPrepareMove> { session.prepareMove(it.move) } } launch { onEach<RequestUnprepareMove> { session.unprepareMove() } } - // TODO await game end and cancel this scope to unsubscribe everything + next<RequestLeaveGame>() + session.leaveGame() + dispatch(Navigate(Route.GAME_BROWSER)) } console.log("End of game saga") } |