Skip to content

Commit

Permalink
Fix ESLint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jmichelsen committed Jan 23, 2020
1 parent 1eaf0fa commit 9ae6bba
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions d2bs/kolbot/libs/bots/BattleOrders.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,29 @@
* @return {boolean}
*/

function BattleOrders() {
this.checkForPlayers = function() {
function BattleOrders () {
this.checkForPlayers = function () {
if (Misc.getPlayerCount() <= 1) {
throw new Error("Empty game"); // Alone in game
}
};

this.amTardy = function() {
this.amTardy = function () {
let party = getParty();

AreaInfoLoop:
while (true) {
try {
this.checkForPlayers();
} catch(e) {
} catch (e) {
if (Config.BattleOrders.Wait) {
print("Waiting " +Config.BattleOrders.Wait+ " seconds for other players...");
print("Waiting " + Config.BattleOrders.Wait + " seconds for other players...");

while (getTickCount() - tick < Config.BattleOrders.Wait * 1000) {
me.overhead("Waiting " + Math.round(((tick + (Config.BattleOrders.Wait * 1000)) - getTickCount()) / 1000) + " Seconds for other players");
delay(1000);
}

this.checkForPlayers();
}
}
Expand All @@ -44,14 +46,16 @@ function BattleOrders() {
if (party.area === 131 || party.area === 132 || party.area === 108 || party.area === 39) {
// Player is in Throne of Destruction, Worldstone Chamber, Chaos Sanctuary, or Cows
print("ÿc1I'm late to BOs. Moving on...");

return true;
}
} while (party.getNext());
}

return false; // Not late; wait.
};

this.giveBO = function(list) {
this.giveBO = function (list) {
let i,
unit,
failTimer = 60,
Expand All @@ -65,6 +69,7 @@ function BattleOrders() {
if (getTickCount() - tick >= failTimer * 1000) {
showConsole();
print("ÿc1BO timeout fail.");

if (Config.BattleOrders.QuitOnFailure) {
quit();
}
Expand All @@ -88,9 +93,11 @@ function BattleOrders() {
} catch (wperror) {
showConsole();
print("ÿc1Failed to take waypoint.");

if (Config.BattleOrders.QuitOnFailure) {
quit();
}

return false;
}

Expand All @@ -105,16 +112,19 @@ function BattleOrders() {
if (Config.BattleOrders.SkipIfTardy && this.amTardy()) {
break;
}

switch (Config.BattleOrders.Mode) {
case 0: // Give BO
for (i = 0; i < Config.BattleOrders.Getters.length; i += 1) {
while (!Misc.inMyParty(Config.BattleOrders.Getters[i]) || !getUnit(0, Config.BattleOrders.Getters[i])) {
if (getTickCount() - tick >= failTimer * 1000) {
showConsole();
print("ÿc1BO timeout fail.");

if (Config.BattleOrders.QuitOnFailure) {
quit();
}

break MainLoop;
}

Expand All @@ -137,9 +147,11 @@ function BattleOrders() {
if (getTickCount() - tick >= failTimer * 1000) {
showConsole();
print("ÿc1BO timeout fail.");

if (Config.BattleOrders.QuitOnFailure) {
quit();
}

break MainLoop;
}

Expand All @@ -160,4 +172,4 @@ function BattleOrders() {
}

return true;
}
}

0 comments on commit 9ae6bba

Please sign in to comment.