mirror of
https://github.com/cliffe/BreakEscape.git
synced 2026-02-21 11:18:08 +00:00
bluetooth remade for "carry unlock"
This commit is contained in:
@@ -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"
|
||||
},
|
||||
{
|
||||
|
||||
42
index.html
42
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
|
||||
);
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user