2015-04-14 17:19:05 -04:00
|
|
|
var BOT_WORKER_MONEY = 1;
|
|
|
|
var BOT_SLIME_MONEY = 10;
|
2015-04-17 13:41:39 -04:00
|
|
|
var CHAT_LIMIT = 150;
|
2015-04-21 11:07:14 -04:00
|
|
|
var SAFE_SOLDIER_COUNT = 50000000;
|
2015-04-14 17:19:05 -04:00
|
|
|
|
2015-04-08 21:06:27 -04:00
|
|
|
var botLoop;
|
2015-04-13 18:42:38 -04:00
|
|
|
var botGlobalBossTimer;
|
2015-04-08 21:06:27 -04:00
|
|
|
var botPaused = true;
|
|
|
|
var botPurchasing = false;
|
2015-04-17 13:41:39 -04:00
|
|
|
var botSleeping = 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-14 14:43:44 -04:00
|
|
|
var botBuyWorkers = false;
|
2015-04-11 00:14:34 -04:00
|
|
|
var botFightGlobal = true;
|
2015-04-14 10:24:09 -04:00
|
|
|
var botFightRandom = true;
|
2015-04-19 10:01:54 -04:00
|
|
|
var botSpendBossCoins = true;
|
2015-04-17 13:41:39 -04:00
|
|
|
var botChatClear = true;
|
2015-04-23 09:56:49 -04:00
|
|
|
var botSaveSpears = true;
|
2015-04-09 13:14:00 -04:00
|
|
|
var botRaidTarget = null;
|
2015-04-14 10:09:27 -04:00
|
|
|
var botLastRandom = 0;
|
2015-04-14 10:52:59 -04:00
|
|
|
var botLastRaid = 0;
|
2015-04-15 21:27:34 -04:00
|
|
|
var botLastPurchase = 0;
|
2015-04-14 16:32:57 -04:00
|
|
|
var botUser = null;
|
2015-04-08 21:06:27 -04:00
|
|
|
|
|
|
|
function mainLoop() {
|
|
|
|
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);
|
2015-04-14 10:52:59 -04:00
|
|
|
botLastRaid = botTimestamp();
|
2015-04-08 21:06:27 -04:00
|
|
|
clickButton('CONTINUE');
|
|
|
|
break;
|
|
|
|
case 'SUMMON BOSS':
|
|
|
|
clickButton('Summon Boss');
|
2015-04-13 19:15:31 -04:00
|
|
|
botLastRandom = botTimestamp();
|
2015-04-08 21:06:27 -04:00
|
|
|
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':
|
2015-04-09 14:06:34 -04:00
|
|
|
if(haveRaidTarget() === true) {
|
|
|
|
if(botRaiding) {
|
|
|
|
clickButton('Raid!');
|
|
|
|
botRaiding = false;
|
|
|
|
} else {
|
|
|
|
clickButton('Nevermind');
|
|
|
|
}
|
2015-04-09 13:14:00 -04:00
|
|
|
}
|
|
|
|
break;
|
2015-04-14 14:43:44 -04:00
|
|
|
case 'CONFIRM':
|
|
|
|
if(botPurchasing) {
|
|
|
|
clickButton('Yes');
|
|
|
|
botPurchasing = false;
|
|
|
|
}
|
|
|
|
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-13 20:09:38 -04:00
|
|
|
case 'ACTIVITY FAILED!':
|
2015-04-14 10:09:27 -04:00
|
|
|
case 'Game in progress':
|
2015-04-14 10:52:59 -04:00
|
|
|
case 'User not found':
|
2015-04-08 21:06:27 -04:00
|
|
|
clickButton('CONTINUE');
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
console.log('Unknown popup: ' + botPopupTitle);
|
|
|
|
break;
|
|
|
|
}
|
2015-04-13 18:42:38 -04:00
|
|
|
} else {
|
|
|
|
//RANDOM BOSS
|
2015-04-15 17:16:34 -04:00
|
|
|
if(randomBossRefreshing() === true && botFightingRandomBoss === true && botFightingGlobalBoss === false) {
|
2015-04-13 18:42:38 -04:00
|
|
|
botFightingRandomBoss = false;
|
2015-04-16 08:54:22 -04:00
|
|
|
} else if(randomBossRefreshing() === false && botFightingRandomBoss === false && botFightRandom === true && haveSoldiers() === true) {
|
2015-04-13 18:42:38 -04:00
|
|
|
clickSelector('#randomBossPortal a');
|
|
|
|
botFightingRandomBoss = true;
|
2015-04-16 08:54:22 -04:00
|
|
|
} else if(botTimestamp() > botLastRandom + 180 && botFightRandom === true && haveSoldiers() === true) {
|
2015-04-13 19:15:31 -04:00
|
|
|
clickSelector('#randomBossPortal a');
|
|
|
|
botFightingRandomBoss = true;
|
2015-04-13 18:42:38 -04:00
|
|
|
}
|
2015-04-08 21:06:27 -04:00
|
|
|
|
2015-04-21 11:07:14 -04:00
|
|
|
//RANDOM BOSS MOBS
|
|
|
|
if(haveSlimes(SAFE_SOLDIER_COUNT) === false && botFightRandom === true && botPurchasing === false) {
|
|
|
|
setBotToPurchasing();
|
|
|
|
clickSelector('button[name="buyx-knight"]');
|
|
|
|
botFillIn('input[name="x_amount"]', SAFE_SOLDIER_COUNT);
|
|
|
|
clickButton("Buy");
|
|
|
|
}
|
|
|
|
|
|
|
|
if(haveCreepers(SAFE_SOLDIER_COUNT) === false && botFightRandom === true && botPurchasing === false) {
|
|
|
|
setBotToPurchasing();
|
|
|
|
clickSelector('button[name="buyx-advknight"]');
|
|
|
|
botFillIn('input[name="x_amount"]', SAFE_SOLDIER_COUNT);
|
|
|
|
clickButton("Buy");
|
|
|
|
}
|
|
|
|
|
2015-04-13 18:42:38 -04:00
|
|
|
//GLOBAL BOSS
|
|
|
|
if(globalBossRefreshing() === true && botFightingGlobalBoss === true) {
|
|
|
|
clearInterval(botGlobalBossTimer);
|
|
|
|
botFightingGlobalBoss = false;
|
|
|
|
} else if(globalBossRefreshing() === false && botFightingGlobalBoss === false && botFightGlobal === true) {
|
|
|
|
clickSelector('span[name="timeRemaining"]:contains("JOIN") a');
|
|
|
|
botGlobalBossTimer = setInterval(fightGlobalBoss, 250);
|
|
|
|
botFightingGlobalBoss = true;
|
|
|
|
}
|
2015-04-08 21:06:27 -04:00
|
|
|
|
2015-04-13 18:42:38 -04:00
|
|
|
//ACTIVATE BUFFS
|
|
|
|
if(inactiveBuffs()) {
|
2015-04-23 09:56:49 -04:00
|
|
|
activateBuffs();
|
2015-04-13 18:42:38 -04:00
|
|
|
}
|
2015-04-08 21:06:27 -04:00
|
|
|
|
2015-04-13 18:42:38 -04:00
|
|
|
//RAID
|
2015-04-14 11:29:57 -04:00
|
|
|
if(raidRefreshing() === false && haveRaidTarget() === true && internalRaidRefreshing() === false) {
|
2015-04-13 18:42:38 -04:00
|
|
|
clickSelector('button[name="raid_button"]');
|
|
|
|
botFillIn('input[name="raid_user"]', botRaidTarget);
|
|
|
|
botRaiding = true;
|
|
|
|
}
|
2015-04-09 13:14:00 -04:00
|
|
|
|
2015-04-15 21:27:34 -04:00
|
|
|
//PURCHASES
|
|
|
|
if(botTimestamp() > botLastPurchase + 5 && botPurchasing === true) {
|
|
|
|
botPurchasing = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//BUY SCIENTISTS
|
2015-04-19 10:01:54 -04:00
|
|
|
if(haveBossCoins(1) === true && haveCheapLabor() === true && botPurchasing === false && haveMaxWorker('capturedminion') && botSpendBossCoins === true) {
|
2015-04-21 11:07:14 -04:00
|
|
|
setBotToPurchasing();
|
2015-04-15 21:27:34 -04:00
|
|
|
clickSelector('button[name="hiremax_scientists"]');
|
|
|
|
}
|
|
|
|
|
2015-04-13 18:42:38 -04:00
|
|
|
//BUY SLIMES
|
2015-04-16 08:54:22 -04:00
|
|
|
if(botBuySlimes === true && haveTrillions(BOT_SLIME_MONEY) === true && botPurchasing === false) {
|
2015-04-21 11:07:14 -04:00
|
|
|
setBotToPurchasing();
|
2015-04-13 18:42:38 -04:00
|
|
|
clickSelector('button[name="buymax-knight"]');
|
|
|
|
}
|
2015-04-14 14:43:44 -04:00
|
|
|
|
|
|
|
//BUY WORKERS
|
2015-04-16 08:54:22 -04:00
|
|
|
if(botBuyWorkers === true && haveTrillions(BOT_WORKER_MONEY) === true && haveCheapLabor() === true && botPurchasing === false) {
|
2015-04-21 11:07:14 -04:00
|
|
|
setBotToPurchasing();
|
2015-04-14 14:43:44 -04:00
|
|
|
clickSelector('button[name="buymax-' + mostEfficientWorker() + '"]');
|
|
|
|
}
|
2015-04-19 10:01:54 -04:00
|
|
|
if(botBuyWorkers === true && haveCheapLabor() === true && botPurchasing === false && haveBossCoins(9) === true && botSpendBossCoins === true) {
|
2015-04-21 11:07:14 -04:00
|
|
|
setBotToPurchasing();
|
2015-04-15 18:32:36 -04:00
|
|
|
clickSelector('button[name="buymax-capturedminion"]');
|
|
|
|
}
|
2015-04-08 21:06:27 -04:00
|
|
|
}
|
2015-04-16 10:22:43 -04:00
|
|
|
|
|
|
|
//CLEAR CHAT
|
2015-04-17 13:41:39 -04:00
|
|
|
if(haveChatLines(CHAT_LIMIT) === true && botChatClear === true) {
|
|
|
|
$('#chatbox div:lt(' + Math.ceil(CHAT_LIMIT * .2) + ')').remove();
|
2015-04-16 10:22:43 -04:00
|
|
|
}
|
2015-04-06 17:01:14 -04:00
|
|
|
}
|
|
|
|
|
2015-04-14 16:32:57 -04:00
|
|
|
botDetectUser();
|
2015-04-08 21:06:27 -04:00
|
|
|
botToggle();
|
2015-04-06 17:30:55 -04:00
|
|
|
|
2015-04-23 09:56:49 -04:00
|
|
|
function activateBuffs() {
|
|
|
|
$('div[name="items_holder"]').children().each(function() {
|
|
|
|
var itemHolder = $(this);
|
|
|
|
|
2015-04-23 10:29:23 -04:00
|
|
|
if(itemHolder.attr('item') != 'godspear_fragment' || botSaveSpears === false || haveMaxItems()) {
|
2015-04-23 09:56:49 -04:00
|
|
|
var itemButton = itemHolder.find('button:contains("Activate")');
|
|
|
|
if(itemButton.length > 0) {
|
|
|
|
itemButton.get(0).click()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-04-23 10:29:23 -04:00
|
|
|
function haveMaxItems() {
|
2015-04-23 10:32:14 -04:00
|
|
|
return convertToNumber($('span[name="item_count"').text().split('/')[0]) >= 17;
|
2015-04-23 10:29:23 -04:00
|
|
|
}
|
|
|
|
|
2015-04-21 11:07:14 -04:00
|
|
|
function setBotToPurchasing() {
|
|
|
|
botPurchasing = true;
|
|
|
|
botLastPurchase = botTimestamp();
|
|
|
|
}
|
|
|
|
|
|
|
|
function haveSlimes(value) {
|
|
|
|
return convertToNumber($('tr[name="knight"] span[name="owned"]').text()) >= value;
|
|
|
|
}
|
|
|
|
|
|
|
|
function haveCreepers(value) {
|
|
|
|
return convertToNumber($('tr[name="advknight"] span[name="owned"]').text()) >= value;
|
|
|
|
}
|
|
|
|
|
2015-04-17 13:41:39 -04:00
|
|
|
function haveChatLines(value) {
|
|
|
|
if($('#chatbox').children().length > value) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-16 08:54:22 -04:00
|
|
|
function haveMaxWorker(type) {
|
|
|
|
var worker = $('tr[name="' + type + '"]').find('span[name="owned"]').text();
|
|
|
|
worker = worker.replace(/\s+/g, '');
|
|
|
|
var workerArray = worker.split('/');
|
2015-04-15 18:32:36 -04:00
|
|
|
|
2015-04-16 08:54:22 -04:00
|
|
|
return convertToNumber(workerArray[0]) == convertToNumber(workerArray[1]);
|
2015-04-15 18:32:36 -04:00
|
|
|
}
|
|
|
|
|
2015-04-14 16:32:57 -04:00
|
|
|
function botDetectUser() {
|
2015-04-16 08:11:15 -04:00
|
|
|
var guests = $('#player-list div.no-icon span.username-holder');
|
2015-04-14 16:32:57 -04:00
|
|
|
var randomGuest = $(guests[Math.floor(Math.random() * guests.length)]).text();
|
|
|
|
|
|
|
|
$('#chatbox').bind('DOMSubtreeModified', function() {
|
|
|
|
var lastMessage = $(this).find('.chat-message').last();
|
|
|
|
if(lastMessage.find('.chat-pm').text() == 'PM -> ' + randomGuest) {
|
|
|
|
botUser = lastMessage.find('.username').text().trim();
|
|
|
|
console.log('Setting bot user to ' + botUser);
|
|
|
|
$('#chatbox').unbind('DOMSubtreeModified');
|
|
|
|
chatMonitor();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
botSendChat('/pm ' + randomGuest + ' hello!');
|
|
|
|
}
|
|
|
|
|
|
|
|
function botSendChat(message) {
|
|
|
|
botFillIn('#chat_msg', message);
|
|
|
|
var e = jQuery.Event("keypress");
|
|
|
|
e.which = 13;
|
|
|
|
e.keyCode = 13;
|
|
|
|
$("#chat_msg").trigger(e);
|
|
|
|
}
|
|
|
|
|
2015-04-14 14:43:44 -04:00
|
|
|
function mostEfficientWorker() {
|
|
|
|
var bestValueWorker;
|
|
|
|
var bestValue;
|
|
|
|
$('table[name="workers"] > tbody').children().each(function() {
|
|
|
|
var workersTable = $(this);
|
|
|
|
if(workersTable.is('[name]') && workersTable.attr('name') != 'capturedminion' && workersTable.attr('name') != 'gb_capturedminion') {
|
|
|
|
var price = convertToNumber(workersTable.find('span[name="price"]').text());
|
|
|
|
var opm = convertToNumber(workersTable.find('span[name="opm"]').text());
|
|
|
|
var value = opm / price;
|
|
|
|
|
2015-04-16 08:54:22 -04:00
|
|
|
if(bestValueWorker == null || bestValue < value && haveMaxWorker(workersTable.attr('name')) === false) {
|
2015-04-14 14:43:44 -04:00
|
|
|
bestValueWorker = workersTable.attr('name');
|
|
|
|
bestValue = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return bestValueWorker;
|
|
|
|
}
|
|
|
|
|
2015-04-14 10:52:59 -04:00
|
|
|
function internalRaidRefreshing() {
|
|
|
|
if(botTimestamp() > botLastRaid + 300) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-13 21:42:34 -04:00
|
|
|
function haveSoldiers() {
|
2015-04-21 11:07:14 -04:00
|
|
|
return haveSlimes(1) && haveCreepers(1);
|
2015-04-13 21:42:34 -04:00
|
|
|
}
|
|
|
|
|
2015-04-13 20:47:17 -04:00
|
|
|
function chatMonitor() {
|
|
|
|
$('#chatbox, #groupchatbox').bind('DOMSubtreeModified', function() {
|
|
|
|
var lastMessage = $(this).find('.chat-message').last();
|
|
|
|
if(chatIsPM(lastMessage) || chatHasName(lastMessage)) {
|
|
|
|
var user = lastMessage.find('.username').text().trim();
|
|
|
|
var content = lastMessage.find('.message').text().trim();
|
|
|
|
console.log('CHAT (' + user + '): ' + content);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function chatIsPM(message) {
|
|
|
|
return message.find('.chat-pm').length > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function chatHasName(message) {
|
2015-04-14 16:32:57 -04:00
|
|
|
if(botUser == null) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-04-13 21:59:56 -04:00
|
|
|
var string = message.find('.message').text();
|
2015-04-14 16:32:57 -04:00
|
|
|
return (new RegExp('\\b' + botUser + '\\b')).test(string);
|
2015-04-13 19:15:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function botTimestamp() {
|
|
|
|
return Math.floor(Date.now() / 1000);
|
|
|
|
}
|
|
|
|
|
2015-04-09 13:14:00 -04:00
|
|
|
function botFillIn(selector, text) {
|
|
|
|
$(selector).val(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
function raidRefreshing() {
|
2015-04-10 18:18:55 -04:00
|
|
|
if($('span[name="raidtime"]').css('display') == 'none') {
|
2015-04-09 13:14:00 -04:00
|
|
|
return false;
|
2015-04-10 18:20:38 -04:00
|
|
|
} else {
|
|
|
|
return true;
|
2015-04-09 13:14:00 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function haveRaidTarget() {
|
|
|
|
if(botRaidTarget == null) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-08 21:06:27 -04:00
|
|
|
function botBuildRaidReport(message) {
|
2015-04-15 11:00:32 -04:00
|
|
|
var botAttacker, botDefender;
|
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];
|
2015-04-15 11:00:32 -04:00
|
|
|
botAttacker = botRaidUser;
|
|
|
|
botDefender = botUser;
|
2015-04-09 11:06:34 -04:00
|
|
|
} else {
|
|
|
|
botRaidUser = /You .*? the raid against (.*?)! /.exec(message)[1];
|
2015-04-15 11:00:32 -04:00
|
|
|
botAttacker = botUser;
|
|
|
|
botDefender = botRaidUser;
|
2015-04-09 11:06:34 -04:00
|
|
|
}
|
|
|
|
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-15 11:00:32 -04:00
|
|
|
var botStolen = (botRaidResult == 'won') ? botRaidStolen : '-' + botRaidStolen;
|
|
|
|
|
|
|
|
$.post('http://shielded-dusk-2170.herokuapp.com/', { raid: { attacker: botAttacker, defender: botDefender, soldiers: botRaidSoldiers, money: botStolen}});
|
|
|
|
|
2015-04-13 21:42:34 -04:00
|
|
|
return "RAIDED (" + botRaidUser + "): " + botRaidResult + "; soldiers: -" + botRaidSoldiers + "; " + botRaidResult + " money: " + botRaidStolen;
|
2015-04-08 21:06:27 -04:00
|
|
|
}
|
|
|
|
|
2015-04-13 19:53:48 -04:00
|
|
|
function haveTrillions(number) {
|
|
|
|
if(convertToNumber($('#money_display').text()) > trillions(number)) {
|
2015-04-08 21:06:27 -04:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-13 19:53:48 -04:00
|
|
|
function convertToNumber(string) {
|
|
|
|
return Number(string.replace(/[^0-9\.]+/g, ''));
|
|
|
|
}
|
|
|
|
|
|
|
|
function trillions(number) {
|
|
|
|
return number * 1000000000000;
|
|
|
|
}
|
|
|
|
|
2015-04-15 19:18:23 -04:00
|
|
|
function haveBossCoins(value) {
|
|
|
|
if(convertToNumber($('#bc_display').text()) >= value) {
|
2015-04-08 21:06:27 -04:00
|
|
|
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-14 10:28:12 -04:00
|
|
|
function botSetTarget(username) {
|
|
|
|
botRaidTarget = username;
|
|
|
|
}
|
|
|
|
|
|
|
|
function botClearTarget() {
|
|
|
|
botRaidTarget = null;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2015-04-14 14:43:44 -04:00
|
|
|
function botToggleWorkers() {
|
|
|
|
if(botBuyWorkers) {
|
|
|
|
console.log('Stopping worker purchases');
|
|
|
|
botBuyWorkers = false;
|
|
|
|
} else {
|
|
|
|
console.log('Starting worker purchases');
|
|
|
|
botBuyWorkers = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-11 00:14:34 -04:00
|
|
|
function botToggleGlobal() {
|
|
|
|
if(botFightGlobal) {
|
|
|
|
console.log('Stopping global fighting');
|
|
|
|
botFightGlobal = false;
|
|
|
|
} else {
|
|
|
|
console.log('Starting global fighting');
|
|
|
|
botFightGlobal = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-14 10:24:09 -04:00
|
|
|
function botToggleRandom() {
|
2015-04-14 11:23:54 -04:00
|
|
|
if(botFightRandom) {
|
2015-04-14 10:24:09 -04:00
|
|
|
console.log('Stopping random fighting');
|
|
|
|
botFightRandom = false;
|
|
|
|
} else {
|
|
|
|
console.log('Starting random fighting');
|
|
|
|
botFightRandom = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-13 20:47:17 -04:00
|
|
|
function botToggleUI() {
|
|
|
|
clickSelector('a[name="portal"]');
|
|
|
|
clickSelector('button[name="vault_hide"]');
|
|
|
|
$('a[name="bossPortal"] > img').toggle();
|
|
|
|
}
|
|
|
|
|
2015-04-14 10:28:12 -04:00
|
|
|
function botToggleSleep() {
|
|
|
|
if(botSleeping) {
|
2015-04-14 13:27:04 -04:00
|
|
|
console.log('Stopping sleep mode');
|
2015-04-14 10:28:12 -04:00
|
|
|
botFightRandom = true;
|
|
|
|
botFightGlobal = true;
|
|
|
|
botSleeping = false;
|
|
|
|
} else {
|
2015-04-14 13:27:04 -04:00
|
|
|
console.log('Starting sleep mode');
|
2015-04-14 10:28:12 -04:00
|
|
|
botFightRandom = false;
|
|
|
|
botFightGlobal = false;
|
|
|
|
botBuySlimes = false;
|
|
|
|
botSleeping = true;
|
|
|
|
}
|
2015-04-09 13:14:00 -04:00
|
|
|
}
|
|
|
|
|
2015-04-17 13:41:39 -04:00
|
|
|
function botToggleChatClear() {
|
|
|
|
if(botChatClear) {
|
|
|
|
console.log('Stopping chat clearing');
|
|
|
|
botChatClear = false;
|
|
|
|
} else {
|
|
|
|
console.log('Starting chat clearing');
|
|
|
|
botChatClear = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-19 10:01:54 -04:00
|
|
|
function botToggleBossCoins() {
|
|
|
|
if(botSpendBossCoins) {
|
|
|
|
console.log('Stopping spending boss coins');
|
|
|
|
botSpendBossCoins = false;
|
|
|
|
} else {
|
2015-04-23 09:56:49 -04:00
|
|
|
console.log('Starting spending boss coins');
|
2015-04-19 10:01:54 -04:00
|
|
|
botSpendBossCoins = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-23 09:56:49 -04:00
|
|
|
function botToggleSaveSpears() {
|
|
|
|
if(botSaveSpears) {
|
|
|
|
console.log('Stopping saving spears');
|
|
|
|
botSaveSpears = false;
|
|
|
|
} else {
|
|
|
|
console.log('Starting saving spears');
|
|
|
|
botSaveSpears = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-14 10:32:51 -04:00
|
|
|
function botHelp() {
|
|
|
|
console.log('bt(): Toggle for the entire bot.');
|
|
|
|
console.log('bs(): Toggle "sleep mode." Disables all actions, but logs raids and chat.');
|
|
|
|
console.log('bts(): Toggle auto-slime purchasing.');
|
2015-04-14 14:43:44 -04:00
|
|
|
console.log('btw(): Toggle auto-worker purchasing (detects most efficient).');
|
2015-04-14 10:32:51 -04:00
|
|
|
console.log('btu(): Toggle the UI (probably only works once).');
|
|
|
|
console.log('btg(): Toggle the global boss.');
|
|
|
|
console.log('btr(): Toggle the random boss.');
|
2015-04-17 13:41:39 -04:00
|
|
|
console.log('btc(): Toggle the chat clear.');
|
2015-04-19 10:01:54 -04:00
|
|
|
console.log('btb(): Toggle boss coins spending.');
|
2015-04-23 09:56:49 -04:00
|
|
|
console.log('bta(): Toggle saving of spears.');
|
2015-04-14 10:32:51 -04:00
|
|
|
console.log('bst("username"): Set a target to raid every 5 minutes.');
|
|
|
|
console.log('bct(): Clear the raid target.');
|
|
|
|
}
|
|
|
|
|
2015-04-14 10:28:12 -04:00
|
|
|
function bt() { botToggle(); }
|
|
|
|
function bs() { botToggleSleep(); }
|
|
|
|
function bts() { botToggleSlimes(); }
|
2015-04-14 14:43:44 -04:00
|
|
|
function btw() { botToggleWorkers(); }
|
2015-04-14 10:28:12 -04:00
|
|
|
function btu() { botToggleUI(); }
|
|
|
|
function btg() { botToggleGlobal(); }
|
|
|
|
function btr() { botToggleRandom(); }
|
2015-04-17 13:41:39 -04:00
|
|
|
function btc() { botToggleChatClear(); }
|
2015-04-19 10:01:54 -04:00
|
|
|
function btb() { botToggleBossCoins(); }
|
2015-04-23 09:56:49 -04:00
|
|
|
function bta() { botToggleSaveSpears(); }
|
2015-04-14 10:28:12 -04:00
|
|
|
function bst(username) { botSetTarget(username); }
|
|
|
|
function bct() { botClearTarget(); }
|