Skip to content

Commit

Permalink
fix(wrong card playable) (#84)
Browse files Browse the repository at this point in the history
Resolved an issue where the SwapCarrots card could be played when it shouldn't have been allowed.
  • Loading branch information
Vito0912 authored Oct 21, 2024
1 parent 4ffaca0 commit 975a595
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "_socha"
version = "3.5.1"
version = "3.5.2"
edition = "2021"

[lib]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "maturin"

[project]
name = "socha"
version = "3.5.1"
version = "3.5.2"
authors = [{ name = "maxblan", email = "[email protected]" }]
description = "Dieses Paket ist für die Software-Challenge Germany 2025, bei der in dieser Saison das Spiel 'Hase und Igel' im Mittelpunkt steht."
readme = "README.md"
Expand Down
15 changes: 5 additions & 10 deletions src/plugin/action/card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,13 @@ impl Card {
}
Card::EatSalad => current.eat_salad(state)?,
Card::SwapCarrots => {
let last_lettuce_position = state
.board
.get_previous_field(Field::Salad, state.board.track.len() - 1)
.ok_or_else(|| {
HUIError::new_err("Unable to find the last lettuce field position")
})?;

if current.position > last_lettuce_position
|| other.position > last_lettuce_position
let last_lettuce_position = 57;

if current.position >= last_lettuce_position
|| other.position >= last_lettuce_position
{
return Err(HUIError::new_err(
"You can only play this card if both players haven't passed the last lettuce field",
"You can only play this card if both players are before the last lettuce field",
));
}

Expand Down

0 comments on commit 975a595

Please sign in to comment.