fix market capacity

This commit is contained in:
2026-04-28 22:17:36 +03:00
parent 1717de8373
commit 0ef0bef036
3 changed files with 15 additions and 2 deletions

View File

@@ -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,

View File

@@ -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
? `📦 Εμπορική Χωρητικότητα: <strong>${window.fmt(mCap)}</strong>`
? `📦 Εμπορική Χωρητικότητα: <strong style="color:#6fcfcf">${window.fmt(aCap)}</strong> / <strong>${window.fmt(mCap)}</strong>`
: '';
const mCapLabel = document.getElementById('market-capacity-label');
if (mCapLabel) mCapLabel.textContent = `Χωρητικότητα: ${window.fmt(mCap)}`;
if (mCapLabel) {
if (mCap > 0) {
mCapLabel.innerHTML = `Χωρητικότητα: <strong style="color:#6fcfcf">${window.fmt(aCap)}</strong> / ${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}` : '—';

View File

@@ -154,6 +154,7 @@
<!-- Market options -->
<!-- Market options -->
<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="flex:1;">
<label>Προσφορά</label>