aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/moves.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/moves.rs b/src/moves.rs
index b8ced18..188e1e0 100644
--- a/src/moves.rs
+++ b/src/moves.rs
@@ -39,6 +39,18 @@ impl Move {
impl Display for Move {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- write!(f, "{}{}", self.source, self.target)
+ let promotion_postfix = match self.kind {
+ MoveKind::Promotion(piece) => {
+ match piece.without_color() {
+ Piece::Rook => "r",
+ Piece::Queen => "q",
+ Piece::Bishop => "b",
+ Piece::Knight => "k",
+ _ => panic!("Illegal promotion piece: {:?}", piece)
+ }
+ }
+ _ => ""
+ };
+ write!(f, "{}{}{}", self.source, self.target, promotion_postfix)
}
}