Add optional count parameter to hashCost and spendHashes

This commit is contained in:
Undeemiss
2022-05-31 21:13:03 -05:00
parent 6f017bf4f6
commit f0dc532513
5 changed files with 48 additions and 34 deletions
+7 -3
View File
@@ -62,11 +62,15 @@ export class HashUpgrade {
// Functions that returns the UI element to display the effect of this upgrade.
effectText: (level: number) => JSX.Element | null = () => null;
getCost(levels: number): number {
getCost(currentLevel: number, count = 1): number {
if (typeof this.cost === "number") {
return this.cost;
return this.cost * count;
}
return Math.round((levels + 1) * this.costPerLevel);
//This formula is equivalent to
//(currentLevel + 1) * this.costPerLevel
//being performed repeatedly
const collapsedSum = 0.5 * count * (count + 2 * currentLevel + 1);
return this.costPerLevel * collapsedSum;
}
}