[board] Use Unicode chess characters to Display Pieces

This commit is contained in:
Eryn Wells 2024-01-06 20:49:25 -08:00
parent ea8f5f47fd
commit b62cd1fcd2

View file

@ -158,7 +158,22 @@ impl Piece {
impl fmt::Display for Piece {
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)
}
}