Thursday, August 11, 2011

Script REKRUT MASSAL

Script REKRUT MASSAL

javascript:var%20archers%20=%20true;%20var%20configuration%20=%20[0,0,10000,0,0,2500,200,0,230,0];var%20units;var%20unitsNET;var%20costs;function%20arrayMin(array){var%20value=array[0];for(var%20%20t=1;t%3Carray.length;t++){if(array[t]%3Cvalue){value=array[t];}}return%20%20value;}function%20linearDivideArray(array1,array2){var%20%20value=[];if(array1.length==array2.length){for(var%20%20t=0;t%3Carray1.length;t++){if(array2[t]!=0){value[t]=array1[t]*1.0/array2[t];}else{value[t]=0;}}}return%20%20value;}function%20linearAddArray(array1,array2){var%20%20value=[];if(array1.length==array2.length){for(var%20%20t=0;t%3Carray1.length;t++){value[t]=array1[t]+array2[t];}}return%20%20value;}function%20getUnitId(unit){for(var%20%20t=0;t%3Cunits.length;t++){if(unit==unitsNET[t]){return%20%20t;}}return-1;}function%20getQueue(record){var%20value=[0,0,0,0,0,0,0,0,0,0];for(var%20%20u=3;u%3Crecord.cells.length;u++){try{value[u-3]=parseInt(record.cells.childNodes[1].childNodes[1].firstChild.title,10);}catch(e){}if(isNaN(value[u-3])){value[u-3]=0;}}return%20%20value;}function%20getResources(record){var%20%20value=[0,0,0,0];var%20res=record.cells[1].textContent.split(%22\n%22);var%20%20farm=record.cells[2].innerHTML.split('/');value[0]=parseInt(res[1].replace(%22.%22,%22%22),10);value[1]=parseInt(res[2].replace(%22.%22,%22%22),10);value[2]=parseInt(res[3].replace(%22.%22,%22%22),10);value[3]=farm[1]-farm[0];return%20%20value;}function%20getProduced(record){var%20%20value=[0,0,0,0,0,0,0,0,0,0];for(var%20%20u=3;u%3Crecord.cells.length;u++){try{value[u-3]=parseInt(record.cells.childNodes[1].textContent.split(%22\n%22)[2],10);}catch(e){}if(isNaN(value[u-3])){value[u-3]=0;}}return%20%20value;}if(document.URL.match('screen=train')&&document.URL.match('mode=mass')){var%20%20records=document.getElementById('mass_train_table').rows;if(archers){units=['spear','sword','axe','archer','spy','light','marcher','heavy','ram','catapult'];unitsNET=['Spear%20Fighter','Swordsman','Axeman','Archer','Scout','Light%20Cavalry','Mounted%20Archer','Heavy%20Cavalry','Ram','Catapult'];costs=[[50,30,10,1],[30,30,70,1],[60,30,40,1],[100,30,60,1],[50,50,20,2],[125,100,250,4],[250,100,150,5],[200,150,600,6],[300,200,200,5],[320,400,100,8]];}else{units=['spear','sword','axe','spy','light','heavy','ram','catapult'];unitsNET=['Spear%20Fighter','Swordsman','Axeman','Scout','Light%20Cavalry','Heavy%20Cavalry','Ram','Catapult'];costs=[[50,30,10,1],[30,30,70,1],[60,30,40,1],[50,50,20,2],[125,100,250,4],[200,150,600,6],[300,200,200,5],[320,400,100,8]];}for(r=1;r%3Crecords.length;r++){var%20%20subconf=[];var%20total_costs=[0,0,0,0];var%20%20i;var%20resources=getResources(records[r]);var%20%20queue=getQueue(records[r]);var%20%20produced=getProduced(records[r]);for(i=0;i%3Cunits.length;i++){subconf=configuration-(queue+produced);if(subconf%3C0){subconf=0;}for(var%20%20j=0;j%3C4;j++){total_costs[j]+=costs[j]*subconf;}};var%20%20factor=arrayMin(linearDivideArray(resources,total_costs));if(factor%3E1.0){factor=1.0;}for(i=0;i%3Cunits.length;i++){var%20%20number=subconf*factor;if(number%3C0){number=0;}if(number!=0){if(records[r].cells[3+i].childNodes[3]&&records[r].cells[3+i].childNodes[3].disabled==false){var%20%20ibox=records[r].cells[3+i].childNodes[3];try{ibox.value=parseInt(number,10);}catch(e){alert(e);}}}}}stop();}else{alert('Script%20only%20works%20on%20the%20mass%20recruitment%20page');}

0 comments:

Popular Posts