From b62cd1fcd283e131f1c1013f697afead7e3e35f6 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sat, 6 Jan 2024 20:49:25 -0800 Subject: [PATCH] [board] Use Unicode chess characters to Display Pieces --- board/src/piece.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/board/src/piece.rs b/board/src/piece.rs index 44f1c50..8c0260f 100644 --- a/board/src/piece.rs +++ b/board/src/piece.rs @@ -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) } }