recruit line
This commit is contained in:
@@ -52,6 +52,12 @@ function gatherState() {
|
|||||||
if (bo?.models) buildQueue = bo.models.map(m => m.attributes);
|
if (bo?.models) buildQueue = bo.models.map(m => m.attributes);
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
|
let unitQueue = [];
|
||||||
|
try {
|
||||||
|
const uo = town.getUnitOrdersCollection?.();
|
||||||
|
if (uo?.models) unitQueue = uo.models.map(m => m.attributes);
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
let buildDataMap = {};
|
let buildDataMap = {};
|
||||||
try {
|
try {
|
||||||
const buildDataRaw = uw.MM?.getModels?.()?.BuildingBuildData?.[town.id]?.attributes?.building_data || {};
|
const buildDataRaw = uw.MM?.getModels?.()?.BuildingBuildData?.[town.id]?.attributes?.building_data || {};
|
||||||
@@ -211,6 +217,7 @@ function gatherState() {
|
|||||||
buildings,
|
buildings,
|
||||||
units: unitsObj,
|
units: unitsObj,
|
||||||
buildingOrder: buildQueue,
|
buildingOrder: buildQueue,
|
||||||
|
unitOrder: unitQueue,
|
||||||
buildData: buildDataMap,
|
buildData: buildDataMap,
|
||||||
unitData: unitDataMap,
|
unitData: unitDataMap,
|
||||||
researches,
|
researches,
|
||||||
|
|||||||
@@ -260,6 +260,7 @@ def get_towns():
|
|||||||
'points': d.get('points', 0),
|
'points': d.get('points', 0),
|
||||||
'god': d.get('god', None),
|
'god': d.get('god', None),
|
||||||
'build_queue': d.get('buildingOrder', []),
|
'build_queue': d.get('buildingOrder', []),
|
||||||
|
'unit_queue': d.get('unitOrder', []),
|
||||||
'build_data': d.get('buildData', {}),
|
'build_data': d.get('buildData', {}),
|
||||||
'unit_data': d.get('unitData', {}),
|
'unit_data': d.get('unitData', {}),
|
||||||
'researches': d.get('researches', {}),
|
'researches': d.get('researches', {}),
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ window.fetchTowns = async function() {
|
|||||||
|
|
||||||
if (window.selectedTownId) {
|
if (window.selectedTownId) {
|
||||||
window.renderBuildQueuePreview();
|
window.renderBuildQueuePreview();
|
||||||
|
window.renderUnitQueuePreview();
|
||||||
window.renderBuildingDropdown();
|
window.renderBuildingDropdown();
|
||||||
window.renderUnitDropdown();
|
window.renderUnitDropdown();
|
||||||
window.renderTownDetails();
|
window.renderTownDetails();
|
||||||
|
|||||||
@@ -489,3 +489,27 @@ window.renderBuildQueuePreview = function() {
|
|||||||
}).join('');
|
}).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}`;
|
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}`;
|
||||||
|
};
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ window.selectTown = function(id) {
|
|||||||
document.getElementById('town-details-panel').style.display = 'block';
|
document.getElementById('town-details-panel').style.display = 'block';
|
||||||
|
|
||||||
window.renderBuildQueuePreview();
|
window.renderBuildQueuePreview();
|
||||||
|
window.renderUnitQueuePreview();
|
||||||
window.renderBuildingDropdown();
|
window.renderBuildingDropdown();
|
||||||
window.renderUnitDropdown();
|
window.renderUnitDropdown();
|
||||||
window.renderTownDetails();
|
window.renderTownDetails();
|
||||||
|
|||||||
@@ -111,6 +111,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="build-queue-preview"></div>
|
<div id="build-queue-preview"></div>
|
||||||
|
<div id="unit-queue-preview" style="margin-top:10px;"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user