[board] Use Unicode chess characters to Display Pieces
This commit is contained in:
parent
ea8f5f47fd
commit
b62cd1fcd2
1 changed files with 16 additions and 1 deletions
|
@ -158,7 +158,22 @@ impl Piece {
|
||||||
|
|
||||||
impl fmt::Display for Piece {
|
impl fmt::Display for Piece {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "{}", self.shape)
|
let char = match (self.color, self.shape) {
|
||||||
|
(Color::White, Shape::Pawn) => '♟',
|
||||||
|
(Color::White, Shape::Knight) => '♞',
|
||||||
|
(Color::White, Shape::Bishop) => '♝',
|
||||||
|
(Color::White, Shape::Rook) => '♜',
|
||||||
|
(Color::White, Shape::Queen) => '♛',
|
||||||
|
(Color::White, Shape::King) => '♚',
|
||||||
|
(Color::Black, Shape::Pawn) => '♙',
|
||||||
|
(Color::Black, Shape::Knight) => '♘',
|
||||||
|
(Color::Black, Shape::Bishop) => '♗',
|
||||||
|
(Color::Black, Shape::Rook) => '♖',
|
||||||
|
(Color::Black, Shape::Queen) => '♕',
|
||||||
|
(Color::Black, Shape::King) => '♔',
|
||||||
|
};
|
||||||
|
|
||||||
|
write!(f, "{}", char)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue