]> git.sesse.net Git - remoteglot/commitdiff
Support promotion when displaying lines.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 10 Nov 2014 20:20:55 +0000 (21:20 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 10 Nov 2014 20:20:55 +0000 (21:20 +0100)
www/js/remoteglot.js

index 078aba6cdf674cda3840e2f16d4714b5c1ef7001..bf43403ef7a6b7a3420103320b95872a37770f02 100644 (file)
@@ -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