From 221a771b8eedb804272ab7f4ebae2030b548626d Mon Sep 17 00:00:00 2001 From: eug-vs Date: Mon, 27 Feb 2023 03:02:07 +0300 Subject: fix: correctly parse promotions --- src/moves.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/moves.rs b/src/moves.rs index 188e1e0..da66247 100644 --- a/src/moves.rs +++ b/src/moves.rs @@ -33,6 +33,17 @@ impl Move { pub fn from_notation(mut notation: Chars) -> Self { let source = Square::from_notation(&mut notation).unwrap(); let target = Square::from_notation(&mut notation).unwrap(); + + if let Some(promotion) = notation.next() { + let piece = match promotion { + 'r' => Piece::Rook, + 'q' => Piece::Queen, + 'b' => Piece::Bishop, + 'k' => Piece::Knight, + _ => panic!("Illegal promotion piece: {:?}", promotion) + }; + return Move { source, target, kind: MoveKind::Promotion(piece) } + } Move { source, target, kind: MoveKind::Quiet } } } -- cgit v1.2.3