mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-17 21:23:54 +01:00
API: Add ns.bladeburner.getNextBlackOp() (#815)
This commit is contained in:
parent
7e94a8653e
commit
1007ce5e68
25
markdown/bitburner.bladeburner.getnextblackop.md
Normal file
25
markdown/bitburner.bladeburner.getnextblackop.md
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||||
|
|
||||||
|
[Home](./index.md) > [bitburner](./bitburner.md) > [Bladeburner](./bitburner.bladeburner.md) > [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. |
|
| [getContractNames()](./bitburner.bladeburner.getcontractnames.md) | List all contracts. |
|
||||||
| [getCurrentAction()](./bitburner.bladeburner.getcurrentaction.md) | Get current action. |
|
| [getCurrentAction()](./bitburner.bladeburner.getcurrentaction.md) | Get current action. |
|
||||||
| [getGeneralActionNames()](./bitburner.bladeburner.getgeneralactionnames.md) | List all general actions. |
|
| [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. |
|
| [getOperationNames()](./bitburner.bladeburner.getoperationnames.md) | List all operations. |
|
||||||
| [getRank()](./bitburner.bladeburner.getrank.md) | Get player bladeburner rank. |
|
| [getRank()](./bitburner.bladeburner.getrank.md) | Get player bladeburner rank. |
|
||||||
| [getSkillLevel(skillName)](./bitburner.bladeburner.getskilllevel.md) | Get skill level. |
|
| [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));
|
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 {
|
canAttemptBlackOp(actionId: ActionIdentifier): BlackOpsAttempt {
|
||||||
// Safety measure - don't repeat BlackOps that are already done
|
// Safety measure - don't repeat BlackOps that are already done
|
||||||
if (this.blackops[actionId.name] != null) {
|
if (this.blackops[actionId.name] != null) {
|
||||||
@ -301,7 +328,6 @@ export class Bladeburner {
|
|||||||
this.storedCycles += numCycles;
|
this.storedCycles += numCycles;
|
||||||
}
|
}
|
||||||
|
|
||||||
// working on
|
|
||||||
getActionIdFromTypeAndName(type = "", name = ""): ActionIdentifier | null {
|
getActionIdFromTypeAndName(type = "", name = ""): ActionIdentifier | null {
|
||||||
if (type === "" || name === "") {
|
if (type === "" || name === "") {
|
||||||
return null;
|
return null;
|
||||||
|
@ -243,6 +243,7 @@ const bladeburner = {
|
|||||||
getContractNames: RamCostConstants.BladeburnerApiBase / 10,
|
getContractNames: RamCostConstants.BladeburnerApiBase / 10,
|
||||||
getOperationNames: RamCostConstants.BladeburnerApiBase / 10,
|
getOperationNames: RamCostConstants.BladeburnerApiBase / 10,
|
||||||
getBlackOpNames: RamCostConstants.BladeburnerApiBase / 10,
|
getBlackOpNames: RamCostConstants.BladeburnerApiBase / 10,
|
||||||
|
getNextBlackOp: RamCostConstants.BladeburnerApiBase / 2,
|
||||||
getBlackOpRank: RamCostConstants.BladeburnerApiBase / 2,
|
getBlackOpRank: RamCostConstants.BladeburnerApiBase / 2,
|
||||||
getGeneralActionNames: RamCostConstants.BladeburnerApiBase / 10,
|
getGeneralActionNames: RamCostConstants.BladeburnerApiBase / 10,
|
||||||
getSkillNames: RamCostConstants.BladeburnerApiBase / 10,
|
getSkillNames: RamCostConstants.BladeburnerApiBase / 10,
|
||||||
|
@ -54,6 +54,10 @@ export function NetscriptBladeburner(): InternalAPI<INetscriptBladeburner> {
|
|||||||
const bladeburner = getBladeburner(ctx);
|
const bladeburner = getBladeburner(ctx);
|
||||||
return bladeburner.getBlackOpNamesNetscriptFn();
|
return bladeburner.getBlackOpNamesNetscriptFn();
|
||||||
},
|
},
|
||||||
|
getNextBlackOp: (ctx) => () => {
|
||||||
|
const bladeburner = getBladeburner(ctx);
|
||||||
|
return bladeburner.getNextBlackOp();
|
||||||
|
},
|
||||||
getBlackOpRank: (ctx) => (_blackOpName) => {
|
getBlackOpRank: (ctx) => (_blackOpName) => {
|
||||||
const blackOpName = helpers.string(ctx, "blackOpName", _blackOpName);
|
const blackOpName = helpers.string(ctx, "blackOpName", _blackOpName);
|
||||||
checkBladeburnerAccess(ctx);
|
checkBladeburnerAccess(ctx);
|
||||||
|
12
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
12
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -2809,6 +2809,18 @@ export interface Bladeburner {
|
|||||||
*/
|
*/
|
||||||
getBlackOpNames(): string[];
|
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.
|
* List all general actions.
|
||||||
* @remarks
|
* @remarks
|
||||||
|
Loading…
Reference in New Issue
Block a user