Skip to content

Commit

Permalink
fix: Update card.rs to use PluginConstants for last lettuce position
Browse files Browse the repository at this point in the history
  • Loading branch information
maxblan committed Oct 21, 2024
1 parent 975a595 commit 12bf9eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/plugin/action/card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use std::mem::swap;
use pyo3::*;

use crate::plugin::{
errors::HUIError, field::Field, game_state::GameState, hare::Hare, rules_engine::RulesEngine,
constants::PluginConstants, errors::HUIError, field::Field, game_state::GameState, hare::Hare,
rules_engine::RulesEngine,
};

use super::Action;
Expand Down Expand Up @@ -80,10 +81,8 @@ impl Card {
}
Card::EatSalad => current.eat_salad(state)?,
Card::SwapCarrots => {
let last_lettuce_position = 57;

if current.position >= last_lettuce_position
|| other.position >= last_lettuce_position
if current.position >= PluginConstants::LAST_LETTUCE_POSITION
|| other.position >= PluginConstants::LAST_LETTUCE_POSITION
{
return Err(HUIError::new_err(
"You can only play this card if both players are before the last lettuce field",
Expand Down
2 changes: 2 additions & 0 deletions src/plugin/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ impl PluginConstants {
pub const INITIAL_CARROTS: i32 = 68;

pub const ROUND_LIMIT: usize = 30;

pub const LAST_LETTUCE_POSITION: usize = 57;
}

0 comments on commit 12bf9eb

Please sign in to comment.