mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-23 08:03:48 +01:00
calculateCost now works more accurately for count<=100
This commit is contained in:
parent
908d5e9570
commit
8d9e077b66
@ -134,13 +134,25 @@ export class Skill {
|
||||
}
|
||||
|
||||
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
|
||||
//(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 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 {
|
||||
if (name === "successChanceAll") return this.successChanceAll;
|
||||
|
Loading…
Reference in New Issue
Block a user