market revert back
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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', {}),
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
? `📦 Εμπορική Χωρητικότητα: <strong style="color:#6fcfcf">${window.fmt(aCap)}</strong> / <strong>${window.fmt(mCap)}</strong>`
|
||||
: `📦 Εμπορική Χωρητικότητα: <span style="color:#555">Χωρίς Αγορά (Επ.0)</span>`;
|
||||
|
||||
// Always update the label inside the market command form
|
||||
? `📦 Εμπορική Χωρητικότητα: <strong>${window.fmt(mCap)}</strong>`
|
||||
: '';
|
||||
const mCapLabel = document.getElementById('market-capacity-label');
|
||||
if (mCapLabel) {
|
||||
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>`;
|
||||
}
|
||||
}
|
||||
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}` : '—';
|
||||
|
||||
@@ -154,7 +154,6 @@
|
||||
<!-- 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>
|
||||
|
||||
Reference in New Issue
Block a user