From 892148a26c088cd4a8e2818be78cf813bdaa8bb5 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Mon, 27 Feb 2023 00:29:55 +0300 Subject: fix: add promotion to move notation --- src/moves.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src') 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) } } -- cgit v1.2.3