[board] Check that move is in sight of piece

If it's not, return an error from MoveBuilder::make()
This commit is contained in:
Eryn Wells 2024-01-24 17:10:10 -08:00
parent 1b5319c702
commit 88c0638d83

View file

@ -62,9 +62,14 @@ where
.position
.piece_on_square(from_square)
.ok_or(MakeMoveError::NoPiece)?;
println!("{}", &piece);
let to_square = mv.to_square();
let sight = piece.sight_in_position(self.position);
if !sight.is_set(to_square) {
return Err(MakeMoveError::IllegalSquare(to_square));
}
let player = self.position.player_to_move();
let captured_piece: Option<PlacedPiece> = if mv.is_en_passant() {