1
1
package sc.plugin2022
2
2
3
+ import io.kotest.assertions.throwables.shouldThrow
3
4
import io.kotest.core.spec.style.FunSpec
4
5
import io.kotest.matchers.shouldBe
5
6
import sc.api.plugins.Team
6
7
import sc.plugin2022.util.WinReason
8
+ import sc.shared.InvalidMoveException
7
9
import sc.shared.WinCondition
8
10
import java.util.EnumMap
9
11
@@ -13,14 +15,26 @@ class GameTest: FunSpec({
13
15
val game = Game (GameState (
14
16
makeBoard(6 y 6 to "H ", 2 y 1 to "s"), 1,
15
17
ambers = fullAmbers()))
18
+ game.checkWinCondition() shouldBe null
19
+ game.currentState.turn++
16
20
game.checkWinCondition() shouldBe WinCondition (Team .ONE , WinReason .DIFFERING_POSITIONS )
21
+
17
22
val move = Move (2 y 1, 1 y 1)
18
23
val state = game.currentState
24
+ shouldThrow<InvalidMoveException > {
25
+ state.performMove(move)
26
+ }
27
+ game.currentState.turn++
19
28
state.performMove(move)
20
29
state.lastMove shouldBe move
21
30
game.checkWinCondition() shouldBe WinCondition (null, WinReason .EQUAL_SCORE )
31
+
22
32
state.performMove(Move (6 y 6, 7 y 7))
33
+ game.checkWinCondition() shouldBe null
34
+ game.currentState.turn++
23
35
game.checkWinCondition() shouldBe WinCondition (Team .ONE , WinReason .DIFFERING_SCORES )
36
+ game.currentState.turn++
37
+
24
38
state.performMove(Move (1 y 1, 0 y 2))
25
39
game.checkWinCondition() shouldBe WinCondition (null, WinReason .EQUAL_SCORE )
26
40
0 commit comments