diff options
author | IgrisBRC <[email protected]> | 2024-07-20 11:24:15 +0530 |
---|---|---|
committer | IgrisBRC <[email protected]> | 2024-07-20 11:24:15 +0530 |
commit | fce0d5b41707facbc2c50b074fe63002b2e3611c (patch) | |
tree | 5fa38b41baa3d6548f00e033f788ff7d4ba1916e /public/board.js | |
parent | bec75ae5ebcc8c5df9b0be3115370ed7013127a1 (diff) |
made en passant, there might be bugs but I haven't found them yet
Diffstat (limited to 'public/board.js')
-rw-r--r-- | public/board.js | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/public/board.js b/public/board.js index bd39363..785efff 100644 --- a/public/board.js +++ b/public/board.js @@ -56,8 +56,7 @@ function handle_move(from_id, to_id) { prev_y_x.push([from_y, from_x]) new_y_x.push([to_y, to_x]) - if(Math.abs(from) == 1 && to == 0){ - console.log("valid") + if (Math.abs(from) == 1 && to == 0) { if (castle_white_short && from_color && to_y == 7 && to_x == 6) { //white short prev_y_x.push([7, 7]) new_y_x.push([7, 5]) @@ -101,6 +100,24 @@ function handle_move(from_id, to_id) { make_move(board, prev_y_x, new_y_x) + if (en_passant_move >= 0) { + if (from_color) { + let passanted_pawn = document.getElementById(`3${en_passant_move}`) + + while (passanted_pawn.firstChild) { + passanted_pawn.removeChild(passanted_pawn.firstChild) + } + } else { + let passanted_pawn = document.getElementById(`4${en_passant_move}`) + + while (passanted_pawn.firstChild) { + passanted_pawn.removeChild(passanted_pawn.firstChild) + } + } + + en_passant_move = -1 + } + let from_element = document.getElementById(from_id) let to_element = document.getElementById(to_id) |