Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix bonus unset player vars #1833

Merged

Conversation

avanwinkle
Copy link
Collaborator

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 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.

Copy link

sonarcloud bot commented Sep 1, 2024

@avanwinkle avanwinkle merged commit fb80e03 into missionpinball:dev Sep 2, 2024
15 checks passed
@avanwinkle avanwinkle deleted the bugfix-bonus-unset-player-vars branch September 2, 2024 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant