mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-10 09:43:54 +01:00
Merge pull request #954 from Daniferrito/bladeburner-fixes
Bladeburner fixes
This commit is contained in:
commit
2f3e5c79e7
@ -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"];
|
||||||
@ -381,22 +382,16 @@ Bladeburner.prototype.process = function() {
|
|||||||
this.stamina = Math.min(this.maxStamina, this.stamina);
|
this.stamina = Math.min(this.maxStamina, this.stamina);
|
||||||
|
|
||||||
// Count increase for contracts/operations
|
// Count increase for contracts/operations
|
||||||
for (var contractName in this.contracts) {
|
for (let contract of Object.values(this.contracts)) {
|
||||||
if (this.contracts.hasOwnProperty(contractName)) {
|
contract.count += (seconds * contract.countGrowth/BladeburnerConstants.ActionCountGrowthPeriod);
|
||||||
var contract = this.contracts[contractName];
|
|
||||||
contract.count += (seconds * contract.countGrowth/BladeburnerConstants.ActionCountGrowthPeriod);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (var operationName in this.operations) {
|
for (let op of Object.values(this.operations)) {
|
||||||
if (this.operations.hasOwnProperty(operationName)) {
|
op.count += (seconds * op.countGrowth/BladeburnerConstants.ActionCountGrowthPeriod);
|
||||||
var op = this.operations[operationName];
|
|
||||||
op.count += (seconds * op.countGrowth/BladeburnerConstants.ActionCountGrowthPeriod);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Chaos goes down very slowly
|
// Chaos goes down very slowly
|
||||||
for (var i = 0; i < BladeburnerConstants.CityNames.length; ++i) {
|
for (let cityName of BladeburnerConstants.CityNames) {
|
||||||
var city = this.cities[BladeburnerConstants.CityNames[i]];
|
var city = this.cities[cityName];
|
||||||
if (!(city instanceof City)) {throw new Error("Invalid City object when processing passive chaos reduction in Bladeburner.process");}
|
if (!(city instanceof City)) {throw new Error("Invalid City object when processing passive chaos reduction in Bladeburner.process");}
|
||||||
city.chaos -= (0.0001 * seconds);
|
city.chaos -= (0.0001 * seconds);
|
||||||
city.chaos = Math.max(0, city.chaos);
|
city.chaos = Math.max(0, city.chaos);
|
||||||
@ -406,7 +401,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 +660,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 +1889,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 +1932,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 +2032,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}),
|
||||||
@ -2093,6 +2097,7 @@ Bladeburner.prototype.updateOperationsUIElement = function(el, action) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
createPopup(popupId, [txt, input, setBtn, cancelBtn]);
|
createPopup(popupId, [txt, input, setBtn, cancelBtn]);
|
||||||
|
input.focus();
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@ -2171,6 +2176,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 +2188,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}),
|
||||||
@ -2243,6 +2249,7 @@ Bladeburner.prototype.updateBlackOpsUIElement = function(el, action) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
createPopup(popupId, [txt, input, setBtn, cancelBtn]);
|
createPopup(popupId, [txt, input, setBtn, cancelBtn]);
|
||||||
|
input.focus();
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user