From 7adda138e37376a9f0d8d1b87cb523372f6dcee2 Mon Sep 17 00:00:00 2001 From: Damian-I Date: Sun, 9 Mar 2025 15:33:51 +0000 Subject: [PATCH] Enhance inventory item uniqueness check with item identifier --- index.html | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index a2a6615..e708306 100644 --- a/index.html +++ b/index.html @@ -2886,10 +2886,16 @@ } try { - // Check if the item is already in the inventory - const isAlreadyInInventory = inventory.items.some(item => item.name === sprite.name); + // Check if the item is already in the inventory using the unique identifier + const itemIdentifier = createItemIdentifier(sprite.scenarioData); + console.log(`Checking if item ${itemIdentifier} is already in inventory`); + + const isAlreadyInInventory = inventory.items.some(item => + createItemIdentifier(item.scenarioData) === itemIdentifier + ); + if (isAlreadyInInventory) { - console.log(`Item ${sprite.name} is already in inventory, not adding again`); + console.log(`Item ${itemIdentifier} is already in inventory, not adding again`); return false; }