// ================================================================ // Command Form Component // ================================================================ window.onCmdTypeChange = function() { const type = document.getElementById('cmd-type').value; document.getElementById('build-options').style.display = type === 'build' ? '' : 'none'; document.getElementById('recruit-options').style.display = type === 'recruit' ? '' : 'none'; document.getElementById('amount-group').style.display = type === 'recruit' ? '' : 'none'; }; window.renderBuildingDropdown = function() { const town = window.getSelectedTown(); if (!town) return; const bSelect = document.getElementById('building-select'); const bLevels = town.buildings || {}; const currentVal = bSelect.value; bSelect.innerHTML = ''; for (const [key, nameGr] of Object.entries(window.BUILDING_NAMES_GR)) { const level = bLevels[key] !== undefined ? bLevels[key] : "?"; const option = document.createElement('option'); option.value = key; option.textContent = `${nameGr} [Επίπεδο ${level}]`; bSelect.appendChild(option); } if (currentVal && Array.from(bSelect.options).some(o => o.value === currentVal)) { bSelect.value = currentVal; } }; window.renderBuildQueuePreview = function() { const town = window.getSelectedTown(); const el = document.getElementById('build-queue-preview'); if (!town || !town.build_queue || !town.build_queue.length) { el.innerHTML = 'Build queue: empty'; return; } const items = town.build_queue.map(o => `${o.building_type || o.name || JSON.stringify(o)}` ).join(''); el.innerHTML = `
Current queue
${items}`; };