BLADEBURNER: Add APIs to get rank gain and rank loss of an action (#2572)

This commit is contained in:
catloversg
2026-03-14 09:34:13 +07:00
committed by GitHub
parent bc3e8ff3d5
commit 50442472b5
10 changed files with 289 additions and 12 deletions
+17 -1
View File
@@ -19,7 +19,11 @@ import { assertStringWithNSContext } from "../Netscript/TypeAssertion";
import { BlackOperations, blackOpsArray } from "../Bladeburner/data/BlackOperations";
import { checkSleeveAPIAccess, checkSleeveNumber } from "../NetscriptFunctions/Sleeve";
import { canAccessBitNodeFeature } from "../BitNode/BitNodeUtils";
import { calculateActionRankGain, calculateActionReputationGain } from "../Bladeburner/Formulas";
import {
calculateActionRankGain,
calculateActionRankLoss,
calculateActionReputationGain,
} from "../Bladeburner/Formulas";
import { CONSTANTS } from "../Constants";
export function NetscriptBladeburner(): InternalAPI<INetscriptBladeburner> {
@@ -156,6 +160,18 @@ export function NetscriptBladeburner(): InternalAPI<INetscriptBladeburner> {
const rankGain = calculateActionRankGain(action, level);
return calculateActionReputationGain(Player, rankGain);
},
getActionRankGain: (ctx) => (type, name, _level) => {
checkBladeburnerAccess(ctx);
const action = getAction(ctx, type, name);
const level = isLevelableAction(action) ? helpers.number(ctx, "level", _level ?? action.level) : 1;
return calculateActionRankGain(action, level);
},
getActionRankLoss: (ctx) => (type, name, _level) => {
checkBladeburnerAccess(ctx);
const action = getAction(ctx, type, name);
const level = isLevelableAction(action) ? helpers.number(ctx, "level", _level ?? action.level) : 1;
return calculateActionRankLoss(action, level);
},
getActionCountRemaining: (ctx) => (type, name) => {
const bladeburner = getBladeburner(ctx);
const action = getAction(ctx, type, name);