API: Get Sleeve Success at BB tasks through existing commands (#1428)

This commit is contained in:
Sphyxis
2024-06-28 20:49:52 -06:00
committed by GitHub
parent 9c9a69f2e2
commit 61ec7dde80
5 changed files with 35 additions and 23 deletions
+13 -3
View File
@@ -11,6 +11,7 @@ import { getEnumHelper } from "../utils/EnumHelper";
import { Skills } from "../Bladeburner/data/Skills";
import { assertString } from "../Netscript/TypeAssertion";
import { BlackOperations, blackOpsArray } from "../Bladeburner/data/BlackOperations";
import { checkSleeveAPIAccess, checkSleeveNumber } from "../NetscriptFunctions/Sleeve";
export function NetscriptBladeburner(): InternalAPI<INetscriptBladeburner> {
const checkBladeburnerAccess = function (ctx: NetscriptContext): void {
@@ -27,7 +28,6 @@ export function NetscriptBladeburner(): InternalAPI<INetscriptBladeburner> {
throw helpers.errorMessage(ctx, "You must be a member of the Bladeburner division to use this API.");
return bladeburner;
};
function getAction(ctx: NetscriptContext, type: unknown, name: unknown): Action {
const bladeburner = Player.bladeburner;
assertString(ctx, "type", type);
@@ -117,10 +117,20 @@ export function NetscriptBladeburner(): InternalAPI<INetscriptBladeburner> {
1000
);
},
getActionEstimatedSuccessChance: (ctx) => (type, name) => {
getActionEstimatedSuccessChance: (ctx) => (type, name, _sleeve) => {
const bladeburner = getBladeburner(ctx);
const action = getAction(ctx, type, name);
return action.getSuccessRange(bladeburner, Player);
if (_sleeve != null) {
checkSleeveAPIAccess(ctx);
const sleeveNumber = helpers.number(ctx, "sleeve", _sleeve);
checkSleeveNumber(ctx, sleeveNumber);
if (action.type === BladeActionType.contract) {
const sleevePerson = Player.sleeves[sleeveNumber];
return action.getSuccessRange(bladeburner, sleevePerson);
} else return [0, 0];
} else {
return action.getSuccessRange(bladeburner, Player);
}
},
getActionRepGain: (ctx) => (type, name, _level) => {
checkBladeburnerAccess(ctx);