From 0db7a7e4a6bb399b8d6678555196f06c037645e9 Mon Sep 17 00:00:00 2001 From: Damian-I Date: Thu, 13 Mar 2025 02:20:48 +0000 Subject: [PATCH] bluetooth remade for "carry unlock" --- assets/scenarios/ceo_exfil.json | 3 ++- index.html | 42 +++++++++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/assets/scenarios/ceo_exfil.json b/assets/scenarios/ceo_exfil.json index ea4b4ba..8048d26 100644 --- a/assets/scenarios/ceo_exfil.json +++ b/assets/scenarios/ceo_exfil.json @@ -131,7 +131,8 @@ "type": "pc", "name": "IT Staff Computer", "takeable": false, - "requires": "password", + "requires": "bluetooth", + "mac": "00:11:22:33:44:55", "observations": "An IT staff computer showing network security logs" }, { diff --git a/index.html b/index.html index c7dfd2c..1c77b10 100644 --- a/index.html +++ b/index.html @@ -3372,9 +3372,12 @@ } break; - case 'bluetooth': + case 'bluetooth': if (lockable.scenarioData?.locked) { - // Allow the item to be picked up even if locked + // Check if we have a matching Bluetooth device in the current room + const matchFound = findMatchingBluetoothDevice(lockable); + + // Allow the item to be picked up regardless of match if it's takeable if (type === 'item' && lockable.scenarioData?.takeable) { // Check if the item is already in the inventory before adding it const isAlreadyInInventory = inventory.items.some(item => item.name === lockable.name); @@ -3386,11 +3389,27 @@ delete rooms[currentRoom].objects[lockable.name]; } } + + // Only unlock if there's a matching device + if (matchFound) { + unlockTarget(lockable, type, lockable.layer); + gameAlert(`Bluetooth connection established with ${matchFound.name}`, 'success', 'Bluetooth Connected', 3000); + } else { + gameAlert('Item added to inventory but still locked - no matching Bluetooth device in range', 'warning', 'Partial Success', 3000); + return; + } + } else if (matchFound) { + // For non-takeable items, only proceed if there's a match + unlockTarget(lockable, type, lockable.layer); + gameAlert(`Bluetooth connection established with ${matchFound.name}`, 'success', 'Bluetooth Connected', 3000); + } else { + gameAlert('No matching Bluetooth device in range', 'error', 'Connection Failed', 3000); + return; } - return; } + console.log('Bluetooth processing complete'); break; - + default: gameAlert(`Requires: ${lockRequirements.requires}`, 'warning', 'Locked', 4000); } @@ -6368,6 +6387,21 @@ } } + // Function to find a matching Bluetooth device in the current room + function findMatchingBluetoothDevice(device) { + if (!device.scenarioData?.mac || !currentRoom) return null; + + const targetMac = device.scenarioData.mac; + const roomObjects = Object.values(rooms[currentRoom].objects || {}); + + // Find any object in the current room with a matching MAC address + return roomObjects.find(obj => + obj.scenarioData?.mac && + obj.scenarioData.mac === targetMac && + obj.name !== device.name // Ensure it's not the same device + ); + } + \ No newline at end of file