diff options
author | nil <niljo@airmail.cc> | 2024-12-14 21:38:07 +0100 |
---|---|---|
committer | nil <niljo@airmail.cc> | 2024-12-14 21:38:07 +0100 |
commit | add682d6aaa50b2c1561731cdb1696bf7665cba3 (patch) | |
tree | 81bbb91e40d3aa537f41ab884ff4f7dd13d113c9 /src/engine/turns.js | |
parent | 1b6275b4fbc4ab7bcd876938f807aad9ce1900a6 (diff) |
liberty fix and tidying code
Diffstat (limited to 'src/engine/turns.js')
-rw-r--r-- | src/engine/turns.js | 37 |
1 files changed, 1 insertions, 36 deletions
diff --git a/src/engine/turns.js b/src/engine/turns.js index ee5b9e2..0018417 100644 --- a/src/engine/turns.js +++ b/src/engine/turns.js @@ -1,8 +1,5 @@ -import { board } from "../board.js" -import { Vector2 } from "../engine/vector2.js" -import { Link } from "../link.js" import { PLAYER } from "../constants.js" -import { isMoveLegal } from "../engine/moves.js" +import { placeLinks } from "../engine/placeLinks.js" export let playerTurn = "" @@ -15,35 +12,3 @@ function changeTurn() { playerTurn = playerTurn == PLAYER.BLACK ? PLAYER.WHITE : PLAYER.BLACK } -function placeLinks() { - resetLink() - board.links = [...Array(board.size)].map(_ => Array(board.size)) - for (let row = 0; row < board.size; row++) { - for (let col = 0; col < board.size; col++) { - tryLink(new Vector2(row, col)) - } - } -} - -function resetLink() { - Array.from(board.links).forEach(x => { - Array.from(x) - .filter((x) => x !== undefined) - .map(y => { - y.removeLink() - }) - }) -} - -function tryLink(position) { - if (!isMoveLegal({ - position: position, - team: playerTurn - })) { - return - } - - new Link({ - position: position, - }) -} |