Fix another off-by-one bug that was introduced while fixing the others.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 16 Nov 2016 19:03:08 +0000 (20:03 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 20 Nov 2016 22:12:02 +0000 (23:12 +0100)
www/js/remoteglot.js

index 0748dce..1f4c2a5 100644 (file)
@@ -1060,10 +1060,20 @@ var update_board = function() {
                        headline += ' after ' + last_move;
                }
        } else if (data['position']['last_move'] !== 'none') {
+               // Find the previous move.
+               var previous_move_num, previous_toplay;
+               if (data['position']['toplay'] == 'B') {
+                       previous_move_num = data['position']['move_num'];
+                       previous_toplay = 'W';
+               } else {
+                       previous_move_num = data['position']['move_num'] - 1;
+                       previous_toplay = 'B';
+               }
+
                last_move = format_move_with_number(
                        data['position']['last_move'],
-                       data['position']['move_num'],
-                       data['position']['toplay'] == 'B');
+                       previous_move_num,
+                       previous_toplay == 'W');
                headline += ' after ' + last_move;
        } else {
                last_move = null;