[board] Check that move is in sight of piece
If it's not, return an error from MoveBuilder::make()
This commit is contained in:
parent
1b5319c702
commit
88c0638d83
1 changed files with 6 additions and 1 deletions
|
@ -62,9 +62,14 @@ where
|
||||||
.position
|
.position
|
||||||
.piece_on_square(from_square)
|
.piece_on_square(from_square)
|
||||||
.ok_or(MakeMoveError::NoPiece)?;
|
.ok_or(MakeMoveError::NoPiece)?;
|
||||||
println!("{}", &piece);
|
|
||||||
|
|
||||||
let to_square = mv.to_square();
|
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 player = self.position.player_to_move();
|
||||||
|
|
||||||
let captured_piece: Option<PlacedPiece> = if mv.is_en_passant() {
|
let captured_piece: Option<PlacedPiece> = if mv.is_en_passant() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue