diff --git a/src/Bladeburner.js b/src/Bladeburner.js index e1bfba2c3..151534902 100644 --- a/src/Bladeburner.js +++ b/src/Bladeburner.js @@ -3335,6 +3335,38 @@ Bladeburner.prototype.startActionNetscriptFn = function(type, name, workerScript return false; } + // Special logic for Black Ops + if (actionId.type === ActionTypes["BlackOp"]) { + // Can't start a BlackOp if you don't have the required rank + let action = this.getActionObject(actionId); + if (action.reqdRank > this.rank) { + workerScript.log(`Failed to start Black Op ${actionId.name} due to insufficient rank`); + return false; + } + + // Can't start a BlackOp if you haven't done the one before it + var blackops = []; + for (const nm in BlackOperations) { + if (BlackOperations.hasOwnProperty(nm)) { + blackops.push(nm); + } + } + blackops.sort(function(a, b) { + return (BlackOperations[a].reqdRank - BlackOperations[b].reqdRank); // Sort black ops in intended order + }); + + let i = blackops.indexOf(actionId.name); + if (i === -1) { + workerScript.log("ERROR: Invalid Black Operation name passed into bladeburner.startAction(). Note that this name is case-sensitive & whitespace-sensitive"); + return false; + } + + if (i > 0 && this.blackops[blackops[i-1]] == null) { + workerScript.log(`ERROR: Cannot attempt Black Operation ${actionId.name} because you have not done the preceding one`); + return false; + } + } + try { this.startAction(actionId); if (workerScript.shouldLog("startAction")) { @@ -3436,9 +3468,14 @@ Bladeburner.prototype.getActionCountRemainingNetscriptFn = function(type, name, switch (actionId.type) { case ActionTypes["Contract"]: case ActionTypes["Operation"]: + return actionObj.count; case ActionTypes["BlackOp"]: case ActionTypes["BlackOperation"]: - return actionObj.count; + if (this.blackops[name] != null) { + return 0; + } else { + return 1; + } case ActionTypes["Training"]: case ActionTypes["Field Analysis"]: case ActionTypes["FieldAnalysis"]: diff --git a/src/Constants.js b/src/Constants.js index 152665c96..c031243cd 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -519,6 +519,8 @@ let CONSTANTS = { * Bug Fix: Netscript calls that throw errors will now no longer cause the 'concurrent calls' error if they are caught in the script. i.e. try/catch should now work properly in scripts * Bug Fix: Fixed a bug where sometimes the NeuroFlux Governor Augmentation level would be incorrectly calculated when the game was loaded * Bug Fix: Fixed a bug where calling the scp() Netscript function with invalid hostname/ips would throw an unclear error message + * Bug Fix: Bladeburner API function getActionCountRemaining() should now work properly for BlackOps + * Bug Fix: Black Ops can no longer be attempted out-of-order or without the required rank via Bladeburner API * RAM cost for basic Netscript functions added to documentation (by CBJamo) `