Skip to content

Commit 0c86018

Browse files
author
Xerus
committed
fix(plugin): return SkipMove if getPossibleMoves is empty
fixes #239
1 parent 3e2b0b6 commit 0c86018

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

plugin/src/shared/sc/plugin2020/util/GameRuleLogic.kt

+4-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ object GameRuleLogic {
8888
}
8989

9090
private fun validateSkipMove(gameState: GameState): Boolean {
91-
if(this.getPossibleMoves(gameState).isNotEmpty())
91+
if(this.getPossibleMoves(gameState).any { it !is SkipMove })
9292
throw InvalidMoveException("Skipping a turn is only allowed when no other moves can be made.")
9393
if(gameState.round == 3 && !hasPlayerPlacedBee(gameState))
9494
throw InvalidMoveException("The bee must be placed in fourth round latest")
@@ -337,7 +337,9 @@ object GameRuleLogic {
337337

338338
@JvmStatic
339339
fun getPossibleMoves(gameState: GameState): List<Move> =
340-
this.getPossibleSetMoves(gameState) + this.getPossibleDragMoves(gameState)
340+
(this.getPossibleSetMoves(gameState) + this.getPossibleDragMoves(gameState)).ifEmpty {
341+
listOf(SkipMove)
342+
}
341343

342344
@JvmStatic
343345
fun getPossibleDragMoves(gameState: GameState): List<Move> =

plugin/src/test/sc/plugin2020/GamePlayTest.kt

+1
Original file line numberDiff line numberDiff line change
@@ -1261,6 +1261,7 @@ class GamePlayTest {
12611261
" ------------")
12621262
val valid = SkipMove
12631263
assertTrue(GameRuleLogic.validateMove(state, valid))
1264+
assertEquals(GameRuleLogic.getPossibleMoves(state), listOf(SkipMove))
12641265
}
12651266
}
12661267

0 commit comments

Comments
 (0)