From: Steinar H. Gunderson Date: Wed, 16 Nov 2016 19:03:08 +0000 (+0100) Subject: Fix another off-by-one bug that was introduced while fixing the others. X-Git-Url: https://git.sesse.net/?p=remoteglot;a=commitdiff_plain;h=4cc49cb14f990d0b9283002028899a09190040b4;hp=28a2cc705cbfdcbc1d13f8a557bc090157a8190f Fix another off-by-one bug that was introduced while fixing the others. --- diff --git a/www/js/remoteglot.js b/www/js/remoteglot.js index 0748dce..1f4c2a5 100644 --- a/www/js/remoteglot.js +++ b/www/js/remoteglot.js @@ -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;