mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-23 08:03:48 +01:00
Add overflow time of bladeburner updates to the next update
This commit is contained in:
parent
5af10c8406
commit
c95a926154
@ -158,6 +158,7 @@ function Bladeburner(params={}) {
|
|||||||
// These times are in seconds
|
// These times are in seconds
|
||||||
this.actionTimeToComplete = 0; // 0 or -1 is an infinite running action (like training)
|
this.actionTimeToComplete = 0; // 0 or -1 is an infinite running action (like training)
|
||||||
this.actionTimeCurrent = 0;
|
this.actionTimeCurrent = 0;
|
||||||
|
this.actionTimeOverflow = 0;
|
||||||
|
|
||||||
// ActionIdentifier Object
|
// ActionIdentifier Object
|
||||||
var idleActionType = ActionTypes["Idle"];
|
var idleActionType = ActionTypes["Idle"];
|
||||||
@ -406,7 +407,8 @@ Bladeburner.prototype.process = function() {
|
|||||||
this.randomEventCounter -= seconds;
|
this.randomEventCounter -= seconds;
|
||||||
if (this.randomEventCounter <= 0) {
|
if (this.randomEventCounter <= 0) {
|
||||||
this.randomEvent();
|
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);
|
this.processAction(seconds);
|
||||||
@ -664,8 +666,12 @@ Bladeburner.prototype.processAction = function(seconds) {
|
|||||||
throw new Error("Bladeburner.action is not an ActionIdentifier Object");
|
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) {
|
if (this.actionTimeCurrent >= this.actionTimeToComplete) {
|
||||||
|
this.actionTimeOverflow = this.actionTimeCurrent - this.actionTimeToComplete;
|
||||||
return this.completeAction();
|
return this.completeAction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1889,17 +1895,18 @@ Bladeburner.prototype.updateActionAndSkillsContent = function() {
|
|||||||
Bladeburner.prototype.updateGeneralActionsUIElement = function(el, action) {
|
Bladeburner.prototype.updateGeneralActionsUIElement = function(el, action) {
|
||||||
removeChildrenFromElement(el);
|
removeChildrenFromElement(el);
|
||||||
var isActive = el.classList.contains(ActiveActionCssClass);
|
var isActive = el.classList.contains(ActiveActionCssClass);
|
||||||
|
var computedActionTimeCurrent = Math.min(this.actionTimeCurrent+this.actionTimeOverflow,this.actionTimeToComplete);
|
||||||
|
|
||||||
el.appendChild(createElement("h2", { // Header
|
el.appendChild(createElement("h2", { // Header
|
||||||
innerText:isActive ? action.name + " (IN PROGRESS - " +
|
innerText:isActive ? action.name + " (IN PROGRESS - " +
|
||||||
formatNumber(this.actionTimeCurrent, 0) + " / " +
|
formatNumber(computedActionTimeCurrent, 0) + " / " +
|
||||||
formatNumber(this.actionTimeToComplete, 0) + ")"
|
formatNumber(this.actionTimeToComplete, 0) + ")"
|
||||||
: action.name,
|
: action.name,
|
||||||
display:"inline-block",
|
display:"inline-block",
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (isActive) { // Progress bar if its active
|
if (isActive) { // Progress bar if its active
|
||||||
var progress = this.actionTimeCurrent / this.actionTimeToComplete;
|
var progress = computedActionTimeCurrent / this.actionTimeToComplete;
|
||||||
el.appendChild(createElement("p", {
|
el.appendChild(createElement("p", {
|
||||||
display:"block",
|
display:"block",
|
||||||
innerText:createProgressBarText({progress:progress}),
|
innerText:createProgressBarText({progress:progress}),
|
||||||
@ -1931,17 +1938,18 @@ Bladeburner.prototype.updateContractsUIElement = function(el, action) {
|
|||||||
removeChildrenFromElement(el);
|
removeChildrenFromElement(el);
|
||||||
var isActive = el.classList.contains(ActiveActionCssClass);
|
var isActive = el.classList.contains(ActiveActionCssClass);
|
||||||
var estimatedSuccessChance = action.getSuccessChance(this, {est:true});
|
var estimatedSuccessChance = action.getSuccessChance(this, {est:true});
|
||||||
|
var computedActionTimeCurrent = Math.min(this.actionTimeCurrent+this.actionTimeOverflow,this.actionTimeToComplete);
|
||||||
|
|
||||||
el.appendChild(createElement("h2", { // Header
|
el.appendChild(createElement("h2", { // Header
|
||||||
innerText:isActive ? action.name + " (IN PROGRESS - " +
|
innerText:isActive ? action.name + " (IN PROGRESS - " +
|
||||||
formatNumber(this.actionTimeCurrent, 0) + " / " +
|
formatNumber(computedActionTimeCurrent, 0) + " / " +
|
||||||
formatNumber(this.actionTimeToComplete, 0) + ")"
|
formatNumber(this.actionTimeToComplete, 0) + ")"
|
||||||
: action.name,
|
: action.name,
|
||||||
display:"inline-block",
|
display:"inline-block",
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (isActive) { // Progress bar if its active
|
if (isActive) { // Progress bar if its active
|
||||||
var progress = this.actionTimeCurrent / this.actionTimeToComplete;
|
var progress = computedActionTimeCurrent / this.actionTimeToComplete;
|
||||||
el.appendChild(createElement("p", {
|
el.appendChild(createElement("p", {
|
||||||
display:"block",
|
display:"block",
|
||||||
innerText:createProgressBarText({progress:progress}),
|
innerText:createProgressBarText({progress:progress}),
|
||||||
@ -2030,16 +2038,18 @@ Bladeburner.prototype.updateOperationsUIElement = function(el, action) {
|
|||||||
removeChildrenFromElement(el);
|
removeChildrenFromElement(el);
|
||||||
var isActive = el.classList.contains(ActiveActionCssClass);
|
var isActive = el.classList.contains(ActiveActionCssClass);
|
||||||
var estimatedSuccessChance = action.getSuccessChance(this, {est:true});
|
var estimatedSuccessChance = action.getSuccessChance(this, {est:true});
|
||||||
|
var computedActionTimeCurrent = Math.min(this.actionTimeCurrent+this.actionTimeOverflow,this.actionTimeToComplete);
|
||||||
|
|
||||||
el.appendChild(createElement("h2", { // Header
|
el.appendChild(createElement("h2", { // Header
|
||||||
innerText:isActive ? action.name + " (IN PROGRESS - " +
|
innerText:isActive ? action.name + " (IN PROGRESS - " +
|
||||||
formatNumber(this.actionTimeCurrent, 0) + " / " +
|
formatNumber(computedActionTimeCurrent, 0) + " / " +
|
||||||
formatNumber(this.actionTimeToComplete, 0) + ")"
|
formatNumber(this.actionTimeToComplete, 0) + ")"
|
||||||
: action.name,
|
: action.name,
|
||||||
display:"inline-block",
|
display:"inline-block",
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (isActive) { // Progress bar if its active
|
if (isActive) { // Progress bar if its active
|
||||||
var progress = this.actionTimeCurrent / this.actionTimeToComplete;
|
var progress = computedActionTimeCurrent / this.actionTimeToComplete;
|
||||||
el.appendChild(createElement("p", {
|
el.appendChild(createElement("p", {
|
||||||
display:"block",
|
display:"block",
|
||||||
innerText:createProgressBarText({progress:progress}),
|
innerText:createProgressBarText({progress:progress}),
|
||||||
@ -2171,6 +2181,7 @@ Bladeburner.prototype.updateBlackOpsUIElement = function(el, action) {
|
|||||||
var estimatedSuccessChance = action.getSuccessChance(this, {est:true});
|
var estimatedSuccessChance = action.getSuccessChance(this, {est:true});
|
||||||
var actionTime = action.getActionTime(this);
|
var actionTime = action.getActionTime(this);
|
||||||
var hasReqdRank = this.rank >= action.reqdRank;
|
var hasReqdRank = this.rank >= action.reqdRank;
|
||||||
|
var computedActionTimeCurrent = Math.min(this.actionTimeCurrent+this.actionTimeOverflow,this.actionTimeToComplete);
|
||||||
|
|
||||||
// UI for Completed Black Op
|
// UI for Completed Black Op
|
||||||
if (isCompleted) {
|
if (isCompleted) {
|
||||||
@ -2182,14 +2193,14 @@ Bladeburner.prototype.updateBlackOpsUIElement = function(el, action) {
|
|||||||
|
|
||||||
el.appendChild(createElement("h2", { // Header
|
el.appendChild(createElement("h2", { // Header
|
||||||
innerText:isActive ? action.name + " (IN PROGRESS - " +
|
innerText:isActive ? action.name + " (IN PROGRESS - " +
|
||||||
formatNumber(this.actionTimeCurrent, 0) + " / " +
|
formatNumber(computedActionTimeCurrent, 0) + " / " +
|
||||||
formatNumber(this.actionTimeToComplete, 0) + ")"
|
formatNumber(this.actionTimeToComplete, 0) + ")"
|
||||||
: action.name,
|
: action.name,
|
||||||
display:"inline-block",
|
display:"inline-block",
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (isActive) { // Progress bar if its active
|
if (isActive) { // Progress bar if its active
|
||||||
var progress = this.actionTimeCurrent / this.actionTimeToComplete;
|
var progress = computedActionTimeCurrent / this.actionTimeToComplete;
|
||||||
el.appendChild(createElement("p", {
|
el.appendChild(createElement("p", {
|
||||||
display:"block",
|
display:"block",
|
||||||
innerText:createProgressBarText({progress:progress}),
|
innerText:createProgressBarText({progress:progress}),
|
||||||
|
Loading…
Reference in New Issue
Block a user