summaryrefslogtreecommitdiff
path: root/public/make_move.js
diff options
context:
space:
mode:
authorIgrisBRC <[email protected]>2024-07-17 18:09:36 +0530
committerGitHub <[email protected]>2024-07-17 18:09:36 +0530
commit5123593638f73239de9a1bb1bd287b1d0e87daaf (patch)
tree95d038d23db29777d8f3d433cbcbe64f64c1bcfd /public/make_move.js
parenta7e11ff8f729a669d8b2445f066606302ecb1b46 (diff)
parent438ad19a536dab544b6071c741ab6107bf63dabb (diff)
Merge pull request #5 from ameliasquires/main
fix castling and cleanliness
Diffstat (limited to 'public/make_move.js')
-rw-r--r--public/make_move.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/public/make_move.js b/public/make_move.js
index e00b999..6233ed0 100644
--- a/public/make_move.js
+++ b/public/make_move.js
@@ -17,6 +17,21 @@ function make_move(board, prev_y_x, new_y_x) {
}
for (let i = 0; i < prev_y_x.length; i++) {
+ let color = board[prev_y_x[i][0]][prev_y_x[i][1]] > 0
+
+ if(Math.abs(board[prev_y_x[i][0]][prev_y_x[i][1]]) == 1){
+ if(color) castle_white_short = castle_white_long = false
+ else castle_black_short = castle_black_long = false
+ } else if(Math.abs(board[prev_y_x[i][0]][prev_y_x[i][1]]) == 3){
+ if(prev_y_x[i][1] == 0){
+ if(color) castle_white_long = false
+ else castle_black_long = false
+ } else if (prev_y_x[i][1] == 7){
+ if(color) castle_white_short = false
+ else castle_black_short = false
+ }
+ }
+
board[prev_y_x[i][0]][prev_y_x[i][1]] = 0
}
}