Skip to content

Commit 569ad4b

Browse files
committed
fix(plugin): improve test reliability
1 parent a825b14 commit 569ad4b

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

plugin/src/main/kotlin/sc/plugin2022/Game.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,15 @@ class Game(override val currentState: GameState = GameState()): AbstractGame<Pla
9090
var cause: ScoreCause = ScoreCause.REGULAR
9191
var reason = ""
9292
var score: Int = Constants.LOSE_SCORE
93-
94-
// Is the game already finished?
95-
if (winCondition?.reason == WinReason.EQUAL_SCORE)
96-
// TODO something is going wrong on draw scores
97-
score = Constants.DRAW_SCORE
98-
if (winCondition?.reason == WinReason.DIFFERING_SCORES)
99-
if (winCondition.winner == team)
100-
score = Constants.WIN_SCORE
93+
94+
if (winCondition != null) {
95+
// Game is already finished
96+
score = if (winCondition.winner == null)
97+
Constants.DRAW_SCORE
98+
else {
99+
if (winCondition.winner == team) Constants.WIN_SCORE else Constants.LOSE_SCORE
100+
}
101+
}
101102

102103
// Opponent did something wrong
103104
if (opponent.hasViolated() && !player.hasViolated() ||

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class GamePlayTest: WordSpec({
4242
}
4343
"stay paused after move" {
4444
game.isPaused = true
45-
game.onRoundBasedAction(Move(0 y 0, 1 y 2))
45+
game.onRoundBasedAction(game.currentState.possibleMoves.first())
4646
game.isPaused shouldBe true
4747
}
4848
}

0 commit comments

Comments
 (0)