import { WindowManager } from './window_manager.js'; export const PetsOverlay = { open() { // Position next to others const { win, content } = WindowManager.create('window-pets', '🐾 My Pets', { x: 20, y: 340, width: 220, height: 250 }); this.update(content); }, update(container) { if (!container) container = document.getElementById('window-pets-content'); if (!container) return; const MB = window.MagicBot; if (!MB || !MB.state || !MB.state.inventory || !MB.state.inventory.items) { container.innerHTML = '
No Data
'; return; } container.innerHTML = ''; const list = document.createElement('div'); list.style.cssText = "display: flex; flex-direction: column; gap: 8px; font-size: 11px;"; const pets = MB.state.inventory.items.filter(i => i.itemType === 'Pet'); if (pets.length === 0) { container.innerHTML = '
No Pets Found
'; return; } pets.forEach(p => { const row = document.createElement('div'); row.style.cssText = `background: rgba(255,255,255,0.05); padding: 8px; border-radius: 4px; display: flex; flex-direction: column; gap: 2px;`; // Name/Species const name = p.name || p.petSpecies; const species = p.petSpecies; const isAutoFeed = MB.automation && MB.automation.pets && MB.automation.pets[p.id] && MB.automation.pets[p.id].autoFeed; const diets = { 'Bee': ['Strawberry', 'Blueberry', 'Tulip', 'Daffodil', 'Lily'], 'Goat': ['Pumpkin', 'Coconut', 'Cactus', 'Pepper'] }; const diet = diets[species] ? diets[species].join(', ') : 'Unknown Diet'; row.innerHTML = `
${name}
${species} XP: ${p.xp}
Hunger: ${Math.floor(p.hunger || 0)}
Diet: ${diet}
`; // Event listener for checkbox (needs to be attached after innerHTML reflow) // We'll trust the parent re-render or attach globally for now to avoid complexity in this simple render loop. // Actually, let's attach immediately after this loop finishes or use a delegate. list.appendChild(row); }); // Delegate listener list.onchange = (e) => { if (e.target.classList.contains('chk-pet-feed')) { const id = e.target.getAttribute('data-id'); if (!MB.automation.pets) MB.automation.pets = {}; if (!MB.automation.pets[id]) MB.automation.pets[id] = {}; MB.automation.pets[id].autoFeed = e.target.checked; console.log(`[MagicBot] Pet ${id} Auto-Feed: ${e.target.checked}`); } }; container.appendChild(list); } };