diff --git a/src/Bladeburner.jsx b/src/Bladeburner.jsx index 6893feaeb..824259577 100644 --- a/src/Bladeburner.jsx +++ b/src/Bladeburner.jsx @@ -158,6 +158,7 @@ function Bladeburner(params={}) { // These times are in seconds this.actionTimeToComplete = 0; // 0 or -1 is an infinite running action (like training) this.actionTimeCurrent = 0; + this.actionTimeOverflow = 0; // ActionIdentifier Object var idleActionType = ActionTypes["Idle"]; @@ -406,7 +407,8 @@ Bladeburner.prototype.process = function() { this.randomEventCounter -= seconds; if (this.randomEventCounter <= 0) { this.randomEvent(); - this.randomEventCounter = getRandomInt(240, 600); + // Add instead of setting because we might have gone over the required time for the event + this.randomEventCounter += getRandomInt(240, 600); } this.processAction(seconds); @@ -664,8 +666,12 @@ Bladeburner.prototype.processAction = function(seconds) { throw new Error("Bladeburner.action is not an ActionIdentifier Object"); } - this.actionTimeCurrent += seconds; + // If the previous action went past its completion time, add to the next action + // This is not added inmediatly in case the automation changes the action + this.actionTimeCurrent += seconds + this.actionTimeOverflow; + this.actionTimeOverflow = 0; if (this.actionTimeCurrent >= this.actionTimeToComplete) { + this.actionTimeOverflow = this.actionTimeCurrent - this.actionTimeToComplete; return this.completeAction(); } } @@ -1889,17 +1895,18 @@ Bladeburner.prototype.updateActionAndSkillsContent = function() { Bladeburner.prototype.updateGeneralActionsUIElement = function(el, action) { removeChildrenFromElement(el); var isActive = el.classList.contains(ActiveActionCssClass); + var computedActionTimeCurrent = Math.min(this.actionTimeCurrent+this.actionTimeOverflow,this.actionTimeToComplete); el.appendChild(createElement("h2", { // Header innerText:isActive ? action.name + " (IN PROGRESS - " + - formatNumber(this.actionTimeCurrent, 0) + " / " + + formatNumber(computedActionTimeCurrent, 0) + " / " + formatNumber(this.actionTimeToComplete, 0) + ")" : action.name, display:"inline-block", })); if (isActive) { // Progress bar if its active - var progress = this.actionTimeCurrent / this.actionTimeToComplete; + var progress = computedActionTimeCurrent / this.actionTimeToComplete; el.appendChild(createElement("p", { display:"block", innerText:createProgressBarText({progress:progress}), @@ -1931,17 +1938,18 @@ Bladeburner.prototype.updateContractsUIElement = function(el, action) { removeChildrenFromElement(el); var isActive = el.classList.contains(ActiveActionCssClass); var estimatedSuccessChance = action.getSuccessChance(this, {est:true}); + var computedActionTimeCurrent = Math.min(this.actionTimeCurrent+this.actionTimeOverflow,this.actionTimeToComplete); el.appendChild(createElement("h2", { // Header innerText:isActive ? action.name + " (IN PROGRESS - " + - formatNumber(this.actionTimeCurrent, 0) + " / " + + formatNumber(computedActionTimeCurrent, 0) + " / " + formatNumber(this.actionTimeToComplete, 0) + ")" : action.name, display:"inline-block", })); if (isActive) { // Progress bar if its active - var progress = this.actionTimeCurrent / this.actionTimeToComplete; + var progress = computedActionTimeCurrent / this.actionTimeToComplete; el.appendChild(createElement("p", { display:"block", innerText:createProgressBarText({progress:progress}), @@ -2030,16 +2038,18 @@ Bladeburner.prototype.updateOperationsUIElement = function(el, action) { removeChildrenFromElement(el); var isActive = el.classList.contains(ActiveActionCssClass); var estimatedSuccessChance = action.getSuccessChance(this, {est:true}); + var computedActionTimeCurrent = Math.min(this.actionTimeCurrent+this.actionTimeOverflow,this.actionTimeToComplete); + el.appendChild(createElement("h2", { // Header innerText:isActive ? action.name + " (IN PROGRESS - " + - formatNumber(this.actionTimeCurrent, 0) + " / " + + formatNumber(computedActionTimeCurrent, 0) + " / " + formatNumber(this.actionTimeToComplete, 0) + ")" : action.name, display:"inline-block", })); if (isActive) { // Progress bar if its active - var progress = this.actionTimeCurrent / this.actionTimeToComplete; + var progress = computedActionTimeCurrent / this.actionTimeToComplete; el.appendChild(createElement("p", { display:"block", innerText:createProgressBarText({progress:progress}), @@ -2171,6 +2181,7 @@ Bladeburner.prototype.updateBlackOpsUIElement = function(el, action) { var estimatedSuccessChance = action.getSuccessChance(this, {est:true}); var actionTime = action.getActionTime(this); var hasReqdRank = this.rank >= action.reqdRank; + var computedActionTimeCurrent = Math.min(this.actionTimeCurrent+this.actionTimeOverflow,this.actionTimeToComplete); // UI for Completed Black Op if (isCompleted) { @@ -2182,14 +2193,14 @@ Bladeburner.prototype.updateBlackOpsUIElement = function(el, action) { el.appendChild(createElement("h2", { // Header innerText:isActive ? action.name + " (IN PROGRESS - " + - formatNumber(this.actionTimeCurrent, 0) + " / " + + formatNumber(computedActionTimeCurrent, 0) + " / " + formatNumber(this.actionTimeToComplete, 0) + ")" : action.name, display:"inline-block", })); if (isActive) { // Progress bar if its active - var progress = this.actionTimeCurrent / this.actionTimeToComplete; + var progress = computedActionTimeCurrent / this.actionTimeToComplete; el.appendChild(createElement("p", { display:"block", innerText:createProgressBarText({progress:progress}),