From 2aeaf31af78f5dac55e9be50df05803b117379e7 Mon Sep 17 00:00:00 2001 From: Damian-I Date: Sat, 1 Feb 2025 02:23:36 +0000 Subject: [PATCH] Refactor workstation interaction and inventory handling - Renamed `customInteraction` to `openCryptoWorkstation` for clarity - Simplified inventory sprite creation by removing type normalization - Updated interaction logging to reflect new method name - Preserved custom workstation interaction when moving to inventory --- index.html | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index f8c592e..9277e97 100644 --- a/index.html +++ b/index.html @@ -244,7 +244,7 @@ workstationSprite.setInteractive({ useHandCursor: true }); // Override the default handleObjectInteraction for this specific item - workstationSprite.customInteraction = function() { + workstationSprite.openCryptoWorkstation = function() { // console.log('CyberChef: Workstation custom interaction triggered'); // Create popup let popup = document.getElementById('laptop-popup'); @@ -1376,10 +1376,10 @@ // handles interactions with objects // displays the object's data in an alert function handleObjectInteraction(sprite) { - console.log('CyberChef: handleObjectInteraction called for:', sprite.name, 'Has custom interaction:', !!sprite.customInteraction); + console.log('CyberChef: handleObjectInteraction called for:', sprite.name, 'Has open workstation:', !!sprite.openCryptoWorkstation); - if (sprite.customInteraction && sprite.customInteraction()) { - console.log('CyberChef: Custom interaction handled'); + if (sprite.openCryptoWorkstation && sprite.openCryptoWorkstation()) { + console.log('CyberChef: Crypto workstation opened'); return; } @@ -1428,10 +1428,7 @@ // Add all contents to inventory data.contents.forEach(item => { // Ensure the item type matches the preloaded asset name - const contentSprite = createInventorySprite({ - ...item, - type: item.type.toLowerCase() // Ensure type matches asset name - }); + const contentSprite = createInventorySprite(item); if (contentSprite) { addToInventory(contentSprite); } @@ -1509,8 +1506,8 @@ inventorySprite.name = sprite.name; // Copy over the custom interaction if it exists - if (sprite.customInteraction) { - inventorySprite.customInteraction = sprite.customInteraction; + if (sprite.openCryptoWorkstation) { + inventorySprite.openCryptoWorkstation = sprite.openCryptoWorkstation; } // Set depth higher than container