97 lines
3 KiB
Rust
97 lines
3 KiB
Rust
|
// Eryn Wells <eryn@erynwells.me>
|
||
|
|
||
|
#[macro_export]
|
||
|
macro_rules! board {
|
||
|
[$($color:ident $shape:ident on $square:ident),* $(,)?] => {
|
||
|
$crate::Builder::new()
|
||
|
$(.place_piece(
|
||
|
chessfriend_core::PlacedPiece::new(
|
||
|
chessfriend_core::Piece::new(
|
||
|
chessfriend_core::Color::$color,
|
||
|
chessfriend_core::Shape::$shape),
|
||
|
chessfriend_core::Square::$square
|
||
|
)
|
||
|
))*
|
||
|
.build()
|
||
|
};
|
||
|
}
|
||
|
|
||
|
#[cfg(test)]
|
||
|
#[macro_export]
|
||
|
macro_rules! test_board {
|
||
|
($to_move:ident, [ $($color:ident $shape:ident on $square:ident),* $(,)? ], $en_passant:ident) => {
|
||
|
{
|
||
|
let board = $crate::Builder::new()
|
||
|
$(.place_piece(
|
||
|
chessfriend_core::PlacedPiece::new(
|
||
|
chessfriend_core::Piece::new(
|
||
|
chessfriend_core::Color::$color,
|
||
|
chessfriend_core::Shape::$shape
|
||
|
),
|
||
|
chessfriend_core::Square::$square
|
||
|
))
|
||
|
)*
|
||
|
.to_move(chessfriend_core::Color::$to_move)
|
||
|
.en_passant(Some(chessfriend_moves::EnPassant::from_target_square(chessfriend_core::Square::$en_passant)).unwrap())
|
||
|
.build();
|
||
|
|
||
|
println!("{}", board.display());
|
||
|
|
||
|
board
|
||
|
}
|
||
|
};
|
||
|
($to_move:ident, [ $($color:ident $shape:ident on $square:ident),* $(,)? ]) => {
|
||
|
{
|
||
|
let board = $crate::Builder::new()
|
||
|
$(.place_piece(
|
||
|
chessfriend_core::PlacedPiece::new(
|
||
|
chessfriend_core::Piece::new(
|
||
|
chessfriend_core::Color::$color,
|
||
|
chessfriend_core::Shape::$shape
|
||
|
),
|
||
|
chessfriend_core::Square::$square
|
||
|
))
|
||
|
)*
|
||
|
.to_move(chessfriend_core::Color::$to_move)
|
||
|
.build();
|
||
|
|
||
|
println!("{}", board.display());
|
||
|
|
||
|
pos
|
||
|
}
|
||
|
};
|
||
|
($($color:ident $shape:ident on $square:ident),* $(,)?) => {
|
||
|
{
|
||
|
let board = $crate::Builder::new()
|
||
|
$(.place_piece(
|
||
|
chessfriend_core::PlacedPiece::new(
|
||
|
chessfriend_core::Piece::new(
|
||
|
chessfriend_core::Color::$color,
|
||
|
chessfriend_core::Shape::$shape
|
||
|
),
|
||
|
chessfriend_core::Square::$square
|
||
|
))
|
||
|
)*
|
||
|
.build();
|
||
|
|
||
|
println!("{}", board.display());
|
||
|
|
||
|
board
|
||
|
}
|
||
|
};
|
||
|
(empty) => {
|
||
|
{
|
||
|
let board = Board::empty();
|
||
|
println!("{}", board.display());
|
||
|
board
|
||
|
}
|
||
|
};
|
||
|
(starting) => {
|
||
|
{
|
||
|
let board = Board::starting();
|
||
|
println!("{}", board.display());
|
||
|
board
|
||
|
}
|
||
|
};
|
||
|
}
|