From cec1da14708e782801d0cc27fb13ff7586c0e96c Mon Sep 17 00:00:00 2001 From: nil Date: Fri, 13 Dec 2024 16:42:57 +0100 Subject: liberty check demo --- src/engine/moves.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/engine/moves.js') diff --git a/src/engine/moves.js b/src/engine/moves.js index f820f97..26158a0 100644 --- a/src/engine/moves.js +++ b/src/engine/moves.js @@ -1,11 +1,17 @@ import { board } from "../board.js" +import { hasLiberties } from "./liberty.js" export function isMoveLegal({ position, - turn = "none" + team = "none" }) { if (board.stones[position.y][position.x] != undefined) { return false } + + if (!hasLiberties({position: position, team: team})) { + return false + } + return true } -- cgit v1.2.3