diff options
author | eug-vs <eugene@eug-vs.xyz> | 2023-02-27 03:02:07 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2023-02-27 03:02:07 +0300 |
commit | 221a771b8eedb804272ab7f4ebae2030b548626d (patch) | |
tree | 8456f3b35021f290b03501111160ae06670e3422 | |
parent | b3b63041b6920fdf3dab79d8c81bfda33fcf8012 (diff) | |
download | chessnost-221a771b8eedb804272ab7f4ebae2030b548626d.tar.gz |
fix: correctly parse promotions
-rw-r--r-- | src/moves.rs | 11 |
1 files changed, 11 insertions, 0 deletions
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 } } } |