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,
|
||||
|
||||
Reference in New Issue
Block a user