diff --git a/plugin2025/src/main/kotlin/sc/plugin2025/Card.kt b/plugin2025/src/main/kotlin/sc/plugin2025/Card.kt index 97cf6c806..553155e3b 100644 --- a/plugin2025/src/main/kotlin/sc/plugin2025/Card.kt +++ b/plugin2025/src/main/kotlin/sc/plugin2025/Card.kt @@ -8,20 +8,6 @@ import sc.shared.IMoveMistake @XStreamAlias(value = "card") enum class Card(val label: String, val moves: Boolean, val check: (GameState) -> HuIMoveMistake?, val play: (GameState) -> Unit): HuIAction { - /** Falle hinter den Gegenspieler. */ - FALL_BACK("Zurückfallen", true, - { state -> - HuIMoveMistake.CANNOT_PLAY_FALL_BACK.takeUnless { state.isAhead() } - ?: state.validateTargetField(state.otherPlayer.position - 1) - }, - { it.moveToField(it.otherPlayer.position - 1) }), - /** Rücke vor den Gegenspieler. */ - HURRY_AHEAD("Vorrücken", true, - { state -> - HuIMoveMistake.CANNOT_PLAY_HURRY_AHEAD.takeIf { state.isAhead() } - ?: state.validateTargetField(state.otherPlayer.position + 1) - }, - { it.moveToField(it.otherPlayer.position + 1) }), /** Friss sofort einen Salat. */ EAT_SALAD("Salat fressen", false, { state -> HuIMoveMistake.NO_SALAD.takeUnless { state.currentPlayer.salads > 0 } }, @@ -41,7 +27,22 @@ enum class Card(val label: String, val moves: Boolean, val check: (GameState) -> val car = state.currentPlayer.carrots state.currentPlayer.carrots = state.otherPlayer.carrots state.otherPlayer.carrots = car - }); + }), + /** Falle hinter den Gegenspieler. */ + FALL_BACK("Zurückfallen", true, + { state -> + HuIMoveMistake.CANNOT_PLAY_FALL_BACK.takeUnless { state.isAhead() } + ?: state.validateTargetField(state.otherPlayer.position - 1) + }, + { it.moveToField(it.otherPlayer.position - 1) }), + /** Rücke vor den Gegenspieler. */ + HURRY_AHEAD("Vorrücken", true, + { state -> + HuIMoveMistake.CANNOT_PLAY_HURRY_AHEAD.takeIf { state.isAhead() } + ?: state.validateTargetField(state.otherPlayer.position + 1) + }, + { it.moveToField(it.otherPlayer.position + 1) }), + ; override fun perform(state: GameState): IMoveMistake? { if(state.currentField != Field.HARE) diff --git a/plugin2025/src/main/kotlin/sc/plugin2025/GameState.kt b/plugin2025/src/main/kotlin/sc/plugin2025/GameState.kt index cda0242fd..f3f7fe173 100644 --- a/plugin2025/src/main/kotlin/sc/plugin2025/GameState.kt +++ b/plugin2025/src/main/kotlin/sc/plugin2025/GameState.kt @@ -125,7 +125,7 @@ data class GameState @JvmOverloads constructor( fun nextCards(player: Hare = currentPlayer): Collection>? = when(player.field) { Field.HARE -> { - player.getCards().toSet().flatMap { card -> + HashSet(player.getCards()).flatMap { card -> if(card.check(this) == null) { val newState = clone() newState.currentPlayer.removeCard(card)