import { board } from "../board.js" import { Vector2 } from "../engine/vector2.js" import { Link } from "../link.js" import { isMoveLegal } from "../engine/moves.js" import { playerTurn } from "../engine/turns.js" export 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, }) }