fix a null reference when checking for legal en passant moves

This commit is contained in:
Jesse D. McDonald 2020-03-15 14:27:34 -05:00
parent c20dda886a
commit 5011cfed8c
1 changed files with 1 additions and 1 deletions

View File

@ -228,7 +228,7 @@ function legalMoves(board, side, type, from, canCapture){
if (there) { if (there) {
if (boardGet(board, there, otherSide(side)) !== ' ') { if (boardGet(board, there, otherSide(side)) !== ' ') {
legals.push(there); legals.push(there);
} else { } else if (forward2) {
let otherBoard = board; let otherBoard = board;
while (otherBoard && otherBoard.move && otherBoard.move.side[0] === side[0]) { while (otherBoard && otherBoard.move && otherBoard.move.side[0] === side[0]) {
otherBoard = otherBoard.prior; otherBoard = otherBoard.prior;