javascript:
var worldSpeed=1.75;
var resend={
unit:'light',
spy:0,
minutes:150
};
var defaultBuildingLevel=20;
var script={
id:'6A6C55B4-D459-4341-B81D-BF448104D376',
name:'Mangina Farmer Script',
version:1.00,
minGameVersion:7.00,
author:{
name:'dalesmckay',
email:'dalesmckay@gmail.com',
url:'http://crosstrigger.com'
},
credit:'(Dedicated to <span style="color:blue;">Karmalot</span>)',
runOnce:false
};
function fnInt(value){return parseInt(value||'0',10);}
function fnPrint(msg){$('body').append('<span>'+msg+'</span><br/>');}
function fnPrintVersion(){
var authorURL=script.author.url?('<a href="'+script.author.url+'" target="_blank">'+script.author.name+'</a>'):script.author.name;
fnPrint('');
fnPrint('<span style="color:red;font-weight:bold;">Provide the following info when asking for help:</span><hr>');
fnPrint('=========================');
fnPrint(authorURL + '\'s ' + script.name + ': v' + script.version.toFixed(2) + (script.credit?('<br/>'+script.credit):''));
fnPrint('=========================');
/*fnPrint($.trim($('td.server_info').text().match(/\|\s*(.+)/)[1]));*/
fnPrint('Account: '+win.game_data.player.name);
fnPrint('Sitter : '+((fnInt(win.game_data.player.sitter_id)>0)?('yes - '+win.game_data.player.sitter_id):'no'));
fnPrint('=========================');
fnPrint('Version: '+win.game_data.version);
fnPrint('World : '+win.game_data.world);
fnPrint('Screen : '+win.game_data.screen);
fnPrint('Mode : '+win.game_data.mode);
fnPrint('URL : '+win.location.href);
fnPrint('Browser: '+navigator.userAgent);
fnPrint('=========================');
fnPrint('worldSpeed: '+worldSpeed);
fnPrint('resend: '+JSON.stringify(resend));
fnPrint('defaultBuildingLevel: '+defaultBuildingLevel);
fnPrint('=========================');
fnPrint('');
}
var win=(window.main||self),$=win.$;
fnPrintVersion();
if((win.game_data.screen=='place')&&!win.game_data.mode&&win.location.search.match(/dsmScript\=true/i)){
var config={spear:0,sword:0,archer:0,axe:0,spy:1,light:0,marcher:0,heavy:0,ram:0,catapult:0,knight:0,snob:0};
config.spy=(win.location.search.match(/spy\=(\d+)/i)||[0,0])[1];
var unit=(win.location.search.match(/unit\=(\w+)/i)||[0,0])[1];
var qty=(win.location.search.match(/qty\=(\d+)/i)||[0,0])[1];
config[unit]=qty;
$.each(config,function(i,e){
$('input[name="'+i+'"]').val(Math.min(e,fnInt($('input[name="'+i+'"]').closest('tr').text().match(/\d+/))));
});
}
else if((win.game_data.screen!='report')||!win.location.search.match(/view\=\d+/i)){
var msg='This script must be run from a Report Detail Screen!';
fnPrint(msg);
alert(msg);
}
else{
var buildingInfo={
wood:{name:'Timber camp',level:defaultBuildingLevel},
stone:{name:'Clay pit',level:defaultBuildingLevel},
iron:{name:'Iron mine',level:defaultBuildingLevel}
};
var unitInfo={
spear:{name:'Spear fighter',carry:25},
sword:{name:'Swordsman',carry:15},
axe:{name:'Axeman',carry:10},
archer:{name:'Archer',carry:10},
light:{name:'Light cavalry',carry:80},
marcher:{name:'Mounted archer',carry:50},
heavy:{name:'Heavy cavalry',carry:50}
};
function fnResourceProduction(lvl){return ((lvl==0)?5:Math.round(30*Math.pow(80,(lvl-1)/29)))*worldSpeed;}
function fnExtractBuildings(){
var buildings=undefined;
var buildingSrc=$('#attack_spy tr:eq(1) td:first').html();
if(buildingSrc){
buildingSrc=buildingSrc.match(/\w+\s\w*\s*<b>\(\w+\s\d+\)/ig);
if(buildingSrc){
buildings={};
$.each(buildingSrc,function(i,e){
buildings[$.trim(e.match(/\w+\s*\w*\s*/i))]=fnInt(e.match(/\d+/));
});
}
}
return buildings;
}
var buildings=fnExtractBuildings();
if(buildings){
$.each(buildingInfo,function(i,e){
buildingInfo[i].level=buildings[e.name];
});
}
var hourlyResources=0;
$.each(buildingInfo,function(i,e){
hourlyResources+=fnResourceProduction(e.level);
});
fnPrint('Resources: '+hourlyResources*(resend.minutes/60));
fnPrint('');
$.each(unitInfo,function(i,e){
unitInfo[i].qty=Math.round((hourlyResources*(resend.minutes/60))/e.carry);
fnPrint('%%UNITID - (%%UNITDESC): %%QTY'.replace(/\%\%QTY/ig,unitInfo[i].qty).replace(/\%\%UNITID/ig,i).replace(/\%\%UNITDESC/ig,unitInfo[i].name));
});
var villageID=$('#attack_info_def td a:eq(0)').attr('href').match(/id\=(\d+)/i)[1];
win.open(win.game_data.link_base_pure.replace(/screen\=\w*/ig,'screen=place&target='+villageID+'&dsmScript=true&spy='+resend.spy+'&unit='+resend.unit+'&qty='+unitInfo[resend.unit].qty));
}
void(0);