Refactor castling right management in 'do_move'
All checks were successful
ci/woodpecker/push/check Pipeline was successful
All checks were successful
ci/woodpecker/push/check Pipeline was successful
I find it more readable.
This commit is contained in:
parent
9507432bd3
commit
f9ba6fa680
|
@ -170,17 +170,13 @@ impl ChessBoard {
|
||||||
} else {
|
} else {
|
||||||
self.en_passant = None;
|
self.en_passant = None;
|
||||||
}
|
}
|
||||||
if move_piece == Piece::King {
|
let castle_rights = self.castle_rights_mut(self.current_player());
|
||||||
*self.castle_rights_mut(self.current_player()) = CastleRights::NoSide;
|
*castle_rights = match (move_piece, chess_move.start().file()) {
|
||||||
}
|
(Piece::Rook, File::A) => castle_rights.without_queen_side(),
|
||||||
if move_piece == Piece::Rook {
|
(Piece::Rook, File::H) => castle_rights.without_king_side(),
|
||||||
let castle_rights = self.castle_rights_mut(self.current_player());
|
(Piece::King, _) => CastleRights::NoSide,
|
||||||
*castle_rights = match chess_move.start().file() {
|
_ => *castle_rights,
|
||||||
File::A => castle_rights.without_queen_side(),
|
};
|
||||||
File::H => castle_rights.without_king_side(),
|
|
||||||
_ => *castle_rights,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if let Some(piece) = captured_piece {
|
if let Some(piece) = captured_piece {
|
||||||
*self.piece_occupancy_mut(piece) ^= chess_move.destination();
|
*self.piece_occupancy_mut(piece) ^= chess_move.destination();
|
||||||
*self.color_occupancy_mut(opponent) ^= chess_move.destination();
|
*self.color_occupancy_mut(opponent) ^= chess_move.destination();
|
||||||
|
|
Loading…
Reference in a new issue