improve player management
This commit is contained in:
29
src/piece.rs
Normal file
29
src/piece.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||
pub enum Piece {
|
||||
Black,
|
||||
White,
|
||||
}
|
||||
|
||||
impl Piece {
|
||||
pub const fn flip(&self) -> Self {
|
||||
match self {
|
||||
Piece::Black => Piece::White,
|
||||
Piece::White => Piece::Black,
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn text(&self) -> &'static str {
|
||||
match self {
|
||||
Piece::White => "■",
|
||||
Piece::Black => "□",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Not for Piece {
|
||||
type Output = Piece;
|
||||
|
||||
fn not(self) -> Self::Output {
|
||||
self.flip()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user