mirror of
https://github.com/cliffe/BreakEscape.git
synced 2026-02-21 11:18:08 +00:00
Add files via upload
Fixed bug causing game to not load, #10 needs to be semi re-implemented
This commit is contained in:
95
index.html
95
index.html
@@ -1406,52 +1406,35 @@
|
||||
let message = `${data.name}\n\n`;
|
||||
message += `Observations: ${data.observations}\n\n`;
|
||||
|
||||
if (distanceSq > INTERACTION_RANGE_SQ) {
|
||||
// Check for locked state in scenarioData
|
||||
if (data.locked === true) {
|
||||
console.log('Item is locked:', data);
|
||||
handleUnlock(sprite, 'item');
|
||||
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);
|
||||
|
||||
// Add all contents to inventory
|
||||
data.contents.forEach(item => {
|
||||
const contentSprite = createInventorySprite({
|
||||
...item,
|
||||
type: item.type.toLowerCase()
|
||||
if (data.readable && data.text) {
|
||||
message += `Text: ${data.text}\n\n`;
|
||||
}
|
||||
|
||||
if (data.contents && data.contents.length > 0) {
|
||||
message += `You found the following items:\n`;
|
||||
data.contents.forEach(item => {
|
||||
message += `- ${item.name}\n`;
|
||||
});
|
||||
|
||||
alert(message);
|
||||
|
||||
// Add all contents to inventory
|
||||
data.contents.forEach(item => {
|
||||
// Ensure the item type matches the preloaded asset name
|
||||
const contentSprite = createInventorySprite(item);
|
||||
const contentSprite = createInventorySprite({
|
||||
...item,
|
||||
type: item.type.toLowerCase()
|
||||
});
|
||||
if (contentSprite) {
|
||||
addToInventory(contentSprite);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Clear contents after adding to inventory
|
||||
data.contents = [];
|
||||
return;
|
||||
@@ -1875,24 +1858,17 @@
|
||||
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);
|
||||
|
||||
// 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
container.scenarioData.isUnlockedButNotCollected = false;
|
||||
alert('You collected the items from the container.');
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to create inventory sprites for unlocked container contents
|
||||
@@ -2071,6 +2047,23 @@
|
||||
};
|
||||
}
|
||||
|
||||
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.');
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user