Skip to content

Commit b76e96c

Browse files
committed
fix: eat_salad action to enforce it only on action not card
1 parent 8b654a7 commit b76e96c

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/plugin/action/eat_salad.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use pyo3::*;
22

3-
use crate::plugin::game_state::GameState;
3+
use crate::plugin::{game_state::GameState, rules_engine::RulesEngine};
44

55
#[pyclass]
66
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Hash, Default)]
@@ -16,6 +16,7 @@ impl EatSalad {
1616

1717
pub fn perform(&self, state: &mut GameState) -> Result<(), PyErr> {
1818
let mut current = state.clone_current_player();
19+
RulesEngine::can_eat_salad(&state.board, &current)?;
1920
current.eat_salad(state)?;
2021
Ok(())
2122
}

src/plugin/hare.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ impl Hare {
123123
}
124124

125125
pub fn eat_salad(&mut self, state: &mut GameState) -> Result<(), PyErr> {
126-
RulesEngine::can_eat_salad(&state.board, self)?;
127-
128126
self.salads -= 1;
129127
self.carrots += if self.is_ahead(state) { 10 } else { 30 };
130128

@@ -164,7 +162,7 @@ impl Hare {
164162
match self.get_fall_back(state) {
165163
Some(i) => {
166164
RulesEngine::has_to_eat_salad(&state.board, self)?;
167-
165+
168166
self.carrots += 10 * ((self.position - i) as i32);
169167
self.position = i;
170168

0 commit comments

Comments
 (0)