From 2b7c19ee28e91d71615882f48f004954bfae726d Mon Sep 17 00:00:00 2001 From: Vito0912 <86927734+Vito0912@users.noreply.github.com> Date: Fri, 18 Oct 2024 22:47:55 +0200 Subject: [PATCH] fix(wrong card playable) Resolved an issue where the SwapCarrots card could be played when it shouldn't have been allowed. --- Cargo.toml | 2 +- pyproject.toml | 2 +- src/plugin/action/card.rs | 15 +++++---------- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 83ce526..717cbfe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "_socha" -version = "3.5.1" +version = "3.5.2" edition = "2021" [lib] diff --git a/pyproject.toml b/pyproject.toml index 1d28dba..5528f1c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "maturin" [project] name = "socha" -version = "3.5.1" +version = "3.5.2" authors = [{ name = "maxblan", email = "stu222782@mail.uni-kiel.de" }] 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" diff --git a/src/plugin/action/card.rs b/src/plugin/action/card.rs index f848fde..9c113c4 100644 --- a/src/plugin/action/card.rs +++ b/src/plugin/action/card.rs @@ -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", )); }