mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-11 02:03:58 +01:00
calculateCost now works more accurately for count<=100
This commit is contained in:
parent
908d5e9570
commit
8d9e077b66
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user