X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=www%2Fjs%2Fremoteglot.js;h=a402d0004b2067129ff3fe0e738552672d2cee77;hb=9cb18b849dd6993c6c9861a8c474e5d259c99dd9;hp=27ded16052cb45076f37b00534f1f448f20bfdfc;hpb=a8f854462950e88d74aa73102ff3d431caa52b0e;p=remoteglot diff --git a/www/js/remoteglot.js b/www/js/remoteglot.js index 27ded16..a402d00 100644 --- a/www/js/remoteglot.js +++ b/www/js/remoteglot.js @@ -1827,23 +1827,19 @@ let update_historic_analysis = function() { * @param {string} fen */ let update_imbalance = function(fen) { - let hiddenboard = new Chess(fen); let imbalance = {'k': 0, 'q': 0, 'r': 0, 'b': 0, 'n': 0, 'p': 0}; - for (let row = 0; row < 8; ++row) { - for (let col = 0; col < 8; ++col) { - let col_text = String.fromCharCode('a1'.charCodeAt(0) + col); - let row_text = String.fromCharCode('a1'.charCodeAt(1) + row); - let square = col_text + row_text; - let contents = hiddenboard.get(square); - if (contents !== null) { - if (contents.color === 'w') { - ++imbalance[contents.type]; - } else { - --imbalance[contents.type]; - } - } + for (const c of fen) { + if (c === ' ') { + // End of board + break; + } + if (c != c.toUpperCase()) { + --imbalance[c]; + } else if (c != c.toLowerCase()) { + ++imbalance[c.toLowerCase()]; } } + let white_imbalance = document.getElementById('whiteimbalance'); let black_imbalance = document.getElementById('blackimbalance'); white_imbalance.textContent = ''; @@ -2241,6 +2237,9 @@ let onSnapEnd = function(source, target) { // Shouldn't really be here if we have hash probes, but there's really // nothing we can do. + // FIXME: Just make a new line, probably (even if we don't have hash moves). + // As it is, we can actually drag (but not click) such a move in the UI, + // but it has no effect on what we're probing. } // End of dragging-related code.