pop35
This commit is contained in:
parent
71dd938144
commit
25671fda3d
@ -139,7 +139,7 @@ async function loadInventory() {
|
||||
================================ */
|
||||
|
||||
function initDrag() {
|
||||
document.querySelectorAll(".inventory-slot").forEach((item) => {
|
||||
document.querySelectorAll(".inventory-slot:not(.empty)").forEach((item) => {
|
||||
item.addEventListener("dragstart", (e) => {
|
||||
e.dataTransfer.setData("itemId", item.dataset.id);
|
||||
e.dataTransfer.setData("itemLevel", item.dataset.level);
|
||||
@ -217,18 +217,18 @@ function initDrop() {
|
||||
if (existing) {
|
||||
const grid = document.getElementById("inventory-grid");
|
||||
|
||||
const newItem = document.createElement("div");
|
||||
const emptySlot = grid.querySelector(".inventory-slot.empty");
|
||||
|
||||
newItem.classList.add("inventory-slot");
|
||||
newItem.setAttribute("draggable", "true");
|
||||
if (emptySlot) {
|
||||
emptySlot.classList.remove("empty");
|
||||
|
||||
newItem.dataset.id = existing.dataset.id;
|
||||
newItem.dataset.level = existing.dataset.level;
|
||||
newItem.dataset.slot = existing.dataset.slot;
|
||||
emptySlot.dataset.id = existing.dataset.id;
|
||||
emptySlot.dataset.level = existing.dataset.level;
|
||||
emptySlot.dataset.slot = existing.dataset.slot;
|
||||
emptySlot.setAttribute("draggable", "true");
|
||||
|
||||
newItem.innerHTML = `<img src="${existing.src}">`;
|
||||
|
||||
grid.appendChild(newItem);
|
||||
emptySlot.innerHTML = `<img src="${existing.src}">`;
|
||||
}
|
||||
}
|
||||
|
||||
/* neues Item setzen */
|
||||
@ -297,7 +297,20 @@ function initInventoryDrop() {
|
||||
|
||||
newItem.innerHTML = `<img src="${img.src}">`;
|
||||
|
||||
grid.appendChild(newItem);
|
||||
const emptySlot = grid.querySelector(".inventory-slot.empty");
|
||||
|
||||
if (emptySlot) {
|
||||
emptySlot.classList.remove("empty");
|
||||
|
||||
emptySlot.dataset.id = itemId;
|
||||
emptySlot.dataset.level = itemLevel;
|
||||
emptySlot.dataset.slot = slotName;
|
||||
emptySlot.setAttribute("draggable", "true");
|
||||
|
||||
emptySlot.innerHTML = `<img src="${img.src}">`;
|
||||
}
|
||||
|
||||
initDrag();
|
||||
|
||||
/* Slot leeren */
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user