summaryrefslogtreecommitdiff
path: root/src/engine/visual
diff options
context:
space:
mode:
authornil <niljo@airmail.cc>2024-12-12 18:20:22 +0100
committernil <niljo@airmail.cc>2024-12-12 18:20:22 +0100
commit16e02376e2273eeb25a6461f84641e96a485f652 (patch)
tree64a1deee7d8fdfda0a75475642364fc1ba4d8500 /src/engine/visual
parent8a49fc718cbfebe593d18dcf37fef2a19f3aa570 (diff)
add legal movements and organize
Diffstat (limited to 'src/engine/visual')
-rw-r--r--src/engine/visual/createBoard.js15
-rw-r--r--src/engine/visual/placeOnBoard.js34
2 files changed, 35 insertions, 14 deletions
diff --git a/src/engine/visual/createBoard.js b/src/engine/visual/createBoard.js
new file mode 100644
index 0000000..06fcf5e
--- /dev/null
+++ b/src/engine/visual/createBoard.js
@@ -0,0 +1,15 @@
+import { board } from "../../board.js"
+
+export 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)
+}
diff --git a/src/engine/visual/placeOnBoard.js b/src/engine/visual/placeOnBoard.js
index cee2969..4eea0d6 100644
--- a/src/engine/visual/placeOnBoard.js
+++ b/src/engine/visual/placeOnBoard.js
@@ -6,17 +6,23 @@ const HEAD_TOP_VH = 20
const MEDIA_LISTENER = window.matchMedia("(max-width: 600px)")
MEDIA_LISTENER.addEventListener("change", function() {
- Array.from(board.stones).forEach(x => {
- Array.from(x).filter((x) => x !== undefined).map(y => {
- y.update(MEDIA_LISTENER)
- })
- })
-
- Array.from(board.links).forEach(x => {
- Array.from(x).filter((x) => x !== undefined).map(y => {
- y.update(MEDIA_LISTENER)
- })
- })
+ Array.from(board.stones)
+ .forEach(x => {
+ Array.from(x)
+ .filter((x) => x !== undefined)
+ .map(y => {
+ y.update(MEDIA_LISTENER)
+ })
+ })
+
+ Array.from(board.links)
+ .forEach(x => {
+ Array.from(x)
+ .filter((x) => x !== undefined)
+ .map(y => {
+ y.update(MEDIA_LISTENER)
+ })
+ })
});
const PLACE_VALUES = {
@@ -34,12 +40,12 @@ const PLACE_VALUES = {
export function placeOnBoard({
position = new Vector2(0, 0),
board_size = 9,
- use_real_size = false,
+ use_link_size = false,
}) {
let response = {}
if (MEDIA_LISTENER.matches) {
let totalSize = (
- use_real_size ?
+ use_link_size ?
PLACE_VALUES.link.size_mob : PLACE_VALUES.stone.size_mob
)
let size = totalSize / board_size
@@ -48,7 +54,7 @@ export function placeOnBoard({
response["size"] = `${size}vw`
} else {
let totalSize = (
- use_real_size ?
+ use_link_size ?
PLACE_VALUES.link.size : PLACE_VALUES.stone.size
)
let size = totalSize / board_size