if(legalMoves != null) {
var origen = legalmoves[0][0];
for(var i=legalmoves.length-1; i>0; i--) if(origen != legalmoves[i][0]) break;
if(i > 0) movePiece(origen); // fake a click on the only piece that can legally move
}
I got the following code to call the function, though the function didn't work right.
if (typeof legalMoves != 'undefined') {
var ori = legalMoves[0][0];
for (var i=1; i < legalMoves.length; i++) {
if (ori != legalMoves[i][0]) {
ori = "";
break;
}
}
if (ori != "") {
movePiece(ori); // fake a click on the only piece that can legally move
}
}
But it occurred to me that if it did work right, it would remove the display of the last move. So, I'm not sure I should bother trying to get it to work.
I got the following code to call the function, though the function didn't work right.
But it occurred to me that if it did work right, it would remove the display of the last move. So, I'm not sure I should bother trying to get it to work.