summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgrisBRC <[email protected]>2024-07-15 11:22:02 +0530
committerIgrisBRC <[email protected]>2024-07-15 11:22:02 +0530
commitff3f02dddcb979da7c5df14ba0279f5968c9e7d8 (patch)
treed6232df8bc754dc4f12db2a010376a5270ff13ea
parent57e8e55e1e5d72011971f3010fa2b584d1d8f16d (diff)
fixed fault functionality, by changing for charAt to charCodeAt
-rw-r--r--public/board.js15
-rw-r--r--public/move.js4
2 files changed, 10 insertions, 9 deletions
diff --git a/public/board.js b/public/board.js
index bc76394..c5f1fc7 100644
--- a/public/board.js
+++ b/public/board.js
@@ -15,27 +15,28 @@ function handle_highlight(i) {
let id = squares[i].id
- let moves = move(board, id.charAt(0), id.charAt(1), to_move)
+ let moves = move(board, id.charCodeAt(0) - 48, id.charCodeAt(1) - 48, to_move)
for (let i = 0; i < previously_highlighted_squares.length; i++) {
let prev = document.getElementById(previously_highlighted_squares[i])
prev.classList.remove('highlight')
+ prev.onclick = null
}
for (let i = 0; i < moves.length; i++) {
let hlsquare = document.getElementById(`${moves[i][0]}${moves[i][1]}`)
hlsquare.classList.add('highlight')
- hlsquare.onclick = handle_move(hlsquare.id)
previously_highlighted_squares.push(`${moves[i][0]}${moves[i][1]}`)
}
- }
-}
-function handle_move(id) {
- return function() {
- console.log(id)
}
}
+//function handle_move(id) {
+// return function() {
+// console.log(id)
+// }
+//}
+//
diff --git a/public/move.js b/public/move.js
index 51b585c..ee527c6 100644
--- a/public/move.js
+++ b/public/move.js
@@ -11,8 +11,8 @@ let board = [
let to_move = true //white to move
-//console.log(move(board, 4, 3))
-//move(board, 3, 3)
+//console.log(board[7][1])
+//console.log(move(board, 7, 1, to_move))
function move(board, y, x, to_move) {
if (to_move ^ board[y][x] > 0) {