2015-04-08 21:06:27 -04:00
|
|
|
var botLoop;
|
|
|
|
var botPaused = true;
|
|
|
|
var botPurchasing = false;
|
2015-04-09 13:14:00 -04:00
|
|
|
var botRaiding = false;
|
2015-04-08 21:06:27 -04:00
|
|
|
var botFightingRandomBoss = false;
|
|
|
|
var botFightingGlobalBoss = false;
|
|
|
|
var botBuySlimes = false;
|
2015-04-09 11:06:10 -04:00
|
|
|
var botTickActivity = false;
|
2015-04-09 13:14:00 -04:00
|
|
|
var botRaidTarget = null;
|
2015-04-08 21:06:27 -04:00
|
|
|
var botGlobalBossTimer;
|
|
|
|
|
|
|
|
function mainLoop() {
|
2015-04-09 11:06:10 -04:00
|
|
|
botTickActivity = false;
|
|
|
|
|
2015-04-08 21:06:27 -04:00
|
|
|
if($('#popup').is(':visible')) {
|
|
|
|
var botPopupTitle = $('#popup p[name="title"]').text();
|
|
|
|
switch(botPopupTitle) {
|
|
|
|
case 'Raid report':
|
2015-04-09 11:06:34 -04:00
|
|
|
var botMessage = botBuildRaidReport($('#popup div[name="content"]').text());
|
2015-04-08 21:06:27 -04:00
|
|
|
console.log(botMessage);
|
|
|
|
clickButton('CONTINUE');
|
|
|
|
break;
|
|
|
|
case 'SUMMON BOSS':
|
|
|
|
clickButton('Summon Boss');
|
|
|
|
break;
|
|
|
|
case 'Are you sure?':
|
|
|
|
clickButton('Activate Item');
|
|
|
|
break;
|
|
|
|
case 'ARE YOU SURE?':
|
|
|
|
case 'CONFIRM PURCHASE':
|
|
|
|
if(botPurchasing) {
|
|
|
|
clickButton('Yes');
|
|
|
|
botPurchasing = false;
|
|
|
|
} else {
|
|
|
|
clickButton('No');
|
|
|
|
}
|
|
|
|
break;
|
2015-04-09 13:14:00 -04:00
|
|
|
case 'Raid':
|
|
|
|
if(botRaiding) {
|
|
|
|
clickButton('Raid!');
|
|
|
|
botRaiding = false;
|
|
|
|
} else {
|
|
|
|
clickButton('Nevermind');
|
|
|
|
}
|
|
|
|
break;
|
2015-04-08 21:06:27 -04:00
|
|
|
case 'WHOOPS!':
|
|
|
|
case 'BATTLE REPORT':
|
|
|
|
case 'Battle Report':
|
|
|
|
case 'ACTIVITY PASSED!':
|
|
|
|
case 'SCENARIO #1':
|
2015-04-09 13:14:00 -04:00
|
|
|
case 'Lobby closed':
|
|
|
|
case 'Wait':
|
2015-04-08 21:06:27 -04:00
|
|
|
clickButton('CONTINUE');
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
console.log('Unknown popup: ' + botPopupTitle);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//RANDOM BOSS
|
2015-04-09 11:06:34 -04:00
|
|
|
if(randomBossRefreshing() === true && botFightingRandomBoss === true && botTickActivity === false) {
|
2015-04-08 21:06:27 -04:00
|
|
|
botFightingRandomBoss = false;
|
|
|
|
} else if(randomBossRefreshing() === false && botFightingRandomBoss === false) {
|
|
|
|
clickSelector('#randomBossPortal a');
|
|
|
|
botFightingRandomBoss = true;
|
2015-04-09 11:06:34 -04:00
|
|
|
botTickActivity = true;
|
2015-04-08 21:06:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
//GLOBAL BOSS
|
2015-04-09 11:06:34 -04:00
|
|
|
if(globalBossRefreshing() === true && botFightingGlobalBoss === true && botTickActivity === false) {
|
2015-04-08 21:06:27 -04:00
|
|
|
clearInterval(botGlobalBossTimer);
|
|
|
|
botFightingGlobalBoss = false;
|
|
|
|
} else if(globalBossRefreshing() === false && botFightingGlobalBoss === false) {
|
|
|
|
clickSelector('span[name="timeRemaining"]:contains("JOIN") a');
|
|
|
|
botGlobalBossTimer = setInterval(fightGlobalBoss, 250);
|
|
|
|
botFightingGlobalBoss = true;
|
2015-04-09 11:06:34 -04:00
|
|
|
botTickActivity = true;
|
2015-04-08 21:06:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
//ACTIVATE BUFFS
|
2015-04-09 11:06:34 -04:00
|
|
|
if(inactiveBuffs() && botTickActivity === false) {
|
2015-04-08 21:06:27 -04:00
|
|
|
clickSelector('button:contains("Activate")');
|
2015-04-09 11:06:34 -04:00
|
|
|
botTickActivity = true;
|
2015-04-08 21:06:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
//BUY SCIENTISTS
|
2015-04-09 11:06:34 -04:00
|
|
|
if(haveBossCoins() && haveCheapLabor() && botTickActivity === false) {
|
2015-04-08 21:06:27 -04:00
|
|
|
botPurchasing = true;
|
|
|
|
clickSelector('button[name="hiremax_scientists"]');
|
2015-04-09 11:06:34 -04:00
|
|
|
botTickActivity = true;
|
2015-04-08 21:06:27 -04:00
|
|
|
}
|
|
|
|
|
2015-04-09 13:14:00 -04:00
|
|
|
//RAID
|
|
|
|
if(raidRefreshing() === false && haveRaidTarget() === true && botTickActivity === false) {
|
|
|
|
clickSelector('button[name="raid_button"]');
|
|
|
|
botFillIn('input[name="raid_user"]', botRaidTarget);
|
|
|
|
botTickActivity = true;
|
|
|
|
botRaiding = true;
|
|
|
|
}
|
|
|
|
|
2015-04-08 21:06:27 -04:00
|
|
|
//BUY SLIMES
|
2015-04-09 11:06:34 -04:00
|
|
|
if(botBuySlimes === true && haveTrillions(10) && botTickActivity === false) {
|
2015-04-08 21:06:27 -04:00
|
|
|
botPurchasing = true;
|
|
|
|
clickSelector('button[name="buymax-knight"]');
|
2015-04-09 11:06:34 -04:00
|
|
|
botTickActivity = true;
|
2015-04-08 21:06:27 -04:00
|
|
|
}
|
2015-04-06 17:01:14 -04:00
|
|
|
}
|
|
|
|
|
2015-04-08 21:06:27 -04:00
|
|
|
botToggle();
|
2015-04-06 17:30:55 -04:00
|
|
|
|
2015-04-09 13:14:00 -04:00
|
|
|
function botFillIn(selector, text) {
|
|
|
|
$(selector).val(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
function raidRefreshing() {
|
|
|
|
if($('span[name="raidtime"]').text().trim() == "") {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function haveRaidTarget() {
|
|
|
|
if(botRaidTarget == null) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-08 21:06:27 -04:00
|
|
|
function botBuildRaidReport(message) {
|
2015-04-09 11:06:34 -04:00
|
|
|
var botRaidUser;
|
|
|
|
if(/You.? were raided by (.*?).? /.exec(message)) {
|
|
|
|
botRaidUser = /You.? were raided by (.*?).? /.exec(message)[1];
|
|
|
|
} else {
|
|
|
|
botRaidUser = /You .*? the raid against (.*?)! /.exec(message)[1];
|
|
|
|
}
|
|
|
|
var botRaidSoldiers = /! .*? lost (.*?) soldiers/.exec(message)[1];
|
2015-04-08 21:06:27 -04:00
|
|
|
var botRaidResult = (/won/.exec(message) !== null) ? 'won' : 'lost';
|
|
|
|
var botRaidStolen = (/steal (.*?) from/.exec(message) !== null) ? /steal (.*?) from/.exec(message)[1] : '$0';
|
|
|
|
|
2015-04-09 11:06:34 -04:00
|
|
|
return "RAIDED (" + botRaidUser + "): " + botRaidResult + "; souldiers: -" + botRaidSoldiers + "; " + botRaidResult + " money: " + botRaidStolen;
|
2015-04-08 21:06:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function haveTrillions(trillions) {
|
|
|
|
var botCurrency = $('#money_display').text();
|
|
|
|
var botLowerLimit = trillions * 1000000000000;
|
|
|
|
var botCurrencyInt = Number(botCurrency.replace(/[^0-9\.]+/g,""));
|
|
|
|
if(botCurrencyInt > botLowerLimit) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function haveBossCoins() {
|
|
|
|
if($('#bc_display').text() != 0) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function haveCheapLabor() {
|
|
|
|
if($('span[name="scientists_price"]').text() == "1 BC") {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function inactiveBuffs() {
|
|
|
|
if($('button:contains("Activate")').length > 0) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2015-04-07 16:55:11 -04:00
|
|
|
|
2015-04-08 21:06:27 -04:00
|
|
|
function randomBossRefreshing() {
|
|
|
|
if($('span[name="timer"]').is(':visible')) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2015-04-07 13:42:08 -04:00
|
|
|
}
|
|
|
|
|
2015-04-08 21:06:27 -04:00
|
|
|
function globalBossRefreshing() {
|
|
|
|
if($('span[name="timeRemaining"]:contains("min"), span[name="timeRemaining"]:contains("sec")').length > 0) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
2015-04-06 17:30:55 -04:00
|
|
|
}
|
2015-04-07 13:42:08 -04:00
|
|
|
}
|
2015-04-07 15:19:27 -04:00
|
|
|
|
2015-04-08 21:06:27 -04:00
|
|
|
function fightGlobalBoss() {
|
|
|
|
if($('img[name="globalBossImg"]').is(':visible')) {
|
|
|
|
$('img[name="globalBossImg"]').get(0).click();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function clickButton(text) {
|
|
|
|
$('#popup span button:contains("' + text + '")').get(0).click();
|
|
|
|
}
|
|
|
|
|
|
|
|
function clickSelector(selector) {
|
|
|
|
$(selector).get(0).click();
|
2015-04-07 15:19:27 -04:00
|
|
|
}
|
2015-04-07 15:44:58 -04:00
|
|
|
|
2015-04-08 21:06:27 -04:00
|
|
|
function botToggle() {
|
|
|
|
if(botPaused) {
|
|
|
|
console.log('Playing bot');
|
|
|
|
botLoop = setInterval(mainLoop, 1000);
|
|
|
|
botPaused = false;
|
|
|
|
} else {
|
|
|
|
console.log('Pausing bot');
|
|
|
|
clearInterval(botLoop);
|
|
|
|
botPaused = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function botToggleSlimes() {
|
|
|
|
if(botBuySlimes) {
|
|
|
|
console.log('Stopping slime purchases');
|
|
|
|
botBuySlimes = false;
|
|
|
|
} else {
|
|
|
|
console.log('Starting slime purchases');
|
|
|
|
botBuySlimes = true;
|
|
|
|
}
|
2015-04-07 15:44:58 -04:00
|
|
|
}
|
2015-04-09 13:14:00 -04:00
|
|
|
|
|
|
|
function botSetTarget(username) {
|
|
|
|
botRaidTarget = username;
|
|
|
|
}
|
|
|
|
|
|
|
|
function botClearTarget() {
|
|
|
|
botRaidTarget = null;
|
|
|
|
}
|