fix of fix(version)
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Grepolis Remote Control
|
// @name Grepolis Remote Control
|
||||||
// @namespace http://tampermonkey.net/
|
// @namespace http://tampermonkey.net/
|
||||||
// @version 3.5
|
// @version 3.5.5
|
||||||
// @description Polls grepo.haunter-pets.top for remote commands and executes them in-game (Multi-Player)
|
// @description Polls grepo.haunter-pets.top for remote commands and executes them in-game (Multi-Player)
|
||||||
// @author Dimitrios
|
// @author Dimitrios
|
||||||
// @match https://*.grepolis.com/game/*
|
// @match https://*.grepolis.com/game/*
|
||||||
@@ -90,7 +90,7 @@
|
|||||||
const pm = uw.MM.getModels().Player[player_id];
|
const pm = uw.MM.getModels().Player[player_id];
|
||||||
if (pm && pm.attributes) alliance_name = pm.attributes.alliance_name;
|
if (pm && pm.attributes) alliance_name = pm.attributes.alliance_name;
|
||||||
console.log("GrepoRemote: Extracted alliance_name =", alliance_name);
|
console.log("GrepoRemote: Extracted alliance_name =", alliance_name);
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
console.log("GrepoRemote: Failed to extract alliance_name", e);
|
console.log("GrepoRemote: Failed to extract alliance_name", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,7 +245,7 @@
|
|||||||
let farms = [];
|
let farms = [];
|
||||||
try {
|
try {
|
||||||
const farmCollection = uw.MM.getOnlyCollectionByName('FarmTown');
|
const farmCollection = uw.MM.getOnlyCollectionByName('FarmTown');
|
||||||
const relCollection = uw.MM.getOnlyCollectionByName('FarmTownPlayerRelation');
|
const relCollection = uw.MM.getOnlyCollectionByName('FarmTownPlayerRelation');
|
||||||
if (farmCollection && relCollection) {
|
if (farmCollection && relCollection) {
|
||||||
const ix = town.getIslandCoordinateX?.();
|
const ix = town.getIslandCoordinateX?.();
|
||||||
const iy = town.getIslandCoordinateY?.();
|
const iy = town.getIslandCoordinateY?.();
|
||||||
@@ -255,13 +255,13 @@
|
|||||||
if (rel.attributes.farm_town_id === farm.attributes.id &&
|
if (rel.attributes.farm_town_id === farm.attributes.id &&
|
||||||
rel.attributes.relation_status >= 0) {
|
rel.attributes.relation_status >= 0) {
|
||||||
farms.push({
|
farms.push({
|
||||||
farm_town_id: farm.attributes.id,
|
farm_town_id: farm.attributes.id,
|
||||||
farm_name: farm.attributes.name || '',
|
farm_name: farm.attributes.name || '',
|
||||||
relation_id: rel.id,
|
relation_id: rel.id,
|
||||||
relation_status: rel.attributes.relation_status,
|
relation_status: rel.attributes.relation_status,
|
||||||
expansion_stage: rel.attributes.expansion_stage || 0,
|
expansion_stage: rel.attributes.expansion_stage || 0,
|
||||||
expansion_at: rel.attributes.expansion_at || 0,
|
expansion_at: rel.attributes.expansion_at || 0,
|
||||||
lootable_at: rel.attributes.lootable_at || 0
|
lootable_at: rel.attributes.lootable_at || 0
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -424,7 +424,7 @@
|
|||||||
let farmModels, relModels;
|
let farmModels, relModels;
|
||||||
try {
|
try {
|
||||||
farmModels = uw.MM.getOnlyCollectionByName('FarmTown')?.models;
|
farmModels = uw.MM.getOnlyCollectionByName('FarmTown')?.models;
|
||||||
relModels = uw.MM.getOnlyCollectionByName('FarmTownPlayerRelation')?.models;
|
relModels = uw.MM.getOnlyCollectionByName('FarmTownPlayerRelation')?.models;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return { ok: false, msg: `Cannot access farm collections: ${e.message}` };
|
return { ok: false, msg: `Cannot access farm collections: ${e.message}` };
|
||||||
}
|
}
|
||||||
@@ -450,8 +450,8 @@
|
|||||||
|
|
||||||
let upgraded = 0;
|
let upgraded = 0;
|
||||||
let unlocked = 0;
|
let unlocked = 0;
|
||||||
let skipped = 0;
|
let skipped = 0;
|
||||||
let errors = 0;
|
let errors = 0;
|
||||||
|
|
||||||
for (const town_id of polisList) {
|
for (const town_id of polisList) {
|
||||||
const town = uw.ITowns?.towns?.[town_id];
|
const town = uw.ITowns?.towns?.[town_id];
|
||||||
@@ -467,8 +467,8 @@
|
|||||||
if (rel.attributes.farm_town_id !== farm.attributes.id) continue;
|
if (rel.attributes.farm_town_id !== farm.attributes.id) continue;
|
||||||
|
|
||||||
const status = rel.attributes.relation_status;
|
const status = rel.attributes.relation_status;
|
||||||
const level = rel.attributes.expansion_stage || 0;
|
const level = rel.attributes.expansion_stage || 0;
|
||||||
const expAt = rel.attributes.expansion_at || 0;
|
const expAt = rel.attributes.expansion_at || 0;
|
||||||
|
|
||||||
// Skip if upgrade already in progress
|
// Skip if upgrade already in progress
|
||||||
if (expAt > now) { skipped++; continue; }
|
if (expAt > now) { skipped++; continue; }
|
||||||
@@ -488,9 +488,9 @@
|
|||||||
log(`Farm ${action}: farm_id=${farm.attributes.id} level=${level} town=${town_id}`);
|
log(`Farm ${action}: farm_id=${farm.attributes.id} level=${level} town=${town_id}`);
|
||||||
try {
|
try {
|
||||||
uw.gpAjax.ajaxPost('frontend_bridge', 'execute', {
|
uw.gpAjax.ajaxPost('frontend_bridge', 'execute', {
|
||||||
model_url: `FarmTownPlayerRelation/${rel.id}`,
|
model_url: `FarmTownPlayerRelation/${rel.id}`,
|
||||||
action_name: action,
|
action_name: action,
|
||||||
arguments: { farm_town_id: farm.attributes.id },
|
arguments: { farm_town_id: farm.attributes.id },
|
||||||
town_id
|
town_id
|
||||||
});
|
});
|
||||||
isLocked ? unlocked++ : upgraded++;
|
isLocked ? unlocked++ : upgraded++;
|
||||||
@@ -521,7 +521,7 @@
|
|||||||
let farmModels, relModels;
|
let farmModels, relModels;
|
||||||
try {
|
try {
|
||||||
farmModels = uw.MM.getOnlyCollectionByName('FarmTown')?.models;
|
farmModels = uw.MM.getOnlyCollectionByName('FarmTown')?.models;
|
||||||
relModels = uw.MM.getOnlyCollectionByName('FarmTownPlayerRelation')?.models;
|
relModels = uw.MM.getOnlyCollectionByName('FarmTownPlayerRelation')?.models;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return { ok: false, msg: `Cannot access farm collections: ${e.message}` };
|
return { ok: false, msg: `Cannot access farm collections: ${e.message}` };
|
||||||
}
|
}
|
||||||
@@ -550,7 +550,7 @@
|
|||||||
|
|
||||||
let claimed = 0;
|
let claimed = 0;
|
||||||
let skipped = 0;
|
let skipped = 0;
|
||||||
let errors = 0;
|
let errors = 0;
|
||||||
|
|
||||||
for (let i = 0; i < polisList.length; i++) {
|
for (let i = 0; i < polisList.length; i++) {
|
||||||
const town_id = polisList[i];
|
const town_id = polisList[i];
|
||||||
@@ -576,7 +576,7 @@
|
|||||||
readyFarms.push({
|
readyFarms.push({
|
||||||
town_id,
|
town_id,
|
||||||
farm_town_id: rel.attributes.farm_town_id,
|
farm_town_id: rel.attributes.farm_town_id,
|
||||||
relation_id: rel.id
|
relation_id: rel.id
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -588,10 +588,10 @@
|
|||||||
for (const farm of readyFarms) {
|
for (const farm of readyFarms) {
|
||||||
try {
|
try {
|
||||||
uw.gpAjax.ajaxPost('frontend_bridge', 'execute', {
|
uw.gpAjax.ajaxPost('frontend_bridge', 'execute', {
|
||||||
model_url: `FarmTownPlayerRelation/${farm.relation_id}`,
|
model_url: `FarmTownPlayerRelation/${farm.relation_id}`,
|
||||||
action_name: 'claim',
|
action_name: 'claim',
|
||||||
arguments: { farm_town_id: farm.farm_town_id, type: 'resources', option },
|
arguments: { farm_town_id: farm.farm_town_id, type: 'resources', option },
|
||||||
town_id: farm.town_id
|
town_id: farm.town_id
|
||||||
});
|
});
|
||||||
claimed++;
|
claimed++;
|
||||||
} catch (e) { errors++; }
|
} catch (e) { errors++; }
|
||||||
@@ -601,12 +601,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Refresh map icons after claiming (same as original)
|
// Refresh map icons after claiming (same as original)
|
||||||
try { uw.WMap.removeFarmTownLootCooldownIconAndRefreshLootTimers(); } catch(e) {}
|
try { uw.WMap.removeFarmTownLootCooldownIconAndRefreshLootTimers(); } catch (e) { }
|
||||||
|
|
||||||
// Random between-island delay: 30s – 90s (only if more islands remain)
|
// Random between-island delay: 30s – 90s (only if more islands remain)
|
||||||
if (i < polisList.length - 1) {
|
if (i < polisList.length - 1) {
|
||||||
const gap = randInt(30000, 90000);
|
const gap = randInt(30000, 90000);
|
||||||
log(`Farm: island done. Waiting ${(gap/1000).toFixed(0)}s before next island...`);
|
log(`Farm: island done. Waiting ${(gap / 1000).toFixed(0)}s before next island...`);
|
||||||
await sleep(gap);
|
await sleep(gap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -750,11 +750,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build queue, Recruit queue and Market queue are independent
|
// Build queue, Recruit queue and Market queue are independent
|
||||||
const buildCmd = cmdData.build;
|
const buildCmd = cmdData.build;
|
||||||
const recruitCmd = cmdData.recruit;
|
const recruitCmd = cmdData.recruit;
|
||||||
const marketCmd = cmdData.market;
|
const marketCmd = cmdData.market;
|
||||||
const farmCmd = cmdData.farm;
|
const farmCmd = cmdData.farm;
|
||||||
const farmUpgradeCmd = cmdData.farm_upgrade;
|
const farmUpgradeCmd = cmdData.farm_upgrade;
|
||||||
|
|
||||||
// Auto-farm: if enabled, claim all ready farms (no explicit command needed)
|
// Auto-farm: if enabled, claim all ready farms (no explicit command needed)
|
||||||
const farmSettings = cmdData.farm_settings || {};
|
const farmSettings = cmdData.farm_settings || {};
|
||||||
@@ -765,7 +765,7 @@
|
|||||||
try {
|
try {
|
||||||
const coll = uw.MM.getOnlyCollectionByName('FarmTownPlayerRelation');
|
const coll = uw.MM.getOnlyCollectionByName('FarmTownPlayerRelation');
|
||||||
return coll?.models?.some(r => r.attributes.relation_status === 1 && (r.attributes.lootable_at || 0) <= nowTs);
|
return coll?.models?.some(r => r.attributes.relation_status === 1 && (r.attributes.lootable_at || 0) <= nowTs);
|
||||||
} catch(e) { return false; }
|
} catch (e) { return false; }
|
||||||
});
|
});
|
||||||
if (hasFarms) {
|
if (hasFarms) {
|
||||||
log('⚡ Auto-farm: ready farms detected, triggering loot...');
|
log('⚡ Auto-farm: ready farms detected, triggering loot...');
|
||||||
|
|||||||
Reference in New Issue
Block a user