Skip to content

Commit d3cb082

Browse files
committed
fix: not checking if player moves with cards onto market field
1 parent fff82fd commit d3cb082

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/plugin/action/card.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ impl Card {
7575
"You can only play this card if you are behind the other player",
7676
));
7777
}
78-
self.move_to_field(current, state, other.position + 1, remaining_cards)?;
7978
// saturating add is here unnecessary because the board is finite and never larger than usize::MAX
79+
self.move_to_field(current, state, other.position + 1, remaining_cards)?;
8080
}
8181
Card::EatSalad => current.eat_salad(state)?,
8282
Card::SwapCarrots => {

src/plugin/rules_engine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ impl RulesEngine {
113113
Field::Salad => Err(HUIError::new_err("Field is occupied by opponent")),
114114
Field::Hare if !cards.is_empty() => Ok(()),
115115
Field::Hare => Err(HUIError::new_err("No card to play")),
116-
Field::Market if player.carrots >= 10 => Ok(()),
117-
Field::Market => Err(HUIError::new_err("Not enough carrots")),
116+
Field::Market if player.carrots >= 10 && !cards.is_empty() => Ok(()),
117+
Field::Market => Err(HUIError::new_err("Not enough carrots or no card to play")),
118118
Field::Goal if player.carrots <= 10 && player.salads == 0 => Ok(()),
119119
Field::Goal => Err(HUIError::new_err("Too many carrots or salads")),
120120
_ => Ok(()),

0 commit comments

Comments
 (0)