diff options
author | joffrey-bion <joffrey.bion@gmail.com> | 2020-12-12 16:18:28 +0100 |
---|---|---|
committer | joffrey-bion <joffrey.bion@gmail.com> | 2020-12-12 16:18:28 +0100 |
commit | 71f2fc4f25bdfdeac7db9b8e62144c3110e3bf6a (patch) | |
tree | d8a88a126c74d3a36177980be4259b1a173fa1aa /sw-bot/src/main/kotlin/org/luxons | |
parent | Fix race in blinking test (diff) | |
download | seven-wonders-71f2fc4f25bdfdeac7db9b8e62144c3110e3bf6a.tar.gz seven-wonders-71f2fc4f25bdfdeac7db9b8e62144c3110e3bf6a.tar.bz2 seven-wonders-71f2fc4f25bdfdeac7db9b8e62144c3110e3bf6a.zip |
Fix race conditions for game start and tests
Resolves:
https://github.com/joffrey-bion/seven-wonders/issues/70
Diffstat (limited to 'sw-bot/src/main/kotlin/org/luxons')
-rw-r--r-- | sw-bot/src/main/kotlin/org/luxons/sevenwonders/bot/SevenWondersBot.kt | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/sw-bot/src/main/kotlin/org/luxons/sevenwonders/bot/SevenWondersBot.kt b/sw-bot/src/main/kotlin/org/luxons/sevenwonders/bot/SevenWondersBot.kt index 87ba7983..6170acb8 100644 --- a/sw-bot/src/main/kotlin/org/luxons/sevenwonders/bot/SevenWondersBot.kt +++ b/sw-bot/src/main/kotlin/org/luxons/sevenwonders/bot/SevenWondersBot.kt @@ -2,10 +2,7 @@ package org.luxons.sevenwonders.bot import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.delay -import kotlinx.coroutines.flow.collect -import kotlinx.coroutines.flow.onCompletion -import kotlinx.coroutines.flow.onStart -import kotlinx.coroutines.flow.takeWhile +import kotlinx.coroutines.flow.* import kotlinx.coroutines.withTimeout import org.luxons.sevenwonders.client.SevenWondersClient import org.luxons.sevenwonders.client.SevenWondersSession @@ -38,8 +35,9 @@ class SevenWondersBot( suspend fun play(serverUrl: String, gameId: Long) = withTimeout(botConfig.globalTimeout) { val session = client.connect(serverUrl) session.chooseName(displayName, Icon("desktop")) + val gameStartedEvents = session.watchGameStarted() session.joinGameAndWaitLobby(gameId) - val firstTurn = session.awaitGameStart(gameId) + val firstTurn = gameStartedEvents.first() session.watchTurns() .onStart { emit(firstTurn) } |