Make the struct attribute private, and export two new methods. A getter, active_color(), and a setter, set_active_color(). Update all references to the attribute to use the methods.
73 lines
2.2 KiB
Rust
73 lines
2.2 KiB
Rust
// Eryn Wells <eryn@erynwells.me>
|
|
|
|
#[macro_export]
|
|
macro_rules! test_board {
|
|
($to_move:ident, [ $($color:ident $shape:ident on $square:ident),* $(,)? ], $en_passant:ident) => {
|
|
{
|
|
let mut board = $crate::Board::empty();
|
|
$(let _ = board.place_piece(
|
|
chessfriend_core::Piece::new(
|
|
chessfriend_core::Color::$color,
|
|
chessfriend_core::Shape::$shape
|
|
),
|
|
chessfriend_core::Square::$square,
|
|
$crate::PlacePieceStrategy::default());
|
|
)*
|
|
board.set_active_color(chessfriend_core::Color::$to_move);
|
|
board.en_passant_target = Some(chessfriend_core::Square::$en_passant);
|
|
|
|
println!("{}", board.display());
|
|
|
|
board
|
|
}
|
|
};
|
|
($to_move:ident, [ $($color:ident $shape:ident on $square:ident),* $(,)? ]) => {
|
|
{
|
|
let mut board = $crate::Board::empty();
|
|
$(let _ = board.place_piece(
|
|
chessfriend_core::Piece::new(
|
|
chessfriend_core::Color::$color,
|
|
chessfriend_core::Shape::$shape
|
|
),
|
|
chessfriend_core::Square::$square,
|
|
$crate::PlacePieceStrategy::default());
|
|
)*
|
|
board.active_color = chessfriend_core::Color::$to_move;
|
|
|
|
println!("{}", board.display());
|
|
|
|
board
|
|
}
|
|
};
|
|
($($color:ident $shape:ident on $square:ident),* $(,)?) => {
|
|
{
|
|
let mut board = $crate::Board::empty();
|
|
$(let _ = board.place_piece(
|
|
chessfriend_core::Piece::new(
|
|
chessfriend_core::Color::$color,
|
|
chessfriend_core::Shape::$shape
|
|
),
|
|
chessfriend_core::Square::$square,
|
|
$crate::PlacePieceStrategy::default());
|
|
)*
|
|
|
|
println!("{}", board.display());
|
|
|
|
board
|
|
}
|
|
};
|
|
(empty) => {
|
|
{
|
|
let board = Board::empty();
|
|
println!("{}", board.display());
|
|
board
|
|
}
|
|
};
|
|
(starting) => {
|
|
{
|
|
let board = Board::starting();
|
|
println!("{}", board.display());
|
|
board
|
|
}
|
|
};
|
|
}
|