From 4194b03e980ac68e0fd07e183189fbe93dfefdce Mon Sep 17 00:00:00 2001 From: IgrisBRC Date: Sun, 14 Jul 2024 13:43:36 +0530 Subject: finnnallyyyy... added make move to the game, its a bit shitty, i'll make it prettier later --- public/sync_board.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'public/sync_board.js') diff --git a/public/sync_board.js b/public/sync_board.js index 629cae6..c56cb77 100644 --- a/public/sync_board.js +++ b/public/sync_board.js @@ -1,16 +1,18 @@ -function sync_board(){ - let table = {1:'K', 2:'Q', 3:'R', 4:'B', 5:'N', 6:'p'} +function sync_board() { + + let table = { 1: 'K', 2: 'Q', 3: 'R', 4: 'B', 5: 'N', 6: 'p' } - for(let i = 0; i < 8; i++){ - for(let j = 0; j < 8; j++){ - if(board[i][j] == 0) continue + for (let i = 0; i < 8; i++) { + for (let j = 0; j < 8; j++) { + if (board[i][j] == 0) continue let square = document.getElementById(`${alphabet.charAt(j)}${8 - i}`) let piece = document.createElement('p') - piece.classList.add(board[i][j] > 0 ? 'w' : 'b') + piece.classList.add(board[i][j] > 0 ? 'w' : 'b', 'piece') square.append(piece) piece.append(table[Math.abs(board[i][j])]) } } -} \ No newline at end of file + console.log(board) +} -- cgit v1.2.3