Encapsulate castling rights within a small module. Castle provides the API to the rest of the board package. Rights encodes the castling rights for each player. Parameters defines castling parameters for each player.
24 lines
485 B
Rust
24 lines
485 B
Rust
// Eryn Wells <eryn@erynwells.me>
|
|
|
|
mod parameters;
|
|
mod rights;
|
|
|
|
pub use rights::Rights;
|
|
|
|
use chessfriend_core::Color;
|
|
use parameters::Parameters;
|
|
|
|
#[repr(u8)]
|
|
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
|
pub enum Castle {
|
|
KingSide = 0,
|
|
QueenSide = 1,
|
|
}
|
|
|
|
impl Castle {
|
|
pub const ALL: [Castle; 2] = [Castle::KingSide, Castle::QueenSide];
|
|
|
|
pub fn parameters(self, color: Color) -> &'static Parameters {
|
|
&Parameters::BY_COLOR[color as usize][self as usize]
|
|
}
|
|
}
|