Bug Fix: Geometric Series Formula Inconsistency#59
Bug Fix: Geometric Series Formula Inconsistency#59phillip-simons wants to merge 2 commits intoducdat0507:mainfrom
Conversation
|
Not sure if this PR really helps with #41. The core issue there as I understand it is that currency is being deducted without the card level being updated at all. Like it shouldn't matter that That said, this probably helps with a different bug with the auto-buyer. The auto-buyer logic incorrectly assumes that |
|
|
||
| function sumGeometricSeries(base, rate, n, owned = 0) { | ||
| base *= rate ** owned; | ||
| if (n == 1) return base; |
There was a problem hiding this comment.
This early return is still worth keeping because it prevents pointless exponentiation.
Problem
The sumGeometricSeries and maxGeometricSeries functions in js/util.js are not inverses of each other, causing incorrect upgrade cost calculations.
Root cause: sumGeometricSeries uses rate ** (n + 1) instead of rate ** n, calculating one extra term than intended.
Example
For a card with levelCost: [10, 2] (base=10, rate=2):
Impact on Autobuy
This mismatch causes autobuy to fail silently, especially noticeable with low balance currencies:
Affected Areas
All costs will be lower after this fix, as players were previously being overcharged.
Addresses #41