Skip to content

Commit 975a595

Browse files
authored
fix(wrong card playable) (#84)
Resolved an issue where the SwapCarrots card could be played when it shouldn't have been allowed.
1 parent 4ffaca0 commit 975a595

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "_socha"
3-
version = "3.5.1"
3+
version = "3.5.2"
44
edition = "2021"
55

66
[lib]

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "maturin"
44

55
[project]
66
name = "socha"
7-
version = "3.5.1"
7+
version = "3.5.2"
88
authors = [{ name = "maxblan", email = "[email protected]" }]
99
description = "Dieses Paket ist für die Software-Challenge Germany 2025, bei der in dieser Saison das Spiel 'Hase und Igel' im Mittelpunkt steht."
1010
readme = "README.md"

src/plugin/action/card.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,13 @@ impl Card {
8080
}
8181
Card::EatSalad => current.eat_salad(state)?,
8282
Card::SwapCarrots => {
83-
let last_lettuce_position = state
84-
.board
85-
.get_previous_field(Field::Salad, state.board.track.len() - 1)
86-
.ok_or_else(|| {
87-
HUIError::new_err("Unable to find the last lettuce field position")
88-
})?;
89-
90-
if current.position > last_lettuce_position
91-
|| other.position > last_lettuce_position
83+
let last_lettuce_position = 57;
84+
85+
if current.position >= last_lettuce_position
86+
|| other.position >= last_lettuce_position
9287
{
9388
return Err(HUIError::new_err(
94-
"You can only play this card if both players haven't passed the last lettuce field",
89+
"You can only play this card if both players are before the last lettuce field",
9590
));
9691
}
9792

0 commit comments

Comments
 (0)