summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgrisBRC <[email protected]>2024-07-13 10:04:03 +0530
committerIgrisBRC <[email protected]>2024-07-13 10:04:03 +0530
commit05c8eb09a60791e37736053f6ce03ea4f36f8e42 (patch)
tree0e3807041679899f57f93e0e974d7ee1233d44bc
parent50f7035097dba83eb29cbe1dda87d4f2ddc62c3a (diff)
fixed move function to look better, and I don't know how to enums in JS
-rw-r--r--app.js20
1 files changed, 5 insertions, 15 deletions
diff --git a/app.js b/app.js
index f988614..1122bed 100644
--- a/app.js
+++ b/app.js
@@ -9,37 +9,27 @@ let board = [
[0, 0, 0, 0, 0, 0, 0, 0],
]
-//console.log(move(board, 1, 0))
+
+console.log(move(board, 1, 0))
//move(board, 3, 3)
function move(board, y, x) {
- switch (board[y][x]) {
+ let piece = Math.abs(board[y][x])
+ switch (piece) {
case 0:
return []
case 1:
return king_move(board, y, x)
- case -1:
- return king_move(board, y, x)
case 2:
return amelia_move(board, y, x)
- case -2:
- return amelia_move(board, y, x)
case 3:
return rook_move(board, y, x)
- case -3:
- return rook_move(board, y, x)
case 4:
return bishop_move(board, y, x)
- case -4:
- return bishop_move(board, y, x)
case 5:
return knight_move(board, y, x)
- case -5:
- return knight_move(board, y, x)
case 6:
return pawn_move(board, y, x)
- case -6:
- return pawn_move(board, y, x)
}
}
@@ -373,4 +363,4 @@ function amelia_move(board, y, x) {
return moves
}
-export {move}
+export { move }