BLADEBURNER: Add API to calculate max upgrade count of skill (#1475)

This commit is contained in:
catloversg
2024-08-17 03:15:20 +07:00
committed by GitHub
parent 3d15413619
commit 289f60d8c8
17 changed files with 274 additions and 19 deletions
+17
View File
@@ -51,6 +51,7 @@ import { findEnumMember } from "../utils/helpers/enum";
import { getEnumHelper } from "../utils/EnumHelper";
import { CompanyPositions } from "../Company/CompanyPositions";
import { findCrime } from "../Crime/CrimeHelpers";
import { Skills } from "../Bladeburner/data/Skills";
export function NetscriptFormulas(): InternalAPI<IFormulas> {
const checkFormulasAccess = function (ctx: NetscriptContext): void {
@@ -427,6 +428,22 @@ export function NetscriptFormulas(): InternalAPI<IFormulas> {
return calculateCompanyWorkStats(person, company, position, favor);
},
},
bladeburner: {
skillMaxUpgradeCount: (ctx) => (_name, _level, _skillPoints) => {
checkFormulasAccess(ctx);
const name = getEnumHelper("BladeSkillName").nsGetMember(ctx, _name, "name");
const level = helpers.number(ctx, "level", _level);
if (level < 0) {
throw new Error(`Level must be a non-negative number.`);
}
const skillPoints = helpers.positiveNumber(ctx, "skillPoints", _skillPoints);
const skill = Skills[name];
if (level >= skill.maxLvl) {
return 0;
}
return skill.calculateMaxUpgradeCount(level, skillPoints);
},
},
};
// Removed functions