aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2023-02-27 00:29:55 +0300
committereug-vs <eugene@eug-vs.xyz>2023-02-27 00:35:17 +0300
commit892148a26c088cd4a8e2818be78cf813bdaa8bb5 (patch)
tree5ed675b10b95a77fcbbdce0a93cf90919e7b36c7
parentc31e8188ddb0a39eff3e59df94eed736f2490d8a (diff)
downloadchessnost-892148a26c088cd4a8e2818be78cf813bdaa8bb5.tar.gz
fix: add promotion to move notation
-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)
}
}