From 7c2371766b940742f3986d7904d4c20a4127ea70 Mon Sep 17 00:00:00 2001 From: joffrey-bion Date: Wed, 3 Feb 2021 02:37:38 +0100 Subject: Add auto-game with bots only Resolves: https://github.com/joffrey-bion/seven-wonders/issues/82 --- .../org/luxons/sevenwonders/server/SevenWondersTest.kt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'sw-server/src/test') diff --git a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/SevenWondersTest.kt b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/SevenWondersTest.kt index 02f43fcf..7c830140 100644 --- a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/SevenWondersTest.kt +++ b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/SevenWondersTest.kt @@ -9,6 +9,7 @@ import kotlinx.coroutines.withTimeoutOrNull import org.junit.runner.RunWith import org.luxons.sevenwonders.client.SevenWondersClient import org.luxons.sevenwonders.client.SevenWondersSession +import org.luxons.sevenwonders.client.createGameAndWaitLobby import org.luxons.sevenwonders.client.joinGameAndWaitLobby import org.luxons.sevenwonders.model.Action import org.luxons.sevenwonders.model.api.GameListEvent @@ -60,7 +61,7 @@ class SevenWondersTest { val session2 = newPlayer("Player2") val gameName = "Test Game" - val lobby = ownerSession.createGameAndWaitLobby(gameName) + val lobby = ownerSession.createGameWithLegacySettingsAndWaitLobby(gameName) session1.joinGameAndWaitLobby(lobby.id) session2.joinGameAndWaitLobby(lobby.id) @@ -80,7 +81,7 @@ class SevenWondersTest { val ownerSession = newPlayer("GameOwner") val gameName = "Test Game" - val lobby = ownerSession.createGameAndWaitLobby(gameName) + val lobby = ownerSession.createGameWithLegacySettingsAndWaitLobby(gameName) assertEquals(gameName, lobby.name) disconnect(ownerSession) @@ -97,7 +98,7 @@ class SevenWondersTest { val ownerSession = newPlayer("GameOwner") val gameName = "Test Game" - val createdLobby = ownerSession.createGameAndWaitLobby(gameName) + val createdLobby = ownerSession.createGameWithLegacySettingsAndWaitLobby(gameName) val afterGameListEvent = withTimeout(500) { games.receive() } assertTrue(afterGameListEvent is GameListEvent.CreateOrUpdate) @@ -114,7 +115,7 @@ class SevenWondersTest { val session2 = newPlayer("Player2") val startEvents1 = session1.watchGameStarted() - val lobby = session1.createGameAndWaitLobby("Test Game") + val lobby = session1.createGameWithLegacySettingsAndWaitLobby("Test Game") val startEvents2 = session2.watchGameStarted() session2.joinGameAndWaitLobby(lobby.id) @@ -146,10 +147,8 @@ class SevenWondersTest { } } -private suspend fun SevenWondersSession.createGameAndWaitLobby(gameName: String): LobbyDTO { - val joinedLobbies = watchLobbyJoined() - createGame(gameName) - val lobby = joinedLobbies.first() +private suspend fun SevenWondersSession.createGameWithLegacySettingsAndWaitLobby(gameName: String): LobbyDTO { + val lobby = createGameAndWaitLobby(gameName) updateSettings(lobby.settings.copy(askForReadiness = true)) return lobby } -- cgit