From d952e7ca56d22801c570ae066792b293ba1075dd Mon Sep 17 00:00:00 2001 From: haunter Date: Tue, 28 Apr 2026 23:28:13 +0300 Subject: [PATCH] market revert back --- bot_modules/02_state.js | 18 +++++------------- routes/dashboard.py | 1 - static/js/components/commandForm.js | 5 ----- static/js/components/townViewer.js | 17 +++-------------- templates/dashboard.html | 1 - 5 files changed, 8 insertions(+), 34 deletions(-) diff --git a/bot_modules/02_state.js b/bot_modules/02_state.js index 7d060f7..f0bc4d2 100644 --- a/bot_modules/02_state.js +++ b/bot_modules/02_state.js @@ -74,20 +74,13 @@ function gatherState() { } catch (e) { log(`storage capacity lookup failed: ${e}`); } // ---- Market / Trade capacity ----------------------------------------- - // Reads from the same live MM model the game UI uses (CreateOffers). - // This model is populated once the player opens their market tab. let marketCapacity = 0; - let availableTradeCapacity = 0; try { - const createOffers = uw.MM.getModels?.()?.CreateOffers?.[town.id]; - if (createOffers?.attributes) { - marketCapacity = createOffers.attributes.trade_capacity ?? 0; - availableTradeCapacity = createOffers.attributes.available_trade_capacity ?? marketCapacity; - } - // Fallback: use town method if model not yet loaded (market not yet opened) - if (!marketCapacity && town.getTradeCapacity) { - marketCapacity = town.getTradeCapacity() || 0; - availableTradeCapacity = town.getAvailableTradeCapacity?.() ?? marketCapacity; + const marketLevel = buildings.market ?? 0; + const gd = uw.GameData?.buildingData?.market; + marketCapacity = gd?.capacity_per_level?.[marketLevel] || 0; + if (buildings.trade_office && buildings.trade_office > 0) { + marketCapacity += (uw.GameData?.buildingData?.trade_office?.capacity_extra_per_level || 500) * marketLevel; } } catch (e) { log(`market capacity lookup failed: ${e}`); } @@ -183,7 +176,6 @@ 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/routes/dashboard.py b/routes/dashboard.py index 81ccc03..57e2f2e 100644 --- a/routes/dashboard.py +++ b/routes/dashboard.py @@ -200,7 +200,6 @@ def get_towns(): 'iron': d.get('iron', 0), 'storage': d.get('storage', 0), 'market_capacity': d.get('market_capacity', 0), - 'available_trade_capacity': d.get('available_trade_capacity'), 'population': d.get('population', 0), }, 'buildings': d.get('buildings', {}), diff --git a/static/js/components/commandForm.js b/static/js/components/commandForm.js index 5e199ec..a7dd21b 100644 --- a/static/js/components/commandForm.js +++ b/static/js/components/commandForm.js @@ -9,11 +9,6 @@ window.onCmdTypeChange = function() { document.getElementById('amount-group').style.display = type === 'recruit' ? '' : 'none'; document.getElementById('market-options').style.display = type === 'market_offer' ? '' : 'none'; document.getElementById('research-options').style.display = type === 'research' ? '' : 'none'; - - // Refresh market capacity label whenever market tab is opened - if (type === 'market_offer' && window.renderTownDetails) { - window.renderTownDetails(); - } }; // Building emoji icons for the visual grid diff --git a/static/js/components/townViewer.js b/static/js/components/townViewer.js index 325728b..788e183 100644 --- a/static/js/components/townViewer.js +++ b/static/js/components/townViewer.js @@ -166,22 +166,11 @@ window.renderTownDetails = function() { `; const mCap = resObj.market_capacity || 0; - const aCap = resObj.available_trade_capacity != null ? resObj.available_trade_capacity : mCap; - - // Always update td-market in the details panel document.getElementById('td-market').innerHTML = mCap > 0 - ? `📦 Εμπορική Χωρητικότητα: ${window.fmt(aCap)} / ${window.fmt(mCap)}` - : `📦 Εμπορική Χωρητικότητα: Χωρίς Αγορά (Επ.0)`; - - // Always update the label inside the market command form + ? `📦 Εμπορική Χωρητικότητα: ${window.fmt(mCap)}` + : ''; const mCapLabel = document.getElementById('market-capacity-label'); - if (mCapLabel) { - if (mCap > 0) { - mCapLabel.innerHTML = `🏪 Διαθέσιμη Χωρητικότητα: ${window.fmt(aCap)} / ${window.fmt(mCap)} max`; - } else { - mCapLabel.innerHTML = `⚠️ Αυτή η πόλη δεν έχει Αγορά`; - } - } + if (mCapLabel) mCapLabel.textContent = `Χωρητικότητα: ${window.fmt(mCap)}`; 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 d704f77..e4d89a1 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -154,7 +154,6 @@