From 26619e4353d551bb4e2a79059203a26c3f5f5647 Mon Sep 17 00:00:00 2001 From: IgrisBRC Date: Mon, 15 Jul 2024 15:35:35 +0530 Subject: all the bugs so far have been fixed, black pawns move twice, and the highlighting does get cancelled when it should --- public/move.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'public/move.js') diff --git a/public/move.js b/public/move.js index ee527c6..5dc49af 100644 --- a/public/move.js +++ b/public/move.js @@ -12,7 +12,7 @@ let board = [ let to_move = true //white to move //console.log(board[7][1]) -//console.log(move(board, 7, 1, to_move)) +//console.log(move(board, 3, 1, to_move)) function move(board, y, x, to_move) { if (to_move ^ board[y][x] > 0) { @@ -69,9 +69,10 @@ function pawn_move(board, y, x) { if (board[y + 2][x] == 0) { moves.push([y + 2, x]) } - } else if (color && y != 7 && board[y + 1][x] == 0) { + } else if (!color && y != 7 && board[y + 1][x] == 0) { moves.push([y + 1, x]) } + return moves } } -- cgit v1.2.3