From 0ef0bef0367f08a5bc51cb3a02cdbddab198492e Mon Sep 17 00:00:00 2001 From: haunter Date: Tue, 28 Apr 2026 22:17:36 +0300 Subject: [PATCH] fix market capacity --- bot_modules/02_state.js | 3 +++ static/js/components/townViewer.js | 13 +++++++++++-- templates/dashboard.html | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/bot_modules/02_state.js b/bot_modules/02_state.js index f0bc4d2..433151c 100644 --- a/bot_modules/02_state.js +++ b/bot_modules/02_state.js @@ -75,6 +75,7 @@ function gatherState() { // ---- Market / Trade capacity ----------------------------------------- let marketCapacity = 0; + let availableTradeCapacity = 0; try { const marketLevel = buildings.market ?? 0; const gd = uw.GameData?.buildingData?.market; @@ -82,6 +83,7 @@ function gatherState() { if (buildings.trade_office && buildings.trade_office > 0) { marketCapacity += (uw.GameData?.buildingData?.trade_office?.capacity_extra_per_level || 500) * marketLevel; } + availableTradeCapacity = town.getAvailableTradeCapacity?.() ?? marketCapacity; } catch (e) { log(`market capacity lookup failed: ${e}`); } // ---- Coordinates & sea zone ----------------------------------------- @@ -176,6 +178,7 @@ function gatherState() { iron: res.iron, storage: storageCapacity, market_capacity: marketCapacity, + available_trade_capacity: availableTradeCapacity, population: res.population, points: town.getPoints?.() ?? 0, god: town.god?.() ?? null, diff --git a/static/js/components/townViewer.js b/static/js/components/townViewer.js index 788e183..1911598 100644 --- a/static/js/components/townViewer.js +++ b/static/js/components/townViewer.js @@ -166,11 +166,20 @@ window.renderTownDetails = function() { `; const mCap = resObj.market_capacity || 0; + const aCap = resObj.available_trade_capacity != null ? resObj.available_trade_capacity : mCap; + document.getElementById('td-market').innerHTML = mCap > 0 - ? `📦 Εμπορική Χωρητικότητα: ${window.fmt(mCap)}` + ? `📦 Εμπορική Χωρητικότητα: ${window.fmt(aCap)} / ${window.fmt(mCap)}` : ''; + const mCapLabel = document.getElementById('market-capacity-label'); - if (mCapLabel) mCapLabel.textContent = `Χωρητικότητα: ${window.fmt(mCap)}`; + if (mCapLabel) { + if (mCap > 0) { + mCapLabel.innerHTML = `Χωρητικότητα: ${window.fmt(aCap)} / ${window.fmt(mCap)}`; + } else { + mCapLabel.textContent = ''; + } + } const godName = t.god ? t.god.charAt(0).toUpperCase() + t.god.slice(1) : 'Κανένας'; const seaStr = t.sea != null ? `Θ${t.sea}` : '—'; diff --git a/templates/dashboard.html b/templates/dashboard.html index 019f8b0..50d5bf2 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -154,6 +154,7 @@