Fixed win condition

This commit is contained in:
Damian-I
2025-02-25 14:21:02 +00:00
parent 9b180a84fd
commit 3bb16882e4

View File

@@ -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;
}
}
</script>