/ ‘grepolis.user.js’

This commit is contained in:
Jan Bader 2014-06-28 21:02:14 +02:00
parent ea05b8833b
commit ec4d6500a1

View File

@ -21,8 +21,10 @@
console.log("Initializing..."); console.log("Initializing...");
windows = {}; windows = {};
durations = {}; durations = {};
//farm_ids = [1225, 1226, 1228, 1229, 1230, 1231]; farm_ids = {
farm_ids = [20466, 20467, 20468, 20470, 20471, 20472]; 83792: [20466, 20467, 20468, 20470, 20471, 20472],
85523: []
}
setTimeout(function() { setTimeout(function() {
var logGPWindow = new GPWindow(-1, null); var logGPWindow = new GPWindow(-1, null);
@ -58,12 +60,16 @@
+'document.getElementById(id).innerHTML = strZeit;}'; +'document.getElementById(id).innerHTML = strZeit;}';
document.getElementsByTagName("head")[0].appendChild(s); document.getElementsByTagName("head")[0].appendChild(s);
farm_ids.forEach(function(xFarmId) {
for(var town_id in farm_ids) {
farm_ids[town_id].forEach(function(xFarmId) {
var tmout = 5000 + rand(5); var tmout = 5000 + rand(5);
setTimeout(getWaresTick(xFarmId), tmout); setTimeout(getWaresTick(town_id, xFarmId), tmout);
var tmoutId = 'farm-' + xFarmId var tmoutId = 'farm-' + xFarmId
timerWindow.append('Farm ID ' + xFarmId + ': <span id="' + tmoutId + '"><script>j_countdown(' + Math.floor(tmout/1000) + ', "' + tmoutId + '");</script></span><br />'); timerWindow.append('Farm ID ' + xFarmId + ': <span id="' + tmoutId + '"><script>j_countdown(' + Math.floor(tmout/1000) + ', "' + tmoutId + '");</script></span><br />');
}); });
}
$("#ui-id" + logGPWindow.getID()).empty().append("<select id=choosefarmduration><option value=300>5min</option><option value=1200>20min</option><option value=5400>90min</option><option value=14400>4h</option></select>" + GM_info.script.version); $("#ui-id" + logGPWindow.getID()).empty().append("<select id=choosefarmduration><option value=300>5min</option><option value=1200>20min</option><option value=5400>90min</option><option value=14400>4h</option></select>" + GM_info.script.version);
var choose = $("#choosefarmduration")[0]; var choose = $("#choosefarmduration")[0];
@ -88,7 +94,7 @@
return Math.floor((Math.random() * max * 1000)); return Math.floor((Math.random() * max * 1000));
} }
function getWaresTick(xFarmId) { function getWaresTick(xTownId, xFarmId) {
return function() { return function() {
var timeout = 60000; var timeout = 60000;
try { try {
@ -153,7 +159,7 @@
return; return;
} }
timeout = getWaresFromFarm(wnd, mood, xFarmId) * 1000 + rand(5); timeout = getWaresFromFarm(wnd, mood, xTownId, xFarmId) * 1000 + rand(5);
} finally { } finally {
durations["farm-" + xFarmId] = timeout / 1000; durations["farm-" + xFarmId] = timeout / 1000;
setTimeout(getWaresTick(xFarmId), timeout); setTimeout(getWaresTick(xFarmId), timeout);
@ -161,7 +167,10 @@
} }
} }
function getWaresFromFarm(xWindow, xMood, xFarmId) { function getWaresFromFarm(xWindow, xMood, xTownId, xFarmId) {
if(Game.town_id != xTownId) {
Game.town_id = xTownId;
}
if(xMood - 6 > 80) { if(xMood - 6 > 80) {
log("Plündere " + xFarmId + " @ Mood: " + xMood); log("Plündere " + xFarmId + " @ Mood: " + xMood);
xWindow.call('claimLoad', xFarmId.toString(), 'double', 300); xWindow.call('claimLoad', xFarmId.toString(), 'double', 300);