diff options
author | niliara-edu <nil.jimeno@estudiant.fjaverianas.com> | 2024-12-04 18:45:06 +0100 |
---|---|---|
committer | niliara-edu <nil.jimeno@estudiant.fjaverianas.com> | 2024-12-04 18:45:06 +0100 |
commit | eac306447294863b3c5591c2f51b1e76bd257de1 (patch) | |
tree | 331a7e64583661acf04e4b3bdd0d4396e0be3927 /src/board.js |
visuals
Diffstat (limited to 'src/board.js')
-rw-r--r-- | src/board.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/board.js b/src/board.js new file mode 100644 index 0000000..3a0edd9 --- /dev/null +++ b/src/board.js @@ -0,0 +1,26 @@ +export let board = { + element: document.getElementById("board"), + size: 9, + stones: {}, +} + +export function prepareBoard() { + board.stones = [...Array(board.size)].map(_ => Array(board.size)) + createBoard(board.size) +} + +// ########### board engine ############# + +function createBoard(size) { + let table = document.createElement("table") + for (let r = 1; r < size; r++) { + let tr = document.createElement("tr") + + for (let c = 1; c < size; c++) { + let td = document.createElement("td") + tr.appendChild(td) + } + table.appendChild(tr) + } + board.element.appendChild(table) +} |