fix market capacity
This commit is contained in:
@@ -75,6 +75,7 @@ function gatherState() {
|
|||||||
|
|
||||||
// ---- Market / Trade capacity -----------------------------------------
|
// ---- Market / Trade capacity -----------------------------------------
|
||||||
let marketCapacity = 0;
|
let marketCapacity = 0;
|
||||||
|
let availableTradeCapacity = 0;
|
||||||
try {
|
try {
|
||||||
const marketLevel = buildings.market ?? 0;
|
const marketLevel = buildings.market ?? 0;
|
||||||
const gd = uw.GameData?.buildingData?.market;
|
const gd = uw.GameData?.buildingData?.market;
|
||||||
@@ -82,6 +83,7 @@ function gatherState() {
|
|||||||
if (buildings.trade_office && buildings.trade_office > 0) {
|
if (buildings.trade_office && buildings.trade_office > 0) {
|
||||||
marketCapacity += (uw.GameData?.buildingData?.trade_office?.capacity_extra_per_level || 500) * marketLevel;
|
marketCapacity += (uw.GameData?.buildingData?.trade_office?.capacity_extra_per_level || 500) * marketLevel;
|
||||||
}
|
}
|
||||||
|
availableTradeCapacity = town.getAvailableTradeCapacity?.() ?? marketCapacity;
|
||||||
} catch (e) { log(`market capacity lookup failed: ${e}`); }
|
} catch (e) { log(`market capacity lookup failed: ${e}`); }
|
||||||
|
|
||||||
// ---- Coordinates & sea zone -----------------------------------------
|
// ---- Coordinates & sea zone -----------------------------------------
|
||||||
@@ -176,6 +178,7 @@ 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,
|
||||||
|
|||||||
@@ -166,11 +166,20 @@ 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;
|
||||||
|
|
||||||
document.getElementById('td-market').innerHTML = mCap > 0
|
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');
|
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 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}` : '—';
|
||||||
|
|||||||
@@ -154,6 +154,7 @@
|
|||||||
<!-- 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>
|
||||||
|
|||||||
Reference in New Issue
Block a user