chessfriend/board/src/castle.rs
Eryn Wells 0b100d5f14 [board] Remove Flags struct, replace it with Castle and supporting structs
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.
2025-05-02 15:03:48 -07:00

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]
}
}