Skip to content

Commit

Permalink
Fix SAN notation not showing check/mate symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
brianch committed Jan 21, 2024
1 parent e6fb208 commit 5013739
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 5013739

Please sign in to comment.