aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/moves.rs11
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 }
}
}