recruit line

This commit is contained in:
2026-05-05 22:25:02 +03:00
parent 0743df0eeb
commit 7e98f1292e
6 changed files with 35 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ window.fetchTowns = async function() {
if (window.selectedTownId) {
window.renderBuildQueuePreview();
window.renderUnitQueuePreview();
window.renderBuildingDropdown();
window.renderUnitDropdown();
window.renderTownDetails();

View File

@@ -489,3 +489,27 @@ window.renderBuildQueuePreview = function() {
}).join('');
el.innerHTML = `<div style="margin-top:6px;color:#888;font-size:0.72rem;text-transform:uppercase;letter-spacing:0.5px;margin-bottom:4px;">Current queue</div>${items}`;
};
window.renderUnitQueuePreview = function() {
const town = window.getSelectedTown();
const el = document.getElementById('unit-queue-preview');
if (!el) return;
if (!town || !town.unit_queue || !town.unit_queue.length) {
el.innerHTML = '<span style="color:#444">Recruit queue: empty</span>';
return;
}
const items = town.unit_queue.map(o => {
const raw = o.unit_type || o.unit_id || 'unknown';
const nameGr = window.UNIT_NAMES_GR ? (window.UNIT_NAMES_GR[raw] || raw) : raw;
const total = o.count || 0;
const left = o.units_left !== undefined ? o.units_left : total;
const countStr = left < total ? `${left}/${total}` : `${total}`;
return `<span style="background: rgba(0,0,0,0.3); padding: 2px 6px; border-radius: 4px; margin-right: 4px; font-size: 0.8rem; display: inline-flex; align-items: center; gap: 4px;">
<span style="color:#fff; font-weight:bold;">${countStr}x</span> ${nameGr}
</span>`;
}).join('');
el.innerHTML = `<div style="margin-top:6px;color:#888;font-size:0.72rem;text-transform:uppercase;letter-spacing:0.5px;margin-bottom:4px;">Recruitment queue</div>${items}`;
};

View File

@@ -87,6 +87,7 @@ window.selectTown = function(id) {
document.getElementById('town-details-panel').style.display = 'block';
window.renderBuildQueuePreview();
window.renderUnitQueuePreview();
window.renderBuildingDropdown();
window.renderUnitDropdown();
window.renderTownDetails();