Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(wrong card playable) #84

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading