Update town.js
This commit is contained in:
32
town.js
32
town.js
@@ -1,9 +1,9 @@
|
|||||||
// ==UserScript==
|
// ==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/
|
// @namespace http://tampermonkey.net/
|
||||||
// @version 1.4
|
// @version 1.8
|
||||||
// @description Sends town stats with coords, sea, full building orders, and researches
|
// @description Sends town stats with coords, sea, full building orders, researches, points, and gods
|
||||||
// @author Dimitrios
|
// @author Dimitrios + GPT
|
||||||
// @match https://*.grepolis.com/game/*
|
// @match https://*.grepolis.com/game/*
|
||||||
// @grant unsafeWindow
|
// @grant unsafeWindow
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
const uw = unsafeWindow || window;
|
const uw = unsafeWindow || window;
|
||||||
let paused = false;
|
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
|
// Toolbar pause/resume button
|
||||||
@@ -55,8 +55,8 @@
|
|||||||
// -----------------------------
|
// -----------------------------
|
||||||
function computeSea(x, y) {
|
function computeSea(x, y) {
|
||||||
if (typeof x !== 'number' || typeof y !== 'number') return null;
|
if (typeof x !== 'number' || typeof y !== 'number') return null;
|
||||||
const sx = Math.floor(x / 100); // col (0-based)
|
const sx = Math.floor(x / 100);
|
||||||
const sy = Math.floor(y / 100); // row (0-based)
|
const sy = Math.floor(y / 100);
|
||||||
return sx * 10 + sy;
|
return sx * 10 + sy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,6 +67,7 @@
|
|||||||
const towns = uw.ITowns?.towns || {};
|
const towns = uw.ITowns?.towns || {};
|
||||||
const player = uw.Game?.player_name || "unknown";
|
const player = uw.Game?.player_name || "unknown";
|
||||||
const player_id = uw.Game?.player_id || "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 townStats = Object.values(towns).map(town => {
|
||||||
const res = town.resources();
|
const res = town.resources();
|
||||||
@@ -107,6 +108,18 @@
|
|||||||
researches = town.researches();
|
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 {
|
return {
|
||||||
town_id: town.id,
|
town_id: town.id,
|
||||||
town_name: town.name,
|
town_name: town.name,
|
||||||
@@ -115,7 +128,8 @@
|
|||||||
stone: res.stone,
|
stone: res.stone,
|
||||||
iron: res.iron,
|
iron: res.iron,
|
||||||
population: res.population,
|
population: res.population,
|
||||||
points: town.points || 0,
|
points,
|
||||||
|
god,
|
||||||
buildings,
|
buildings,
|
||||||
units: unitsObj,
|
units: unitsObj,
|
||||||
buildingOrder,
|
buildingOrder,
|
||||||
@@ -126,7 +140,7 @@
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
return { player, player_id, towns: townStats };
|
return { player, player_id, total_points, towns: townStats };
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user