diff --git a/src/game.rs b/src/game.rs index 456e944..e684567 100644 --- a/src/game.rs +++ b/src/game.rs @@ -484,8 +484,8 @@ impl Board { fn line(&self, from: BoardIndex, to: BoardIndex) -> impl Iterator { let mut curr = from; - // Longest possible move is 10, so we create a generator over 11 - (0..11) + // Longest possible move is 10, so we create a generator over 12 + (0..12) .map(move |_| { let x = if curr.x > to.x { curr.x.saturating_sub(1) @@ -534,7 +534,19 @@ impl Board { // Cannot move on top of a friendly Some(_) => Some(MoveType::Invalid), // Any other spot is valid - None => Some(MoveType::Valid), + None => { + // If there is another piece between A and B + if self + .line(from, to) + .any(|board_index| self.at(board_index).is_some()) + { + // Invalid move, there is a piece between A and B + Some(MoveType::Invalid) + } else { + // Otherwise it's a valid + Some(MoveType::Valid) + } + } } } // Check for moving across the canal