From 7e98f1292e50be9687c3fbd1e2c3ecea7a6fb39b Mon Sep 17 00:00:00 2001 From: haunter Date: Tue, 5 May 2026 22:25:02 +0300 Subject: [PATCH] recruit line --- bot_modules/02_state.js | 7 +++++++ routes/dashboard.py | 1 + static/js/api.js | 1 + static/js/components/commandForm.js | 24 ++++++++++++++++++++++++ static/js/components/townViewer.js | 1 + templates/dashboard.html | 1 + 6 files changed, 35 insertions(+) diff --git a/bot_modules/02_state.js b/bot_modules/02_state.js index 264dfe4..78aecc3 100644 --- a/bot_modules/02_state.js +++ b/bot_modules/02_state.js @@ -52,6 +52,12 @@ function gatherState() { if (bo?.models) buildQueue = bo.models.map(m => m.attributes); } catch (e) {} + let unitQueue = []; + try { + const uo = town.getUnitOrdersCollection?.(); + if (uo?.models) unitQueue = uo.models.map(m => m.attributes); + } catch (e) {} + let buildDataMap = {}; try { const buildDataRaw = uw.MM?.getModels?.()?.BuildingBuildData?.[town.id]?.attributes?.building_data || {}; @@ -211,6 +217,7 @@ function gatherState() { buildings, units: unitsObj, buildingOrder: buildQueue, + unitOrder: unitQueue, buildData: buildDataMap, unitData: unitDataMap, researches, diff --git a/routes/dashboard.py b/routes/dashboard.py index c0e92a2..270c4f6 100644 --- a/routes/dashboard.py +++ b/routes/dashboard.py @@ -260,6 +260,7 @@ def get_towns(): 'points': d.get('points', 0), 'god': d.get('god', None), 'build_queue': d.get('buildingOrder', []), + 'unit_queue': d.get('unitOrder', []), 'build_data': d.get('buildData', {}), 'unit_data': d.get('unitData', {}), 'researches': d.get('researches', {}), diff --git a/static/js/api.js b/static/js/api.js index 5e7dfb9..9257eeb 100644 --- a/static/js/api.js +++ b/static/js/api.js @@ -16,6 +16,7 @@ window.fetchTowns = async function() { if (window.selectedTownId) { window.renderBuildQueuePreview(); + window.renderUnitQueuePreview(); window.renderBuildingDropdown(); window.renderUnitDropdown(); window.renderTownDetails(); diff --git a/static/js/components/commandForm.js b/static/js/components/commandForm.js index c3957ea..17fc6a8 100644 --- a/static/js/components/commandForm.js +++ b/static/js/components/commandForm.js @@ -489,3 +489,27 @@ window.renderBuildQueuePreview = function() { }).join(''); el.innerHTML = `
Current queue
${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 = 'Recruit queue: empty'; + 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 ` + ${countStr}x ${nameGr} + `; + }).join(''); + + el.innerHTML = `
Recruitment queue
${items}`; +}; diff --git a/static/js/components/townViewer.js b/static/js/components/townViewer.js index 87f500a..708a460 100644 --- a/static/js/components/townViewer.js +++ b/static/js/components/townViewer.js @@ -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(); diff --git a/templates/dashboard.html b/templates/dashboard.html index 84f104d..35ee83f 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -111,6 +111,7 @@
+