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 have player_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. If player_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.
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.