From 3bb16882e400f2357f6049d78668db5de3b4235d Mon Sep 17 00:00:00 2001 From: Damian-I Date: Tue, 25 Feb 2025 14:21:02 +0000 Subject: [PATCH] Fixed win condition --- index.html | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index 7f016cd..cca179c 100644 --- a/index.html +++ b/index.html @@ -3235,16 +3235,7 @@ pin.style.background = '#0f0'; } - if (gameState.currentBindingIndex >= numPins) { - setTimeout(() => { - unlockTarget(lockable, 'door', lockable.layer); - alert("Lock successfully picked!"); - document.body.removeChild(iframe); - if (currentScene && currentScene.input && currentScene.input.mouse) { - currentScene.input.mouse.enabled = true; - } - }, 500); - } + checkWinCondition(); } }, 500); // Need to hold for 500ms to set } else if (gameState.pinStates[i] !== 2) { @@ -3315,6 +3306,22 @@ if (currentScene && currentScene.input && currentScene.input.mouse) { currentScene.input.mouse.enabled = false; } + + // Add this function before the pin creation loop + function checkWinCondition() { + if (gameState.currentBindingIndex >= numPins) { + setTimeout(() => { + unlockTarget(lockable, 'door', lockable.layer); + alert("Lock successfully picked!"); + document.body.removeChild(iframe); + if (currentScene && currentScene.input && currentScene.input.mouse) { + currentScene.input.mouse.enabled = true; + } + }, 500); + return true; + } + return false; + } }