// ================================================================ // Command Log Component // ================================================================ window.renderLog = function(cmds) { const el = document.getElementById('log-content'); if (!cmds.length) { el.innerHTML = '

No commands sent yet.

'; return; } const rows = cmds.map(cmd => { const p = typeof cmd.payload === 'string' ? JSON.parse(cmd.payload) : cmd.payload; let desc = ''; if (cmd.type === 'build') { desc = `Build: ${p.building_id}`; } else if (cmd.type === 'recruit') { desc = `Recruit: ${p.amount}x ${p.unit_id}`; } else if (cmd.type === 'market_offer') { desc = `Market: ${p.offer} ${p.offer_type} ➞ ${p.demand} ${p.demand_type}`; } const statusClass = `status-${cmd.status}`; const cancelBtn = ``; return ` #${cmd.id} ${cmd.town_name || cmd.town_id} ${desc} ${cmd.status} ${cmd.result_msg || ''} ${cancelBtn} `; }).join(''); el.innerHTML = `${rows}
#TownCommandStatusResult
`; };