From 5277db2c65ef9ee033d3ca06a1e31e7fd52c3312 Mon Sep 17 00:00:00 2001 From: Rinne <99666293+Semanual@users.noreply.github.com> Date: Wed, 31 Jan 2024 21:40:27 -0300 Subject: [PATCH] API: Changing return value of ns.bladeburner.getSkillUpgradeCost to return Infinity when the skill's level overshoot the maximum level (#1060) --- markdown/bitburner.bladeburner.getskillupgradecost.md | 2 +- src/Bladeburner/Bladeburner.tsx | 7 +++++-- src/ScriptEditor/NetscriptDefinitions.d.ts | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/markdown/bitburner.bladeburner.getskillupgradecost.md b/markdown/bitburner.bladeburner.getskillupgradecost.md index 5980fc28c..6b99e0495 100644 --- a/markdown/bitburner.bladeburner.getskillupgradecost.md +++ b/markdown/bitburner.bladeburner.getskillupgradecost.md @@ -31,5 +31,5 @@ RAM cost: 4 GB This function returns the number of skill points needed to upgrade the specified skill the specified number of times. -The function returns -1 if an invalid skill name is passed in. +The function returns -1 if an invalid skill name is passed in, and Infinity if the count overflows the maximum level. diff --git a/src/Bladeburner/Bladeburner.tsx b/src/Bladeburner/Bladeburner.tsx index bac64e95c..c0c0968f7 100644 --- a/src/Bladeburner/Bladeburner.tsx +++ b/src/Bladeburner/Bladeburner.tsx @@ -2299,10 +2299,13 @@ export class Bladeburner { } const skill = Skills[skillName]; - if (this.skills[skillName] == null) { + const currentLevel = this.skills[skillName]; + if (currentLevel == null) { return skill.calculateCost(0, count); + } else if (currentLevel + count > skill.maxLvl) { + return Infinity; } else { - return skill.calculateCost(this.skills[skillName], count); + return skill.calculateCost(currentLevel, count); } } diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index 76925c36a..3387c9757 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -3257,7 +3257,7 @@ export interface Bladeburner { * * This function returns the number of skill points needed to upgrade the specified skill the specified number of times. * - * The function returns -1 if an invalid skill name is passed in. + * The function returns -1 if an invalid skill name is passed in, and Infinity if the count overflows the maximum level. * * @param skillName - Name of skill. Case-sensitive and must be an exact match. * @param count - Number of times to upgrade the skill. Defaults to 1 if not specified.