[board, moves] Make Board::castling_rights and Board::en_passant_target private
Make the struct fields private and export getters and various setters for manipulating the data. Update all the references to these fields to use the getters and setters instead.
This commit is contained in:
parent
eaab34587c
commit
404212363e
10 changed files with 96 additions and 51 deletions
|
@ -46,7 +46,7 @@ impl Board {
|
|||
|
||||
let color = self.unwrap_color(color);
|
||||
|
||||
if !self.castling_rights.color_has_right(color, wing) {
|
||||
if !self.color_has_castling_right(color, wing) {
|
||||
return Err(CastleEvaluationError::NoRights { color, wing });
|
||||
}
|
||||
|
||||
|
@ -98,15 +98,14 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn king_on_starting_square_can_castle() {
|
||||
let pos = test_board!(
|
||||
let board = test_board!(
|
||||
White King on E1,
|
||||
White Rook on A1,
|
||||
White Rook on H1
|
||||
);
|
||||
|
||||
let rights = pos.castling_rights;
|
||||
assert!(rights.color_has_right(Color::White, Wing::KingSide));
|
||||
assert!(rights.color_has_right(Color::White, Wing::QueenSide));
|
||||
assert!(board.color_has_castling_right(Color::White, Wing::KingSide));
|
||||
assert!(board.color_has_castling_right(Color::White, Wing::QueenSide));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue