MJ:Fix 2
This commit is contained in:
@@ -82,10 +82,20 @@ async function pollAndExecute() {
|
||||
|
||||
const towns = Object.values(uw.ITowns?.towns || {});
|
||||
for (const town of towns) {
|
||||
const storage = town.resources?.()?.storage || town.get?.('storage') || 0;
|
||||
const wood = town.resources?.()?.wood || town.get?.('wood') || 0;
|
||||
const stone = town.resources?.()?.stone || town.get?.('stone') || 0;
|
||||
const iron = town.resources?.()?.iron || town.get?.('iron') || 0;
|
||||
// Use same multi-strategy lookup as gatherState() — res.storage is often 0 in Grepolis
|
||||
const res = town.resources?.() || {};
|
||||
let storage = town.getStorageCapacity?.() || 0;
|
||||
if (!storage) {
|
||||
const buildings = town.buildings?.()?.attributes || {};
|
||||
const storageLevel = buildings.storage ?? 0;
|
||||
const gd = uw.GameData?.buildingData?.storage;
|
||||
storage = gd?.max_storage?.[storageLevel] || gd?.storage?.[storageLevel] || 0;
|
||||
}
|
||||
if (!storage) storage = res.capacity || res.storage_capacity || res.storage || 0;
|
||||
|
||||
const wood = res.wood || 0;
|
||||
const stone = res.stone || 0;
|
||||
const iron = res.iron || 0;
|
||||
if (!storage) continue;
|
||||
|
||||
const maxRes = Math.max(wood, stone, iron);
|
||||
|
||||
Reference in New Issue
Block a user