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.
Summary
This PR fixes a bug in how bonus scores are calculated for player variables. Includes tests to validate.
Currently, MPF does a single evaluation on bonus entries to look for player vars, and if the player variable is not set then it assumes that the bonus entry is static and not variable-dependent. This is the correct behavior for entries without
player_score_entry
, but erroneously includes the bonus score for entries that haveplayer_score_entry
but that entry variable is not defined on the player. In either case, the bonus calculation falls back to a multiplier value of 1 for calculating the bonus score.The Fix
This PR improves the logic to only look for a player variable if
player_score_entry
is defined, and to accept the player fallback value of 0 for the multiplier. Ifplayer_score_entry
is not defined, then a fallback value of 1 is used.With this change, bonus-driving player variables no longer need to be explicitly initialized in the
player_vars:
config section and will behave as expected.Also, corrects a few leftover attributes lookups that should not iterate over collections directly.