mirror of
https://github.com/cliffe/BreakEscape.git
synced 2026-02-20 13:50:46 +00:00
Merge branch 'main' into 7-cyberchef-integration
This commit is contained in:
83
index.html
83
index.html
@@ -1406,23 +1406,41 @@
|
||||
let message = `${data.name}\n\n`;
|
||||
message += `Observations: ${data.observations}\n\n`;
|
||||
|
||||
// Check for locked state in scenarioData
|
||||
if (data.locked === true) {
|
||||
console.log('Item is locked:', data);
|
||||
handleUnlock(sprite, 'item');
|
||||
if (distanceSq > INTERACTION_RANGE_SQ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const data = sprite.scenarioData;
|
||||
let message = `${data.name}\n\n`;
|
||||
message += `Observations: ${data.observations}\n\n`;
|
||||
|
||||
// Check for locked state in scenarioData
|
||||
if (data.locked === true) {
|
||||
console.log('Item is locked:', data);
|
||||
handleUnlock(sprite, 'item');
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.readable && data.text) {
|
||||
message += `Text: ${data.text}\n\n`;
|
||||
}
|
||||
|
||||
// Only handle contents if they exist and haven't been collected yet
|
||||
if (data.contents && data.contents.length > 0) {
|
||||
message += `You found the following items:\n`;
|
||||
data.contents.forEach(item => {
|
||||
message += `- ${item.name}\n`;
|
||||
});
|
||||
alert(message);
|
||||
|
||||
if (data.readable && data.text) {
|
||||
message += `Text: ${data.text}\n\n`;
|
||||
}
|
||||
|
||||
if (data.contents && !data.locked) {
|
||||
// Handle container contents
|
||||
message += `You found the following items:\n`;
|
||||
data.contents.forEach(item => {
|
||||
message += `- ${item.name}\n`;
|
||||
// Add all contents to inventory
|
||||
data.contents.forEach(item => {
|
||||
const contentSprite = createInventorySprite({
|
||||
...item,
|
||||
type: item.type.toLowerCase()
|
||||
});
|
||||
|
||||
alert(message);
|
||||
|
||||
// Add all contents to inventory
|
||||
@@ -1847,22 +1865,36 @@
|
||||
// Handle item unlocking
|
||||
if (lockable.scenarioData) {
|
||||
lockable.scenarioData.locked = false;
|
||||
// Set new state for containers with contents
|
||||
if (lockable.scenarioData.contents) {
|
||||
lockable.scenarioData.isUnlockedButNotCollected = true;
|
||||
}
|
||||
} else {
|
||||
lockable.locked = false;
|
||||
}
|
||||
|
||||
// If the item has contents, make them accessible
|
||||
if (lockable.scenarioData?.contents) {
|
||||
lockable.scenarioData.contents.forEach(item => {
|
||||
const sprite = createInventorySprite(item);
|
||||
if (sprite) {
|
||||
addToInventory(sprite);
|
||||
}
|
||||
});
|
||||
if (lockable.contents) {
|
||||
lockable.isUnlockedButNotCollected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function collectContainerContents(container) {
|
||||
if (!container.scenarioData?.contents ||
|
||||
!container.scenarioData?.isUnlockedButNotCollected) {
|
||||
return;
|
||||
}
|
||||
|
||||
container.scenarioData.contents.forEach(item => {
|
||||
const sprite = createInventorySprite(item);
|
||||
if (sprite) {
|
||||
addToInventory(sprite);
|
||||
}
|
||||
});
|
||||
|
||||
container.scenarioData.isUnlockedButNotCollected = false;
|
||||
alert('You collected the items from the container.');
|
||||
}
|
||||
|
||||
// Helper function to create inventory sprites for unlocked container contents
|
||||
function createInventorySprite(itemData) {
|
||||
const scene = game.scene.scenes[0]; // Get the main scene
|
||||
@@ -2034,10 +2066,11 @@
|
||||
function getLockRequirementsForItem(item) {
|
||||
return {
|
||||
lockType: item.lockType || item.scenarioData?.lockType,
|
||||
requires: item.requires || item.scenarioData?.requires
|
||||
requires: item.requires || item.scenarioData?.requires,
|
||||
isUnlockedButNotCollected: false
|
||||
};
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
Reference in New Issue
Block a user