blob: 80d5b4e895ea3ab8a567e527f2037c9f919bf41a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
use super::piece::Piece;
#[derive(Debug, Clone, Copy, PartialEq, num_enum::FromPrimitive)]
#[repr(u8)]
pub enum Color {
#[default]
White,
Black,
}
impl Color {
pub fn flip(&self) -> Self {
match self {
Self::White => Self::Black,
Self::Black => Self::White,
}
}
pub fn from_piece(piece: Piece) -> Self {
if (piece as u8) < 6 {
Self::White
} else {
Self::Black
}
}
}
|