From 50137398413cf2b39414dafa6030552347d57c95 Mon Sep 17 00:00:00 2001 From: brianch Date: Sun, 21 Jan 2024 17:02:11 -0300 Subject: [PATCH] Fix SAN notation not showing check/mate symbols --- src/config.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/config.rs b/src/config.rs index 9dcab66..feaac5b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -175,6 +175,17 @@ pub fn coord_to_san(board: &Board, coords: String, lang: &lang::Language) -> Opt } } } + let chess_move = ChessMove::from_san(&board, &san_localized); + // Note: It can indeed return Err for a moment when using the engine (and quickly taking + // back moves), I guess for a sec the engine & board may get desynced, so we can't just unwrap it. + if let Ok(chess_move) = chess_move { + let current_board = board.make_move_new(chess_move); + if current_board.status() == chess::BoardStatus::Checkmate { + san_localized.push_str("#"); + } else if current_board.checkers().popcnt() != 0 { + san_localized.push_str("+"); + } + } san = Some(san_localized); } }