pop26
This commit is contained in:
parent
1197161df4
commit
e96781f141
@ -77,6 +77,8 @@ async function loadEquipment() {
|
|||||||
if (label) {
|
if (label) {
|
||||||
slot.appendChild(label);
|
slot.appendChild(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
slot.classList.add("has-item");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,22 +177,38 @@ function initDrop() {
|
|||||||
const itemSlot = e.dataTransfer.getData("slot");
|
const itemSlot = e.dataTransfer.getData("slot");
|
||||||
|
|
||||||
const targetSlot = slot.dataset.slot;
|
const targetSlot = slot.dataset.slot;
|
||||||
console.log("Item Slot:", itemSlot);
|
|
||||||
console.log("Target Slot:", targetSlot);
|
|
||||||
|
|
||||||
if (itemSlot !== targetSlot) return;
|
if (!itemSlot || itemSlot !== targetSlot) return;
|
||||||
|
|
||||||
const icon = document.querySelector(
|
const item = document.querySelector(
|
||||||
'.inventory-slot[data-id="' + itemId + '"] img',
|
'.inventory-slot[data-id="' + itemId + '"]',
|
||||||
).src;
|
);
|
||||||
|
|
||||||
|
const icon = item.querySelector("img").src;
|
||||||
|
|
||||||
|
/* Wenn Slot schon Item hat */
|
||||||
|
|
||||||
|
const existingItem = slot.querySelector("img");
|
||||||
|
|
||||||
|
if (existingItem) {
|
||||||
|
const inventory = document.getElementById("inventory-grid");
|
||||||
|
|
||||||
|
const newSlot = document.createElement("div");
|
||||||
|
|
||||||
|
newSlot.classList.add("inventory-slot");
|
||||||
|
|
||||||
|
newSlot.innerHTML = `<img src="${existingItem.src}">`;
|
||||||
|
|
||||||
|
inventory.appendChild(newSlot);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Neues Item setzen */
|
||||||
|
|
||||||
const label = slot.querySelector(".slot-label");
|
const label = slot.querySelector(".slot-label");
|
||||||
|
|
||||||
slot.innerHTML = `<img src="${icon}">`;
|
slot.innerHTML = `<img src="${icon}">`;
|
||||||
|
|
||||||
if (label) {
|
if (label) slot.appendChild(label);
|
||||||
slot.appendChild(label);
|
|
||||||
}
|
|
||||||
|
|
||||||
slot.classList.add("has-item");
|
slot.classList.add("has-item");
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user