From d63df81cd67bd51f22f95eb08ab8faa875f3648c Mon Sep 17 00:00:00 2001 From: DiamondNether90 Date: Mon, 6 Apr 2026 07:36:01 +1000 Subject: [PATCH] Hopefully fixed multi-move bug --- index.css | 2 +- index.js | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/index.css b/index.css index 9870690..f701233 100644 --- a/index.css +++ b/index.css @@ -16,4 +16,4 @@ html, body { #board { touch-action: none; -} \ No newline at end of file +} diff --git a/index.js b/index.js index c6147af..418f7c3 100644 --- a/index.js +++ b/index.js @@ -16,8 +16,16 @@ async function getPythonData(path, json) { } } +var draggable = true + +function onDragStart(source, piece, position, orientation) { + if (!draggable) return false +} + function onDrop(source, target, piece, newPos, oldPos, orientation) { if (source == target || moves.length === 10) return 'snapback'; + if (draggable == false) return + draggable = false getPythonData("https://honey-motel.bnr.la/app/move", { uci: source + target, fen: fen }) .then(result => { board.position(result.fen) @@ -26,9 +34,10 @@ function onDrop(source, target, piece, newPos, oldPos, orientation) { moves.push(result.san) document.getElementById("guess"+guessNum+"ply"+moves.length).innerText = result.san }) + draggable = true } -let answer = ["Nf3", "f6", "e3", "d5", "Ng5", "fxg5", "Qh5+", "g6", "Qe5", "Be6"] +let answer = ["Nh3", "h6", "e3", "e6", "Nc3", "c6", "Nf4", "Bb4", "Nh5", "g6"] function validateGuess() { if (moves.length != 10) return; @@ -68,4 +77,6 @@ const board = Chessboard('board', { pieceTheme: './pieces/{piece}.png', draggable: true, onDrop: onDrop, + onDragStart: onDragStart }); +