diff --git a/src/Bladeburner/Skill.ts b/src/Bladeburner/Skill.ts index 6f0e92347..56398ab96 100644 --- a/src/Bladeburner/Skill.ts +++ b/src/Bladeburner/Skill.ts @@ -134,12 +134,24 @@ export class Skill { } calculateCost(currentLevel: number, count = 1): number { - //unFloored is roughly equivalent to - //(this.baseCost + currentLevel * this.costInc) * BitNodeMultipliers.BladeburnerSkillCost - //being repeated for increasing currentLevel - const preMult = (count + 1) * (2 * this.baseCost + this.costInc * (2 * currentLevel + count)) / 2; - const unFloored = (preMult * BitNodeMultipliers.BladeburnerSkillCost) - count / 2; - return Math.floor(unFloored); + if (count == 1) { + return Math.floor((this.baseCost + currentLevel * this.costInc) * BitNodeMultipliers.BladeburnerSkillCost); + } + else if (count < 0 || isNaN(count)) { + throw new Error(`Attempted to find cost of ${count} BB upgrades`); + } + else if (count < 100) { + const thisUpgrade = Math.floor((this.baseCost + currentLevel * this.costInc) * BitNodeMultipliers.BladeburnerSkillCost); + return this.calculateCost(currentLevel + 1, count - 1) + thisUpgrade; + } + else { + //unFloored is roughly equivalent to + //(this.baseCost + currentLevel * this.costInc) * BitNodeMultipliers.BladeburnerSkillCost + //being repeated for increasing currentLevel + const preMult = (count + 1) * ((2 * this.baseCost) + this.costInc * (2 * currentLevel + count)) / 2; + const unFloored = (preMult * BitNodeMultipliers.BladeburnerSkillCost) - count / 2; + return Math.floor(unFloored); + } } getMultiplier(name: string): number {