File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
main/kotlin/sc/plugin2025
test/kotlin/sc/plugin2025 Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -122,6 +122,14 @@ data class GameState @JvmOverloads constructor(
122
122
ExchangeCarrots (- 10 ).takeIf { mayExchangeCarrots(- 10 , player) },
123
123
)
124
124
125
+ /* * Checks which cards of the given player are usable from its current position.
126
+ * Does not check validity of a whole move.
127
+ *
128
+ * Usable means playable on a hare field
129
+ * and buyable on a market field.
130
+ *
131
+ * @return empty array means no cards are usable,
132
+ * null means not on a field where cards can be used. */
125
133
fun nextCards (player : Hare = currentPlayer): Collection <Array <Card >>? =
126
134
when (player.field) {
127
135
Field .HARE -> {
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package sc.plugin2025
2
2
3
3
import io.kotest.core.spec.style.FunSpec
4
4
import io.kotest.matchers.*
5
+ import io.kotest.matchers.collections.*
5
6
import sc.plugin2025.util.HuIConstants
6
7
7
8
class CardTest : FunSpec ({
@@ -13,10 +14,13 @@ class CardTest: FunSpec({
13
14
lastSalad shouldBe HuIConstants .LAST_SALAD
14
15
state.currentPlayer.position = lastSalad!!
15
16
Card .SWAP_CARROTS .check(state) shouldBe HuIMoveMistake .CANNOT_PLAY_SWAP_CARROTS_BEYOND_LAST_SALAD
16
- state.currentPlayer.position = lastSalad - 1
17
+ state.currentPlayer.position = state.board.getPreviousField( Field . HARE , lastSalad)!!
17
18
Card .SWAP_CARROTS .check(state) shouldBe null
19
+ state.currentPlayer.addCard(Card .SWAP_CARROTS )
20
+ state.nextCards() shouldContainExactly listOf(arrayOf(Card .SWAP_CARROTS ))
18
21
state.otherPlayer.position = lastSalad
19
22
Card .SWAP_CARROTS .check(state) shouldBe HuIMoveMistake .CANNOT_PLAY_SWAP_CARROTS_BEYOND_LAST_SALAD
23
+ state.nextCards().shouldBeEmpty()
20
24
}
21
25
state.currentPlayer.addCard(Card .SWAP_CARROTS )
22
26
test("not repeatable") {
You can’t perform that action at this time.
0 commit comments