Skip to content

Commit

Permalink
Fix game end bug in SpiceRoad with 4 players
Browse files Browse the repository at this point in the history
  • Loading branch information
Zomis committed Dec 11, 2022
1 parent 24f8ab8 commit 752f887
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,11 @@ object SpiceRoadDsl {
}
allActions.precondition { game.currentPlayer.index == playerIndex }
allActions.after {
val gameEnd = when (game.playerCount) {
1, 2, 3 -> game.players.any { player -> player.pointCards.size >= 6 }
else -> game.currentPlayer.pointCards.size >= 5
val pointCardsRequired = when (game.playerCount) {
1, 2, 3 -> 6
else -> 5
}
val gameEnd = game.players.any { player -> player.pointCards.size >= pointCardsRequired }
if (gameEnd && game.currentPlayerIndex == game.playerCount - 1) {
this.eliminations.eliminateBy(game.players.mapIndexed { index, player -> index to player }, compareBy({ it.points }, { +it.index }))
}
Expand Down

0 comments on commit 752f887

Please sign in to comment.