calculateCost now works more accurately for count<=100

This commit is contained in:
Undeemiss 2022-05-28 21:06:25 -05:00
parent 908d5e9570
commit 8d9e077b66

@ -134,13 +134,25 @@ export class Skill {
} }
calculateCost(currentLevel: number, count = 1): number { calculateCost(currentLevel: number, count = 1): number {
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 //unFloored is roughly equivalent to
//(this.baseCost + currentLevel * this.costInc) * BitNodeMultipliers.BladeburnerSkillCost //(this.baseCost + currentLevel * this.costInc) * BitNodeMultipliers.BladeburnerSkillCost
//being repeated for increasing currentLevel //being repeated for increasing currentLevel
const preMult = (count + 1) * (2 * this.baseCost + this.costInc * (2 * currentLevel + count)) / 2; const preMult = (count + 1) * ((2 * this.baseCost) + this.costInc * (2 * currentLevel + count)) / 2;
const unFloored = (preMult * BitNodeMultipliers.BladeburnerSkillCost) - count / 2; const unFloored = (preMult * BitNodeMultipliers.BladeburnerSkillCost) - count / 2;
return Math.floor(unFloored); return Math.floor(unFloored);
} }
}
getMultiplier(name: string): number { getMultiplier(name: string): number {
if (name === "successChanceAll") return this.successChanceAll; if (name === "successChanceAll") return this.successChanceAll;