// Player Menu & Inventory (Zauberer-Beutel & Profil) (function() { const drawer = document.getElementById('playerDrawer'); const drawerBackdrop = document.getElementById('drawerBackdrop'); const bagBtn = document.getElementById('openBagBtn'); const closeBtn = document.getElementById('closeDrawerBtn'); const bagBadge = document.getElementById('bagBadge'); const bagHouseIcon = document.getElementById('bagHouseIcon'); // Tabs const tabBtns = document.querySelectorAll('.drawer-tab-btn'); const tabPanes = document.querySelectorAll('.drawer-tab-pane'); // Item Detail Card const itemDetailBox = document.getElementById('itemDetailBox'); const itemDetailIcon = document.getElementById('itemDetailIcon'); const itemDetailName = document.getElementById('itemDetailName'); const itemDetailDesc = document.getElementById('itemDetailDesc'); const itemDetailActionBtn = document.getElementById('itemDetailActionBtn'); // House selection buttons const houseBtns = document.querySelectorAll('.house-select-btn'); let currentItem = null; let lumosActive = false; window.togglePlayerDrawer = function() { if (!drawer) return; const isOpen = drawer.classList.contains('open'); if (isOpen) { closePlayerDrawer(); } else { openPlayerDrawer(); } }; window.openPlayerDrawer = function(tabName) { if (!drawer) return; drawer.classList.add('open'); if (drawerBackdrop) drawerBackdrop.classList.add('open'); document.body.style.overflow = 'hidden'; if (window.soundFX) window.soundFX.playStoneSlide(); if (tabName) switchTab(tabName); }; window.closePlayerDrawer = function() { if (!drawer) return; drawer.classList.remove('open'); if (drawerBackdrop) drawerBackdrop.classList.remove('open'); document.body.style.overflow = ''; if (window.soundFX) window.soundFX.playStoneSlide(); }; if (bagBtn) bagBtn.addEventListener('click', window.togglePlayerDrawer); if (closeBtn) closeBtn.addEventListener('click', window.closePlayerDrawer); if (drawerBackdrop) drawerBackdrop.addEventListener('click', window.closePlayerDrawer); window.addEventListener('keydown', (e) => { if (e.key === 'Escape' && drawer && drawer.classList.contains('open')) { window.closePlayerDrawer(); } }); // Tab Switching tabBtns.forEach(btn => { btn.addEventListener('click', () => { const target = btn.dataset.tab; switchTab(target); }); }); function switchTab(tabId) { tabBtns.forEach(b => b.classList.toggle('active', b.dataset.tab === tabId)); tabPanes.forEach(p => p.classList.toggle('active', p.id === tabId)); if (window.soundFX) window.soundFX.playBottleClink(); } // Item Selection in Bag const itemSlots = document.querySelectorAll('.inv-item-slot'); itemSlots.forEach(slot => { slot.addEventListener('click', () => { selectItem(slot); }); }); function selectItem(slot) { itemSlots.forEach(s => s.classList.remove('selected')); slot.classList.add('selected'); const itemId = slot.dataset.itemId; const itemName = slot.dataset.itemName; const itemIcon = slot.dataset.itemIcon; const itemDesc = slot.dataset.itemDesc; const actionLabel = slot.dataset.actionLabel; const action = slot.dataset.action; currentItem = { id: itemId, name: itemName, icon: itemIcon, action: action }; if (itemDetailBox) { itemDetailBox.style.display = 'block'; itemDetailIcon.innerText = itemIcon; itemDetailName.innerText = itemName; itemDetailDesc.innerText = itemDesc; itemDetailActionBtn.innerText = actionLabel || "Benutzen ✨"; itemDetailActionBtn.onclick = () => performItemAction(action); } if (window.soundFX) window.soundFX.playBottleClink(); } function performItemAction(action) { if (action === 'lumos') { lumosActive = !lumosActive; let glow = document.getElementById('lumosLightOverlay'); if (!glow) { glow = document.createElement('div'); glow.id = 'lumosLightOverlay'; glow.className = 'lumos-light'; document.body.appendChild(glow); } glow.classList.toggle('active', lumosActive); itemDetailActionBtn.innerText = lumosActive ? "Nox / Erlöschen 🌑" : "Lumos wirken 💡"; if (window.soundFX) window.soundFX.playKeyChime(); showFloatingToast(lumosActive ? "💡 Lumos! Dein Zauberstab erleuchtet die Kammer." : "🌑 Nox! Das Zauberlicht erlischt."); } else if (action === 'read_scroll') { // Open scroll modal window.closePlayerDrawer(); const modalBackdrop = document.getElementById('modalBackdrop'); const modalTitle = document.getElementById('modalTitle'); const modalText = document.getElementById('modalText'); const modalBtn = document.getElementById('modalBtn'); const modalIcon = document.getElementById('modalIcon'); if (modalBackdrop) { modalIcon.innerText = "📜"; modalTitle.innerText = "Snapes Logik-Rätsel"; modalText.innerHTML = `