enchance data
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// ==UserScript==
|
||||
// @name Grepolis Remote Control
|
||||
// @namespace http://tampermonkey.net/
|
||||
// @version 1.2
|
||||
// @version 1.3
|
||||
// @description Polls grepo.haunter-pets.top for remote commands and executes them in-game
|
||||
// @author Dimitrios
|
||||
// @match https://*.grepolis.com/game/*
|
||||
@@ -67,9 +67,13 @@
|
||||
// Push town state to relay
|
||||
// ----------------------------------------------------------------
|
||||
function gatherState() {
|
||||
const towns = uw.ITowns?.towns || {};
|
||||
const player = uw.Game?.player_name || '';
|
||||
const world = uw.Game?.world_id || '';
|
||||
const towns = uw.ITowns?.towns || {};
|
||||
const player = uw.Game?.player_name || '';
|
||||
const player_id = uw.Game?.player_id ?? null;
|
||||
const alliance_id = uw.Game?.alliance_id ?? null;
|
||||
const total_points = uw.Game?.player_points ?? 0;
|
||||
const world = uw.Game?.world_id || '';
|
||||
|
||||
|
||||
const townList = Object.values(towns).map(town => {
|
||||
const res = town.resources();
|
||||
@@ -135,9 +139,35 @@
|
||||
log(`storage capacity lookup failed: ${e}`);
|
||||
}
|
||||
|
||||
// ---- Coordinates & sea zone -----------------------------------------
|
||||
let x = null, y = null, sea = null;
|
||||
try {
|
||||
x = town.getIslandCoordinateX?.() ?? null;
|
||||
y = town.getIslandCoordinateY?.() ?? null;
|
||||
if (typeof x === 'number' && typeof y === 'number') {
|
||||
sea = Math.floor(x / 100) * 10 + Math.floor(y / 100);
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
// ---- Researches -----------------------------------------------------
|
||||
let researches = {};
|
||||
try {
|
||||
const r = town.researches?.();
|
||||
if (r) researches = r.attributes ?? (typeof r === 'object' ? r : {});
|
||||
} catch (e) {}
|
||||
|
||||
// ---- Extra town flags -----------------------------------------------
|
||||
let has_premium = false;
|
||||
let bonuses = {};
|
||||
let wonder_points = 0;
|
||||
try { has_premium = town.hasPremium?.() || false; } catch (e) {}
|
||||
try { bonuses = town.getBonus?.() || {}; } catch (e) {}
|
||||
try { wonder_points = town.wonder_points || 0; } catch (e) {}
|
||||
|
||||
return {
|
||||
town_id: town.id,
|
||||
town_name: town.name,
|
||||
x, y, sea,
|
||||
wood: res.wood,
|
||||
stone: res.stone,
|
||||
iron: res.iron,
|
||||
@@ -149,10 +179,14 @@
|
||||
units: unitsObj,
|
||||
buildingOrder: buildQueue,
|
||||
buildData: buildDataMap,
|
||||
researches,
|
||||
has_premium,
|
||||
bonuses,
|
||||
wonder_points,
|
||||
};
|
||||
});
|
||||
|
||||
return { player, world_id: world, towns: townList };
|
||||
return { player, player_id, alliance_id, total_points, world_id: world, towns: townList };
|
||||
}
|
||||
|
||||
function pushState() {
|
||||
|
||||
Reference in New Issue
Block a user