This commit is contained in:
cay 2026-04-14 11:57:28 +01:00
parent 75884af315
commit 6ad1149e65

View File

@ -339,7 +339,7 @@ function renderCardOnBoard(slotEl, card, owner) {
slotEl.classList.add('slot-occupied');
applyOwnerStyle(slotEl, owner);
slotEl.innerHTML = card.image
? `<img src="/images/cards/${card.image}" onerror="this.src='/images/items/rueckseite.png'" title="${card.name}" style="width:100%;height:100%;object-fit:cover;border-radius:7px;display:block;">${statsHtml}`
? `<img draggable="false" src="/images/cards/${card.image}" onerror="this.src='/images/items/rueckseite.png'" title="${card.name}" style="width:100%;height:100%;object-fit:cover;border-radius:7px;display:block;pointer-events:none;">${statsHtml}`
: `<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;gap:4px;font-family:Cinzel,serif;padding:4px;"><span style="font-size:18px;">\u2694\uFE0F</span><span style="font-size:9px;color:#f0d9a6;text-align:center;">${card.name}</span></div>${statsHtml}`;
}
@ -694,36 +694,39 @@ function enableBoardDrag() {
if (!isMyZone(idx)) return;
if (!boardState[slot.id]) return;
if (boardState[slot.id].owner !== mySlot) return;
slot.classList.add('board-slot-draggable');
slot.setAttribute('draggable', 'true');
// Event-Listener nur einmal anhängen
if (!slot.dataset.discardListenerAttached) {
slot.dataset.discardListenerAttached = '1';
slot.addEventListener('dragstart', e => {
if (!isMyTurn) { e.preventDefault(); return; }
draggedBoardSlotId = slot.id;
slot.classList.add('dragging');
e.dataTransfer.effectAllowed = 'move';
e.dataTransfer.setData('text/board', slot.id);
});
slot.addEventListener('dragend', () => {
slot.classList.remove('dragging');
draggedBoardSlotId = null;
discardZone.classList.remove('drag-over');
});
}
});
}
function disableBoardDrag() {
document.querySelectorAll('.board-slot-draggable').forEach(slot => {
slot.classList.remove('board-slot-draggable');
slot.classList.remove('board-slot-draggable', 'dragging');
slot.setAttribute('draggable', 'false');
});
}
/* ── Board-Drag via Event-Delegation auf den Rows ────────── */
['row1', 'row2'].forEach(rowId => {
const row = document.getElementById(rowId);
row.addEventListener('dragstart', e => {
const slot = e.target.closest('.board-slot-draggable');
if (!slot || !isMyTurn) { e.preventDefault(); return; }
draggedBoardSlotId = slot.id;
slot.classList.add('dragging');
e.dataTransfer.effectAllowed = 'move';
e.dataTransfer.setData('text/board', slot.id);
});
row.addEventListener('dragend', e => {
const slot = e.target.closest('.board-slot-draggable');
if (slot) slot.classList.remove('dragging');
draggedBoardSlotId = null;
discardZone.classList.remove('drag-over');
});
});
/* ── Karte abwerfen ──────────────────────────────────────── */
function discardBoardCard(slotId) {
const entry = boardState[slotId];