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,12 +134,24 @@ export class Skill {
} }
calculateCost(currentLevel: number, count = 1): number { calculateCost(currentLevel: number, count = 1): number {
//unFloored is roughly equivalent to if (count == 1) {
//(this.baseCost + currentLevel * this.costInc) * BitNodeMultipliers.BladeburnerSkillCost return Math.floor((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; else if (count < 0 || isNaN(count)) {
const unFloored = (preMult * BitNodeMultipliers.BladeburnerSkillCost) - count / 2; throw new Error(`Attempted to find cost of ${count} BB upgrades`);
return Math.floor(unFloored); }
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 { getMultiplier(name: string): number {