recruit troop rehaul
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// ==UserScript==
|
||||
// @name Grepolis Remote Control
|
||||
// @namespace http://tampermonkey.net/
|
||||
// @version 2.0
|
||||
// @version 2.1
|
||||
// @description Polls grepo.haunter-pets.top for remote commands and executes them in-game
|
||||
// @author Dimitrios
|
||||
// @match https://*.grepolis.com/game/*
|
||||
@@ -160,6 +160,49 @@
|
||||
if (r) researches = r.attributes ?? (typeof r === 'object' ? r : {});
|
||||
} catch (e) { log(`[Debug] town.researches() failed: ${e}`); }
|
||||
|
||||
// ---- Unit Data (Costs & Dependencies) -------------------------------
|
||||
let unitDataMap = {};
|
||||
try {
|
||||
const gdUnits = uw.GameData?.units || {};
|
||||
|
||||
for (const u in gdUnits) {
|
||||
if (u === 'militia') continue;
|
||||
|
||||
const reqBuildings = gdUnits[u].building_dependencies || {};
|
||||
const reqResearch = gdUnits[u].research_dependencies || [];
|
||||
|
||||
let missing_deps = {};
|
||||
for (const reqB in reqBuildings) {
|
||||
if ((buildings[reqB] || 0) < reqBuildings[reqB]) {
|
||||
missing_deps[reqB] = { name: reqB, needed_level: reqBuildings[reqB] };
|
||||
}
|
||||
}
|
||||
for (const reqR of reqResearch) {
|
||||
if (!researches[reqR]) {
|
||||
missing_deps[reqR] = { name: reqR, needed_level: 'Έρευνα' };
|
||||
}
|
||||
}
|
||||
|
||||
const cost = gdUnits[u].resources || {};
|
||||
const w = cost.wood || 0;
|
||||
const s = cost.stone || 0;
|
||||
const i = cost.iron || 0;
|
||||
|
||||
let enough = true;
|
||||
if (res.wood < w || res.stone < s || res.iron < i) enough = false;
|
||||
|
||||
unitDataMap[u] = {
|
||||
wood: w,
|
||||
stone: s,
|
||||
iron: i,
|
||||
pop: gdUnits[u].population || 0,
|
||||
build_time: gdUnits[u].build_time || 0,
|
||||
enough_resources: enough,
|
||||
missing_dependencies: missing_deps
|
||||
};
|
||||
}
|
||||
} catch (e) { log(`Failed to gather unit data: ${e}`); }
|
||||
|
||||
// ---- Extra town flags -----------------------------------------------
|
||||
let has_premium = false;
|
||||
let bonuses = {};
|
||||
@@ -184,6 +227,7 @@
|
||||
units: unitsObj,
|
||||
buildingOrder: buildQueue,
|
||||
buildData: buildDataMap,
|
||||
unitData: unitDataMap,
|
||||
researches,
|
||||
has_premium,
|
||||
bonuses,
|
||||
|
||||
Reference in New Issue
Block a user