diff options
author | IgrisBRC <[email protected]> | 2024-07-14 07:47:23 +0530 |
---|---|---|
committer | IgrisBRC <[email protected]> | 2024-07-14 07:47:23 +0530 |
commit | a734e0af70a14dc8d635ab988c82e1a2e0b49836 (patch) | |
tree | 62b3023054d9fc7ba0a89cb0d0f4dbd27d7a9bc8 /public/app.js | |
parent | 2b0cdea28c841040fd872b2b1837b1e0639d6df0 (diff) |
fixed critical error in highlighting, the moves were mapped mirrored from the board
Diffstat (limited to 'public/app.js')
-rw-r--r-- | public/app.js | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/public/app.js b/public/app.js index bbb8d4b..a8db6b2 100644 --- a/public/app.js +++ b/public/app.js @@ -1,16 +1,15 @@ let board = [ [-3, -5, -4, -2, -1, -4, -5, -3], [-6, -6, -6, -6, -6, -6, -6, -6], + [0, 0, -5, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 2, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [6, 6, 6, 6, 6, 6, 6, 6], [3, 5, 4, 2, 1, 4, 5, 3], ] - -//console.log(move(board, 1, 0)) +//console.log(move(board, 4, 3)) //move(board, 3, 3) function move(board, y, x) { @@ -45,10 +44,8 @@ function pawn_move(board, y, x) { if (board[y - 2][x] == 0) { moves.push([y - 2, x]) } - } else if (color && y != 0) { - if (board[y - 1][x] == 0) { - moves.push([y - 1, x]) - } + } else if (color && y != 0 && board[y - 1][x] == 0) { + moves.push([y - 1, x]) } return moves @@ -60,10 +57,8 @@ function pawn_move(board, y, x) { if (board[y + 2][x] == 0) { moves.push([y + 2, x]) } - } else if (color && y != 7) { - if (board[y + 1][x] == 0) { - moves.push([y + 1, x]) - } + } else if (color && y != 7 && board[y + 1][x] == 0) { + moves.push([y + 1, x]) } return moves } |