Skip to content

Commit 68d70c2

Browse files
committed
fix(plugin25): reorder Cards
1 parent a558cac commit 68d70c2

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

plugin2025/src/main/kotlin/sc/plugin2025/Card.kt

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,6 @@ import sc.shared.IMoveMistake
88
@XStreamAlias(value = "card")
99
enum class Card(val label: String, val moves: Boolean, val check: (GameState) -> HuIMoveMistake?, val play: (GameState) -> Unit):
1010
HuIAction {
11-
/** Falle hinter den Gegenspieler. */
12-
FALL_BACK("Zurückfallen", true,
13-
{ state ->
14-
HuIMoveMistake.CANNOT_PLAY_FALL_BACK.takeUnless { state.isAhead() }
15-
?: state.validateTargetField(state.otherPlayer.position - 1)
16-
},
17-
{ it.moveToField(it.otherPlayer.position - 1) }),
18-
/** Rücke vor den Gegenspieler. */
19-
HURRY_AHEAD("Vorrücken", true,
20-
{ state ->
21-
HuIMoveMistake.CANNOT_PLAY_HURRY_AHEAD.takeIf { state.isAhead() }
22-
?: state.validateTargetField(state.otherPlayer.position + 1)
23-
},
24-
{ it.moveToField(it.otherPlayer.position + 1) }),
2511
/** Friss sofort einen Salat. */
2612
EAT_SALAD("Salat fressen", false,
2713
{ 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) ->
4127
val car = state.currentPlayer.carrots
4228
state.currentPlayer.carrots = state.otherPlayer.carrots
4329
state.otherPlayer.carrots = car
44-
});
30+
}),
31+
/** Falle hinter den Gegenspieler. */
32+
FALL_BACK("Zurückfallen", true,
33+
{ state ->
34+
HuIMoveMistake.CANNOT_PLAY_FALL_BACK.takeUnless { state.isAhead() }
35+
?: state.validateTargetField(state.otherPlayer.position - 1)
36+
},
37+
{ it.moveToField(it.otherPlayer.position - 1) }),
38+
/** Rücke vor den Gegenspieler. */
39+
HURRY_AHEAD("Vorrücken", true,
40+
{ state ->
41+
HuIMoveMistake.CANNOT_PLAY_HURRY_AHEAD.takeIf { state.isAhead() }
42+
?: state.validateTargetField(state.otherPlayer.position + 1)
43+
},
44+
{ it.moveToField(it.otherPlayer.position + 1) }),
45+
;
4546

4647
override fun perform(state: GameState): IMoveMistake? {
4748
if(state.currentField != Field.HARE)

plugin2025/src/main/kotlin/sc/plugin2025/GameState.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ data class GameState @JvmOverloads constructor(
125125
fun nextCards(player: Hare = currentPlayer): Collection<Array<Card>>? =
126126
when(player.field) {
127127
Field.HARE -> {
128-
player.getCards().toSet().flatMap { card ->
128+
HashSet(player.getCards()).flatMap { card ->
129129
if(card.check(this) == null) {
130130
val newState = clone()
131131
newState.currentPlayer.removeCard(card)

0 commit comments

Comments
 (0)