Fix bot raid reporting

This commit is contained in:
Andrew Tomaka 2015-04-09 11:06:34 -04:00
parent 598e3560c9
commit 19c898fe85

30
bot.js
View file

@ -14,7 +14,7 @@ function mainLoop() {
var botPopupTitle = $('#popup p[name="title"]').text(); var botPopupTitle = $('#popup p[name="title"]').text();
switch(botPopupTitle) { switch(botPopupTitle) {
case 'Raid report': case 'Raid report':
var botMessage = botBuildRaidReport($('#popup div[name="content"]')); var botMessage = botBuildRaidReport($('#popup div[name="content"]').text());
console.log(botMessage); console.log(botMessage);
clickButton('CONTINUE'); clickButton('CONTINUE');
break; break;
@ -47,53 +47,61 @@ function mainLoop() {
} }
} }
//then, check to see if we need to do anything
//RANDOM BOSS //RANDOM BOSS
if(randomBossRefreshing() === true && botFightingRandomBoss === true) { if(randomBossRefreshing() === true && botFightingRandomBoss === true && botTickActivity === false) {
botFightingRandomBoss = false; botFightingRandomBoss = false;
} else if(randomBossRefreshing() === false && botFightingRandomBoss === false) { } else if(randomBossRefreshing() === false && botFightingRandomBoss === false) {
clickSelector('#randomBossPortal a'); clickSelector('#randomBossPortal a');
botFightingRandomBoss = true; botFightingRandomBoss = true;
botTickActivity = true;
} }
//GLOBAL BOSS //GLOBAL BOSS
if(globalBossRefreshing() === true && botFightingGlobalBoss === true) { if(globalBossRefreshing() === true && botFightingGlobalBoss === true && botTickActivity === false) {
clearInterval(botGlobalBossTimer); clearInterval(botGlobalBossTimer);
botFightingGlobalBoss = false; botFightingGlobalBoss = false;
} else if(globalBossRefreshing() === false && botFightingGlobalBoss === false) { } else if(globalBossRefreshing() === false && botFightingGlobalBoss === false) {
clickSelector('span[name="timeRemaining"]:contains("JOIN") a'); clickSelector('span[name="timeRemaining"]:contains("JOIN") a');
botGlobalBossTimer = setInterval(fightGlobalBoss, 250); botGlobalBossTimer = setInterval(fightGlobalBoss, 250);
botFightingGlobalBoss = true; botFightingGlobalBoss = true;
botTickActivity = true;
} }
//ACTIVATE BUFFS //ACTIVATE BUFFS
if(inactiveBuffs()) { if(inactiveBuffs() && botTickActivity === false) {
clickSelector('button:contains("Activate")'); clickSelector('button:contains("Activate")');
botTickActivity = true;
} }
//BUY SCIENTISTS //BUY SCIENTISTS
if(haveBossCoins() && haveCheapLabor() && botPurchasing === false) { if(haveBossCoins() && haveCheapLabor() && botTickActivity === false) {
botPurchasing = true; botPurchasing = true;
clickSelector('button[name="hiremax_scientists"]'); clickSelector('button[name="hiremax_scientists"]');
botTickActivity = true;
} }
//BUY SLIMES //BUY SLIMES
if(botBuySlimes === true && botPurchasing === false && haveTrillions(10)) { if(botBuySlimes === true && haveTrillions(10) && botTickActivity === false) {
botPurchasing = true; botPurchasing = true;
clickSelector('button[name="buymax-knight"]'); clickSelector('button[name="buymax-knight"]');
botTickActivity = true;
} }
} }
botToggle(); botToggle();
function botBuildRaidReport(message) { function botBuildRaidReport(message) {
var botRaidUser = /You.? were raided by (.*?).? /.exec(message)[1]; var botRaidUser;
var botRaidSoldiers = /lost (.*?) soldiers/.exec(message)[1]; 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];
var botRaidResult = (/won/.exec(message) !== null) ? 'won' : 'lost'; var botRaidResult = (/won/.exec(message) !== null) ? 'won' : 'lost';
var botRaidStolen = (/steal (.*?) from/.exec(message) !== null) ? /steal (.*?) from/.exec(message)[1] : '$0'; var botRaidStolen = (/steal (.*?) from/.exec(message) !== null) ? /steal (.*?) from/.exec(message)[1] : '$0';
return "RAIDED (" + botRaidUser + "): " + botRaidResult + "; lost: " + botRaidSoldiers + " and " + botRaidStolen; return "RAIDED (" + botRaidUser + "): " + botRaidResult + "; souldiers: -" + botRaidSoldiers + "; " + botRaidResult + " money: " + botRaidStolen;
} }
function haveTrillions(trillions) { function haveTrillions(trillions) {