From: Steinar H. Gunderson Date: Mon, 10 Nov 2014 20:20:55 +0000 (+0100) Subject: Support promotion when displaying lines. X-Git-Url: https://git.sesse.net/?p=remoteglot;a=commitdiff_plain;h=bcae12d78459730f30039137cbdbe1cf8f490e5b Support promotion when displaying lines. --- diff --git a/www/js/remoteglot.js b/www/js/remoteglot.js index 078aba6..bf43403 100644 --- a/www/js/remoteglot.js +++ b/www/js/remoteglot.js @@ -763,9 +763,18 @@ var update_displayed_line = function() { hiddenboard.position(current_display_line.start_fen, false); for (var i = 0; i <= current_display_move; ++i) { var move = current_display_line.uci_pv[i]; + var promo = move.substr(4, 1); move = move.substr(0, 2) + "-" + move.substr(2, 2); hiddenboard.move(move, false); + // Do promotion if needed. + if (promo != "") { + var pos = hiddenboard.position(); + var target = move.substr(3, 2); + pos[target] = pos[target].substr(0, 1) + promo.toUpperCase(); + hiddenboard.position(pos, false); + } + // chessboard.js does not automatically move the rook on castling // (issue #51; marked as won't fix), so update it ourselves. if (move == "e1-g1" && hiddenboard.position().g1 == "wK") { // white O-O