diff options
Diffstat (limited to 'public')
-rw-r--r-- | public/board.js | 15 | ||||
-rw-r--r-- | public/move.js | 4 |
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) { |