Skip to content

Commit 12bf9eb

Browse files
committed
fix: Update card.rs to use PluginConstants for last lettuce position
1 parent 975a595 commit 12bf9eb

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/plugin/action/card.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ use std::mem::swap;
33
use pyo3::*;
44

55
use crate::plugin::{
6-
errors::HUIError, field::Field, game_state::GameState, hare::Hare, rules_engine::RulesEngine,
6+
constants::PluginConstants, errors::HUIError, field::Field, game_state::GameState, hare::Hare,
7+
rules_engine::RulesEngine,
78
};
89

910
use super::Action;
@@ -80,10 +81,8 @@ impl Card {
8081
}
8182
Card::EatSalad => current.eat_salad(state)?,
8283
Card::SwapCarrots => {
83-
let last_lettuce_position = 57;
84-
85-
if current.position >= last_lettuce_position
86-
|| other.position >= last_lettuce_position
84+
if current.position >= PluginConstants::LAST_LETTUCE_POSITION
85+
|| other.position >= PluginConstants::LAST_LETTUCE_POSITION
8786
{
8887
return Err(HUIError::new_err(
8988
"You can only play this card if both players are before the last lettuce field",

src/plugin/constants.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ impl PluginConstants {
1111
pub const INITIAL_CARROTS: i32 = 68;
1212

1313
pub const ROUND_LIMIT: usize = 30;
14+
15+
pub const LAST_LETTUCE_POSITION: usize = 57;
1416
}

0 commit comments

Comments
 (0)