market revert back

This commit is contained in:
2026-04-28 23:28:13 +03:00
parent edd7666905
commit d952e7ca56
5 changed files with 8 additions and 34 deletions

View File

@@ -74,20 +74,13 @@ function gatherState() {
} catch (e) { log(`storage capacity lookup failed: ${e}`); } } catch (e) { log(`storage capacity lookup failed: ${e}`); }
// ---- Market / Trade capacity ----------------------------------------- // ---- 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 marketCapacity = 0;
let availableTradeCapacity = 0;
try { try {
const createOffers = uw.MM.getModels?.()?.CreateOffers?.[town.id]; const marketLevel = buildings.market ?? 0;
if (createOffers?.attributes) { const gd = uw.GameData?.buildingData?.market;
marketCapacity = createOffers.attributes.trade_capacity ?? 0; marketCapacity = gd?.capacity_per_level?.[marketLevel] || 0;
availableTradeCapacity = createOffers.attributes.available_trade_capacity ?? marketCapacity; if (buildings.trade_office && buildings.trade_office > 0) {
} marketCapacity += (uw.GameData?.buildingData?.trade_office?.capacity_extra_per_level || 500) * marketLevel;
// 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;
} }
} catch (e) { log(`market capacity lookup failed: ${e}`); } } catch (e) { log(`market capacity lookup failed: ${e}`); }
@@ -183,7 +176,6 @@ function gatherState() {
iron: res.iron, iron: res.iron,
storage: storageCapacity, storage: storageCapacity,
market_capacity: marketCapacity, market_capacity: marketCapacity,
available_trade_capacity: availableTradeCapacity,
population: res.population, population: res.population,
points: town.getPoints?.() ?? 0, points: town.getPoints?.() ?? 0,
god: town.god?.() ?? null, god: town.god?.() ?? null,

View File

@@ -200,7 +200,6 @@ def get_towns():
'iron': d.get('iron', 0), 'iron': d.get('iron', 0),
'storage': d.get('storage', 0), 'storage': d.get('storage', 0),
'market_capacity': d.get('market_capacity', 0), 'market_capacity': d.get('market_capacity', 0),
'available_trade_capacity': d.get('available_trade_capacity'),
'population': d.get('population', 0), 'population': d.get('population', 0),
}, },
'buildings': d.get('buildings', {}), 'buildings': d.get('buildings', {}),

View File

@@ -9,11 +9,6 @@ window.onCmdTypeChange = function() {
document.getElementById('amount-group').style.display = type === 'recruit' ? '' : 'none'; document.getElementById('amount-group').style.display = type === 'recruit' ? '' : 'none';
document.getElementById('market-options').style.display = type === 'market_offer' ? '' : 'none'; document.getElementById('market-options').style.display = type === 'market_offer' ? '' : 'none';
document.getElementById('research-options').style.display = type === 'research' ? '' : '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 // Building emoji icons for the visual grid

View File

@@ -166,22 +166,11 @@ window.renderTownDetails = function() {
`; `;
const mCap = resObj.market_capacity || 0; 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 document.getElementById('td-market').innerHTML = mCap > 0
? `📦 Εμπορική Χωρητικότητα: <strong style="color:#6fcfcf">${window.fmt(aCap)}</strong> / <strong>${window.fmt(mCap)}</strong>` ? `📦 Εμπορική Χωρητικότητα: <strong>${window.fmt(mCap)}</strong>`
: `📦 Εμπορική Χωρητικότητα: <span style="color:#555">Χωρίς Αγορά (Επ.0)</span>`; : '';
// Always update the label inside the market command form
const mCapLabel = document.getElementById('market-capacity-label'); const mCapLabel = document.getElementById('market-capacity-label');
if (mCapLabel) { if (mCapLabel) mCapLabel.textContent = `Χωρητικότητα: ${window.fmt(mCap)}`;
if (mCap > 0) {
mCapLabel.innerHTML = `🏪 Διαθέσιμη Χωρητικότητα: <strong style="color:#6fcfcf">${window.fmt(aCap)}</strong> / <span style="color:#aaa">${window.fmt(mCap)} max</span>`;
} else {
mCapLabel.innerHTML = `<span style="color:#ff6666">⚠️ Αυτή η πόλη δεν έχει Αγορά</span>`;
}
}
const godName = t.god ? t.god.charAt(0).toUpperCase() + t.god.slice(1) : 'Κανένας'; const godName = t.god ? t.god.charAt(0).toUpperCase() + t.god.slice(1) : 'Κανένας';
const seaStr = t.sea != null ? `Θ${t.sea}` : '—'; const seaStr = t.sea != null ? `Θ${t.sea}` : '—';

View File

@@ -154,7 +154,6 @@
<!-- Market options --> <!-- Market options -->
<!-- Market options --> <!-- Market options -->
<div class="form-group" id="market-options" style="display:none"> <div class="form-group" id="market-options" style="display:none">
<div id="market-capacity-label" style="font-size: 0.85rem; color: #888; margin-bottom: 12px; font-weight: bold;"></div>
<div style="display:flex; gap:10px; margin-bottom:10px;"> <div style="display:flex; gap:10px; margin-bottom:10px;">
<div style="flex:1;"> <div style="flex:1;">
<label>Προσφορά</label> <label>Προσφορά</label>