summaryrefslogtreecommitdiff
path: root/sw-server
diff options
context:
space:
mode:
Diffstat (limited to 'sw-server')
-rw-r--r--sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/AutoGameController.kt4
-rw-r--r--sw-server/src/test/kotlin/org/luxons/sevenwonders/server/SevenWondersTest.kt13
2 files changed, 11 insertions, 6 deletions
diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/AutoGameController.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/AutoGameController.kt
index a4aceb96..b6d66e4b 100644
--- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/AutoGameController.kt
+++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/AutoGameController.kt
@@ -5,6 +5,7 @@ import kotlinx.coroutines.withTimeout
import org.luxons.sevenwonders.bot.connectBot
import org.luxons.sevenwonders.bot.connectBots
import org.luxons.sevenwonders.client.SevenWondersClient
+import org.luxons.sevenwonders.model.TurnAction
import org.luxons.sevenwonders.model.api.AutoGameAction
import org.luxons.sevenwonders.model.api.AutoGameResult
import org.slf4j.LoggerFactory
@@ -48,7 +49,8 @@ class AutoGameController(
lastTurn
}
- val scoreBoard = lastTurn.scoreBoard ?: error("Last turn info doesn't have scoreboard")
+ val turnAction = lastTurn.action as? TurnAction.WatchScore ?: error("Last turn action should be to watch the score")
+ val scoreBoard = turnAction.scoreBoard
return AutoGameResult(scoreBoard, lastTurn.table)
}
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 df40b93d..7f05688b 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
@@ -7,7 +7,7 @@ import kotlinx.coroutines.withTimeout
import kotlinx.coroutines.withTimeoutOrNull
import org.junit.runner.RunWith
import org.luxons.sevenwonders.client.*
-import org.luxons.sevenwonders.model.Action
+import org.luxons.sevenwonders.model.TurnAction
import org.luxons.sevenwonders.model.api.GameListEvent
import org.luxons.sevenwonders.model.api.LobbyDTO
import org.luxons.sevenwonders.server.test.runAsyncTest
@@ -15,7 +15,10 @@ import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment
import org.springframework.boot.web.server.LocalServerPort
import org.springframework.test.context.junit4.SpringRunner
-import kotlin.test.*
+import kotlin.test.Test
+import kotlin.test.assertEquals
+import kotlin.test.assertNull
+import kotlin.test.assertTrue
@RunWith(SpringRunner::class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@@ -129,13 +132,13 @@ class SevenWondersTest {
).forEach { (session, startEvents) ->
launch {
val initialReadyTurn = startEvents.first()
- assertEquals(Action.SAY_READY, initialReadyTurn.action)
- assertNull(initialReadyTurn.hand)
+ assertTrue(initialReadyTurn.action is TurnAction.SayReady)
val turns = session.watchTurns()
session.sayReady()
val firstActualTurn = turns.first()
- assertNotNull(firstActualTurn.hand)
+ val action = firstActualTurn.action
+ assertTrue(action is TurnAction.PlayFromHand)
session.disconnect()
}
}
bgstack15