From ee215beeeb510d448ef1bdbb5267599b5dcae594 Mon Sep 17 00:00:00 2001 From: Damian-I Date: Fri, 7 Mar 2025 14:09:58 +0000 Subject: [PATCH] Improved lockpicking success handling for doors and containers --- index.html | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index e1b2422..a66a34b 100644 --- a/index.html +++ b/index.html @@ -3324,14 +3324,27 @@ // Add this function before the pin creation loop function checkWinCondition() { if (gameState.currentBindingIndex >= numPins) { - // Update the lockable object's state to be unlocked but not collected - if (lockable.scenarioData) { + console.log('Lock picked successfully:', lockable); + + // For doors, we need to check properties and handle differently + if (lockable && lockable.properties && lockable.properties.locked) { + console.log('Unlocking door tile:', lockable); + unlockDoor(lockable, lockable.layer); + alert("Lock successfully picked! The door is now unlocked."); + } + // For containers and other lockable items + else if (lockable.scenarioData) { + console.log('Unlocking container:', lockable.scenarioData); lockable.scenarioData.locked = false; - lockable.scenarioData.isUnlockedButNotCollected = true; + + if (lockable.scenarioData.contents) { + lockable.scenarioData.isUnlockedButNotCollected = true; + alert("Lock successfully picked! You can now interact with it to collect the contents."); + } else { + alert("Lock successfully picked!"); + } } - unlockTarget(lockable, 'door', lockable.layer); - alert("Lock successfully picked! You can now interact with it to collect the contents."); document.body.removeChild(iframe); if (currentScene && currentScene.input && currentScene.input.mouse) { currentScene.input.mouse.enabled = true;