mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-23 01:32:55 +02:00
API: Get Sleeve Success at BB tasks through existing commands (#1428)
This commit is contained in:
@@ -16,24 +16,24 @@ import { getAugCost } from "../Augmentation/AugmentationHelpers";
|
||||
import { Factions } from "../Faction/Factions";
|
||||
import { SleeveWorkType } from "../PersonObjects/Sleeve/Work/Work";
|
||||
|
||||
export const checkSleeveAPIAccess = function (ctx: NetscriptContext) {
|
||||
if (Player.bitNodeN !== 10 && !Player.sourceFileLvl(10)) {
|
||||
throw helpers.errorMessage(
|
||||
ctx,
|
||||
"You do not currently have access to the Sleeve API. This is either because you are not in BitNode-10 or because you do not have Source-File 10",
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export const checkSleeveNumber = function (ctx: NetscriptContext, sleeveNumber: number) {
|
||||
if (sleeveNumber >= Player.sleeves.length || sleeveNumber < 0) {
|
||||
const msg = `Invalid sleeve number: ${sleeveNumber}`;
|
||||
helpers.log(ctx, () => msg);
|
||||
throw helpers.errorMessage(ctx, msg);
|
||||
}
|
||||
};
|
||||
|
||||
export function NetscriptSleeve(): InternalAPI<NetscriptSleeve> {
|
||||
const checkSleeveAPIAccess = function (ctx: NetscriptContext) {
|
||||
if (Player.bitNodeN !== 10 && !Player.sourceFileLvl(10)) {
|
||||
throw helpers.errorMessage(
|
||||
ctx,
|
||||
"You do not currently have access to the Sleeve API. This is either because you are not in BitNode-10 or because you do not have Source-File 10",
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const checkSleeveNumber = function (ctx: NetscriptContext, sleeveNumber: number) {
|
||||
if (sleeveNumber >= Player.sleeves.length || sleeveNumber < 0) {
|
||||
const msg = `Invalid sleeve number: ${sleeveNumber}`;
|
||||
helpers.log(ctx, () => msg);
|
||||
throw helpers.errorMessage(ctx, msg);
|
||||
}
|
||||
};
|
||||
|
||||
const sleeveFunctions: InternalAPI<NetscriptSleeve> = {
|
||||
getNumSleeves: (ctx) => () => {
|
||||
checkSleeveAPIAccess(ctx);
|
||||
|
||||
Reference in New Issue
Block a user