This commit is contained in:
2026-04-26 13:55:25 +03:00
parent a8b3e9f5ea
commit 5bff9a287d
5 changed files with 42 additions and 25 deletions

View File

@@ -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);