From e9715cfffd31f89742248cff1404ef219ea2fc66 Mon Sep 17 00:00:00 2001 From: haunter Date: Mon, 18 Aug 2025 11:13:39 +0000 Subject: [PATCH] Update town.js --- town.js | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/town.js b/town.js index a5c5982..6c295e6 100644 --- a/town.js +++ b/town.js @@ -1,9 +1,9 @@ // ==UserScript== -// @name Grepolis Town Stats Extended Clean (with Sea, Buildings, Researches) +// @name Grepolis Town Stats Extended Clean (with Sea, Buildings, Researches, Points, Gods) // @namespace http://tampermonkey.net/ -// @version 1.4 -// @description Sends town stats with coords, sea, full building orders, and researches -// @author Dimitrios +// @version 1.8 +// @description Sends town stats with coords, sea, full building orders, researches, points, and gods +// @author Dimitrios + GPT // @match https://*.grepolis.com/game/* // @grant unsafeWindow // ==/UserScript== @@ -14,7 +14,7 @@ const uw = unsafeWindow || window; let paused = false; - console.log("🚀 Town Stats Extended Clean (with Sea, Buildings, Researches) loaded"); + console.log("🚀 Town Stats Extended Clean (with Sea, Buildings, Researches, Points, Gods) loaded"); // ----------------------------- // Toolbar pause/resume button @@ -55,8 +55,8 @@ // ----------------------------- function computeSea(x, y) { if (typeof x !== 'number' || typeof y !== 'number') return null; - const sx = Math.floor(x / 100); // col (0-based) - const sy = Math.floor(y / 100); // row (0-based) + const sx = Math.floor(x / 100); + const sy = Math.floor(y / 100); return sx * 10 + sy; } @@ -67,6 +67,7 @@ const towns = uw.ITowns?.towns || {}; const player = uw.Game?.player_name || "unknown"; const player_id = uw.Game?.player_id || "unknown"; + const total_points = uw.Game?.player_points || 0; const townStats = Object.values(towns).map(town => { const res = town.resources(); @@ -107,6 +108,18 @@ researches = town.researches(); } + // Village points — use fixed getPoints + let points = 0; + if (typeof town.getPoints === 'function') { + points = town.getPoints(); + } + + // God — keep original logic + let god = null; + if (typeof town.god === 'function') { + god = town.god(); + } + return { town_id: town.id, town_name: town.name, @@ -115,7 +128,8 @@ stone: res.stone, iron: res.iron, population: res.population, - points: town.points || 0, + points, + god, buildings, units: unitsObj, buildingOrder, @@ -126,7 +140,7 @@ }; }); - return { player, player_id, towns: townStats }; + return { player, player_id, total_points, towns: townStats }; } // -----------------------------