diff --git a/GrepolisRemoteControl.user.js b/GrepolisRemoteControl.user.js index 63eb267..a257a22 100644 --- a/GrepolisRemoteControl.user.js +++ b/GrepolisRemoteControl.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Grepolis Remote Control // @namespace http://tampermonkey.net/ -// @version 1.1 +// @version 1.2 // @description Polls grepo.haunter-pets.top for remote commands and executes them in-game // @author Dimitrios // @match https://*.grepolis.com/game/* @@ -110,13 +110,38 @@ log(`Failed to gather build data: ${e}`); } + // ---- Storage capacity ----------------------------------------------- + // res.storage / res.storage_capacity are always 0 in Grepolis. + // Real capacity lives in GameData keyed by the storage building level. + let storageCapacity = 0; + try { + // Strategy 1: dedicated getter (exists on some server versions) + storageCapacity = town.getStorageCapacity?.() || 0; + + // Strategy 2: GameData.buildingData.storage.max_storage[level] + if (!storageCapacity) { + const storageLevel = buildings.storage ?? 0; + const gd = uw.GameData?.buildingData?.storage; + storageCapacity = gd?.max_storage?.[storageLevel] + || gd?.storage?.[storageLevel] + || 0; + } + + // Strategy 3: resource object fallback keys + if (!storageCapacity) { + storageCapacity = res.capacity || res.storage_capacity || res.storage || 0; + } + } catch (e) { + log(`storage capacity lookup failed: ${e}`); + } + return { town_id: town.id, town_name: town.name, wood: res.wood, stone: res.stone, iron: res.iron, - storage: res.storage || res.storage_capacity || 0, + storage: storageCapacity, population: res.population, points: town.getPoints?.() ?? 0, god: town.god?.() ?? null,