Fix use of undefined in Decimal operations at start of game #20
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Sometimes, at the start of the game, undefined values were being passed into Decimal methods. This implicitly converts them to be 0 in the current version of break_eternity.js, but that behaviour should not be relied on as the TypeScript types for Decimal methods state that they do not support undefined values.
As a result, this commit fixes many instances where, at the start of the game, some multipliers are set to zero due to this issue.
This commit intentionally uses ?? instead of || as the author does not know what types are used - if it's possible that the left hand side could be a number (not a Decimal) then || shouldn't be used (if the left hand side was zero). However, if old browser support is required, || should be used instead of ?? (assuming the types are correct).
This commit also uses Decimal.dOne and Decimal.dZero when needed instead of constructing new Decimal instances.