Fix independent gain, add current cost #4

Merged
murapix merged 1 commit from main into main 2022-04-11 00:25:47 +00:00
murapix commented 2022-04-10 22:18:30 +00:00 (Migrated from github.com)

Independent conversions were subtracting the current resource amount from the expected gain, while the nextAt and convert functions were designed with a static currentGain in mind. This discrepancy was causing the displayed currentGain and nextAt value to "jump" immediately after a reset, and to produce erroneous values (e.g. after resetting for 5 points, attaining the original resource amount would allow you to reset for 4, then after resetting for those 4, which would drop you from 5 points to 4, you could once again reset for 5).

Moving the subtraction to a display-only actualGain function allows the currentGain function to work as intended, without interfering with the surrounding conversion functionality.

Additionally, a currentAt function has been added, to allow for displaying current costs or for use in custom convert functions, if the developer wishes to do so.

Independent conversions were subtracting the current resource amount from the expected gain, while the `nextAt` and `convert` functions were designed with a static `currentGain` in mind. This discrepancy was causing the displayed `currentGain` and `nextAt` value to "jump" immediately after a reset, and to produce erroneous values (e.g. after resetting for 5 points, attaining the original resource amount would allow you to reset for 4, then after resetting for those 4, which would drop you from 5 points to 4, you could once again reset for 5). Moving the subtraction to a display-only `actualGain` function allows the `currentGain` function to work as intended, without interfering with the surrounding conversion functionality. Additionally, a `currentAt` function has been added, to allow for displaying current costs or for use in custom `convert` functions, if the developer wishes to do so.
thepaperpilot commented 2022-04-11 00:25:42 +00:00 (Migrated from github.com)

Oh boy, there do seem to be a myriad of issues with the independent conversions code. It makes it a bit tricky to separate the existing issues from the ones this is fixing. Rather than fixing the others and making you update your code, I'm going to merge this in because it does appear to be working, and go and fix the other issues with independent conversions. If there are any issues with this implementation, I'll fix them myself during that process.

Thanks for the contribution!

Oh boy, there do seem to be a myriad of issues with the independent conversions code. It makes it a bit tricky to separate the existing issues from the ones this is fixing. Rather than fixing the others and making you update your code, I'm going to merge this in because it does appear to be working, and go and fix the other issues with independent conversions. If there are any issues with this implementation, I'll fix them myself during that process. Thanks for the contribution!
Sign in to join this conversation.
No description provided.