Skip to content

Commit de22d23

Browse files
committed
test(plugin): adjust to game ending only after round
1 parent c63c690 commit de22d23

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

plugin/src/test/kotlin/sc/plugin2022/GameTest.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package sc.plugin2022
22

3+
import io.kotest.assertions.throwables.shouldThrow
34
import io.kotest.core.spec.style.FunSpec
45
import io.kotest.matchers.shouldBe
56
import sc.api.plugins.Team
67
import sc.plugin2022.util.WinReason
8+
import sc.shared.InvalidMoveException
79
import sc.shared.WinCondition
810
import java.util.EnumMap
911

@@ -13,14 +15,26 @@ class GameTest: FunSpec({
1315
val game = Game(GameState(
1416
makeBoard(6 y 6 to "H", 2 y 1 to "s"), 1,
1517
ambers = fullAmbers()))
18+
game.checkWinCondition() shouldBe null
19+
game.currentState.turn++
1620
game.checkWinCondition() shouldBe WinCondition(Team.ONE, WinReason.DIFFERING_POSITIONS)
21+
1722
val move = Move(2 y 1, 1 y 1)
1823
val state = game.currentState
24+
shouldThrow<InvalidMoveException> {
25+
state.performMove(move)
26+
}
27+
game.currentState.turn++
1928
state.performMove(move)
2029
state.lastMove shouldBe move
2130
game.checkWinCondition() shouldBe WinCondition(null, WinReason.EQUAL_SCORE)
31+
2232
state.performMove(Move(6 y 6, 7 y 7))
33+
game.checkWinCondition() shouldBe null
34+
game.currentState.turn++
2335
game.checkWinCondition() shouldBe WinCondition(Team.ONE, WinReason.DIFFERING_SCORES)
36+
game.currentState.turn++
37+
2438
state.performMove(Move(1 y 1, 0 y 2))
2539
game.checkWinCondition() shouldBe WinCondition(null, WinReason.EQUAL_SCORE)
2640

0 commit comments

Comments
 (0)