feat: Floor division support in dynamic values #1695
Merged
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.
This PR adds floor division functionality to dynamic values, useful for rounding arbitrary numbers to clean multiples.
For example, calculating a point score based on a timer count (hurryup) or a multiplier can yield tens and ones of digits, or even floats. Many pinball games like to have a minimum score multiple of 10 (e.g. no single-digit points) or even 100, and this PR enables a dynamic value to crop to the nearest iteration using the standard syntax of floor division * divisor.
The placeholder templating engine uses native python operations so it inherently understands that
//
means floor division, but the code module wasn't mapping theop.floordiv
method for executing it. This PR simply maps the method, and it works. Tests added to verify and prevent regressions.