API: Add ns.bladeburner.getNextBlackOp() (#815)

This commit is contained in:
missymae#2783 2023-10-17 00:18:54 -06:00 committed by GitHub
parent 7e94a8653e
commit 1007ce5e68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 70 additions and 1 deletions

@ -0,0 +1,25 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [Bladeburner](./bitburner.bladeburner.md) &gt; [getNextBlackOp](./bitburner.bladeburner.getnextblackop.md)
## Bladeburner.getNextBlackOp() method
Get an object with the name and rank requirement of the next BlackOp that can be completed.
**Signature:**
```typescript
getNextBlackOp(): { name: string; rank: number } | null;
```
**Returns:**
{ name: string; rank: number } \| null
An object with the `.name` and `.rank` properties of the available BlackOp, or `null`<!-- -->.
## Remarks
RAM cost: 2 GB
Returns the name and rank requirement for the available BlackOp. Returns `null` if no BlackOps remain in the BitNode.

@ -39,6 +39,7 @@ You have to be employed in the Bladeburner division and be in BitNode-7 or have
| [getContractNames()](./bitburner.bladeburner.getcontractnames.md) | List all contracts. |
| [getCurrentAction()](./bitburner.bladeburner.getcurrentaction.md) | Get current action. |
| [getGeneralActionNames()](./bitburner.bladeburner.getgeneralactionnames.md) | List all general actions. |
| [getNextBlackOp()](./bitburner.bladeburner.getnextblackop.md) | Get an object with the name and rank requirement of the next BlackOp that can be completed. |
| [getOperationNames()](./bitburner.bladeburner.getoperationnames.md) | List all operations. |
| [getRank()](./bitburner.bladeburner.getrank.md) | Get player bladeburner rank. |
| [getSkillLevel(skillName)](./bitburner.bladeburner.getskilllevel.md) | Get skill level. |

@ -116,6 +116,33 @@ export class Bladeburner {
return Math.min(1, this.stamina / (0.5 * this.maxStamina));
}
// Todo, deduplicate this functionality
getNextBlackOp(): { name: string; rank: number } | null {
let blackops: BlackOperation[] = [];
for (const blackopName of Object.keys(BlackOperations)) {
if (Object.hasOwn(BlackOperations, blackopName)) {
blackops.push(BlackOperations[blackopName]);
}
}
blackops.sort(function (a, b) {
return a.reqdRank - b.reqdRank;
});
blackops = blackops.filter(
(blackop: BlackOperation, i: number) =>
!(this.blackops[blackops[i].name] == null && i !== 0 && this.blackops[blackops[i - 1].name] == null),
);
blackops = blackops.reverse();
const actionID = this.getActionIdFromTypeAndName("Black Op", "Operation Daedalus");
return blackops[0].name === "Operation Daedalus" &&
actionID !== null &&
!this.canAttemptBlackOp(actionID).isAvailable
? null
: { name: blackops[0].name, rank: blackops[0].reqdRank };
}
canAttemptBlackOp(actionId: ActionIdentifier): BlackOpsAttempt {
// Safety measure - don't repeat BlackOps that are already done
if (this.blackops[actionId.name] != null) {
@ -301,7 +328,6 @@ export class Bladeburner {
this.storedCycles += numCycles;
}
// working on
getActionIdFromTypeAndName(type = "", name = ""): ActionIdentifier | null {
if (type === "" || name === "") {
return null;

@ -243,6 +243,7 @@ const bladeburner = {
getContractNames: RamCostConstants.BladeburnerApiBase / 10,
getOperationNames: RamCostConstants.BladeburnerApiBase / 10,
getBlackOpNames: RamCostConstants.BladeburnerApiBase / 10,
getNextBlackOp: RamCostConstants.BladeburnerApiBase / 2,
getBlackOpRank: RamCostConstants.BladeburnerApiBase / 2,
getGeneralActionNames: RamCostConstants.BladeburnerApiBase / 10,
getSkillNames: RamCostConstants.BladeburnerApiBase / 10,

@ -54,6 +54,10 @@ export function NetscriptBladeburner(): InternalAPI<INetscriptBladeburner> {
const bladeburner = getBladeburner(ctx);
return bladeburner.getBlackOpNamesNetscriptFn();
},
getNextBlackOp: (ctx) => () => {
const bladeburner = getBladeburner(ctx);
return bladeburner.getNextBlackOp();
},
getBlackOpRank: (ctx) => (_blackOpName) => {
const blackOpName = helpers.string(ctx, "blackOpName", _blackOpName);
checkBladeburnerAccess(ctx);

@ -2809,6 +2809,18 @@ export interface Bladeburner {
*/
getBlackOpNames(): string[];
/**
* Get an object with the name and rank requirement of the next BlackOp that can be completed.
* @remarks
* RAM cost: 2 GB
*
* Returns the name and rank requirement for the available BlackOp.
* Returns `null` if no BlackOps remain in the BitNode.
*
* @returns An object with the `.name` and `.rank` properties of the available BlackOp, or `null`.
*/
getNextBlackOp(): { name: string; rank: number } | null;
/**
* List all general actions.
* @remarks