Worker purchasing based on efficiency
This commit is contained in:
parent
39d58f3c23
commit
172c1d615a
1 changed files with 46 additions and 1 deletions
47
bot.js
47
bot.js
|
@ -7,6 +7,7 @@ var botRaiding = false;
|
||||||
var botFightingRandomBoss = false;
|
var botFightingRandomBoss = false;
|
||||||
var botFightingGlobalBoss = false;
|
var botFightingGlobalBoss = false;
|
||||||
var botBuySlimes = false;
|
var botBuySlimes = false;
|
||||||
|
var botBuyWorkers = false;
|
||||||
var botFightGlobal = true;
|
var botFightGlobal = true;
|
||||||
var botFightRandom = true;
|
var botFightRandom = true;
|
||||||
var botRaidTarget = null;
|
var botRaidTarget = null;
|
||||||
|
@ -50,6 +51,12 @@ function mainLoop() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'CONFIRM':
|
||||||
|
if(botPurchasing) {
|
||||||
|
clickButton('Yes');
|
||||||
|
botPurchasing = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'WHOOPS!':
|
case 'WHOOPS!':
|
||||||
case 'BATTLE REPORT':
|
case 'BATTLE REPORT':
|
||||||
case 'Battle Report':
|
case 'Battle Report':
|
||||||
|
@ -94,7 +101,7 @@ function mainLoop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
//BUY SCIENTISTS
|
//BUY SCIENTISTS
|
||||||
if(haveBossCoins() && haveCheapLabor()) {
|
if(haveBossCoins() && haveCheapLabor() && botPurchasing === false) {
|
||||||
botPurchasing = true;
|
botPurchasing = true;
|
||||||
clickSelector('button[name="hiremax_scientists"]');
|
clickSelector('button[name="hiremax_scientists"]');
|
||||||
}
|
}
|
||||||
|
@ -111,11 +118,37 @@ function mainLoop() {
|
||||||
botPurchasing = true;
|
botPurchasing = true;
|
||||||
clickSelector('button[name="buymax-knight"]');
|
clickSelector('button[name="buymax-knight"]');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//BUY WORKERS
|
||||||
|
if(botBuyWorkers === true && haveTrillions(10) && haveCheapLabor() === true && botPurchasing === false) {
|
||||||
|
botPurchasing = true;
|
||||||
|
clickSelector('button[name="buymax-' + mostEfficientWorker() + '"]');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
botToggle();
|
botToggle();
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
if(bestValueWorker == null || bestValue < value) {
|
||||||
|
bestValueWorker = workersTable.attr('name');
|
||||||
|
bestValue = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return bestValueWorker;
|
||||||
|
}
|
||||||
|
|
||||||
function internalRaidRefreshing() {
|
function internalRaidRefreshing() {
|
||||||
if(botTimestamp() > botLastRaid + 300) {
|
if(botTimestamp() > botLastRaid + 300) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -294,6 +327,16 @@ function botToggleSlimes() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function botToggleWorkers() {
|
||||||
|
if(botBuyWorkers) {
|
||||||
|
console.log('Stopping worker purchases');
|
||||||
|
botBuyWorkers = false;
|
||||||
|
} else {
|
||||||
|
console.log('Starting worker purchases');
|
||||||
|
botBuyWorkers = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function botToggleGlobal() {
|
function botToggleGlobal() {
|
||||||
if(botFightGlobal) {
|
if(botFightGlobal) {
|
||||||
console.log('Stopping global fighting');
|
console.log('Stopping global fighting');
|
||||||
|
@ -339,6 +382,7 @@ function botHelp() {
|
||||||
console.log('bt(): Toggle for the entire bot.');
|
console.log('bt(): Toggle for the entire bot.');
|
||||||
console.log('bs(): Toggle "sleep mode." Disables all actions, but logs raids and chat.');
|
console.log('bs(): Toggle "sleep mode." Disables all actions, but logs raids and chat.');
|
||||||
console.log('bts(): Toggle auto-slime purchasing.');
|
console.log('bts(): Toggle auto-slime purchasing.');
|
||||||
|
console.log('btw(): Toggle auto-worker purchasing (detects most efficient).');
|
||||||
console.log('btu(): Toggle the UI (probably only works once).');
|
console.log('btu(): Toggle the UI (probably only works once).');
|
||||||
console.log('btg(): Toggle the global boss.');
|
console.log('btg(): Toggle the global boss.');
|
||||||
console.log('btr(): Toggle the random boss.');
|
console.log('btr(): Toggle the random boss.');
|
||||||
|
@ -349,6 +393,7 @@ function botHelp() {
|
||||||
function bt() { botToggle(); }
|
function bt() { botToggle(); }
|
||||||
function bs() { botToggleSleep(); }
|
function bs() { botToggleSleep(); }
|
||||||
function bts() { botToggleSlimes(); }
|
function bts() { botToggleSlimes(); }
|
||||||
|
function btw() { botToggleWorkers(); }
|
||||||
function btu() { botToggleUI(); }
|
function btu() { botToggleUI(); }
|
||||||
function btg() { botToggleGlobal(); }
|
function btg() { botToggleGlobal(); }
|
||||||
function btr() { botToggleRandom(); }
|
function btr() { botToggleRandom(); }
|
||||||
|
|
Loading…
Reference in a new issue