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

Auditor: Missing switches, optional player vars #1757

Merged
merged 33 commits into from
Feb 22, 2024

Conversation

avanwinkle
Copy link
Collaborator

@avanwinkle avanwinkle commented Feb 22, 2024

This PR provides some improvements and functionality to the MPF Auditor to assist users in debugging their games.

auditor:
  missing_switch_min_games: 20
  enable_events: init_phase_5
  disable_events: []
  audit_shots: false
  autosave: false
  save_events: credits_added, ball_will_end, game_ended

Missing Switches

This PR adds switch detection logic to the Auditor to track the number of games since each switch has been triggered, to help users identify if a switch may be disconnected or malfunctioning. The default setting is 10 games, but this can be customized via config file with the missing_switch_min_games option.

Missing switches will be identified in the Audits Service Menu, including the count of games since the switch was detected. For advanced users who want to display a secret light, DMD pixel, or display widget to alert at-a-glance, the Auditor's report_missing_switches() method can be called.

Switches tagged with the no_audit tag will not be tracked, to avoid false alerts from non-game switches (like service menu buttons).

Saving Audits

This PR allows more flexibility with how frequently the Auditor writes audit data to disk, which can alleviate I/O pressure during gameplay by not writing a new file (from scratch!) every time a switch is hit. For backwards compatibility the autosave is defaulted to be on, but can be disabled with the config option autosave: false.

AutoSaving Events Only

However custom events may want to be autosaved (while not autosaving player, switch, and shot audits), so there is an additional config option autosave_events: true which will autosave the audits whenever an audit event occurs.

Disabling Shot Audits

Some users may not want to audit all of the shots in the game, so the config option audit_shots: false can be set to ignore shots and only log switches.

Enable/Disable the Auditor

This PR also adds enable_events and disable_events to the Auditor config, so users can control when the auditor is active. The default values are game_starting and game_ended, for backwards compatibility with the previous hard-coded behavior.

Don't Audit Coin Switches during Free Play

Similar to the existing no_audit switch tag to prevent auditing of non-game switches, a new tag no_audit_free can be applied to switches that are for paid games only (e.g. coin slots). When tagged with no_audit_free, these switches will not be tracked as "missing switches" while the game is in Free Play mode.

Auditing Player Variables when Undefined

This PR introduces a change to how player variables are audited. For every audited player variable, the Auditor tracks the number of audits, the average audit value, and a number of the highest recorded values (configurable with num_player_top_records, default 10). However some player variables may only apply to players who reach a certain point of the game, and should not be audited for players who don't.

DANGER

BREAKING CHANGE

This PR changes the player variable audits so that player variables that are not defined for a player are not included in the audit. Without this change, every player would have a value of 0 for the variable and the average value would be dragged down. With this change, only players who have a value set for that player variable will be counted.

MITIGATION TO BREAKING CHANGE

For player variables that should be audited for every player, even if the value is zero, that player variable should be initialized in the game config like so:

player_vars:
  some_thing_to_audit:
    initial_value: 0

Any value initialized in the player_vars config will be audited (because it is initialized in the player object), and any value set with variable_player will be audited (because it is added to the player object). Only values that are never set will be discarded during the audit top/total/average calculation.

Other Stuff

Volume Buttons from 10% to 5%
This PR reduces the service button volume controls to move in 5% increments instead of 10% increments, for finer control.

Typo typo typo
This PR fixes a typo for the config value events_when_reorder_balls, which was mistyped as events_when_reoder_balls

Event Handler Removal
This PR cleans up more event handlers created by the Auditor, to prevent memory leaks

close it down

Copy link

sonarcloud bot commented Feb 22, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@avanwinkle avanwinkle merged commit fef0251 into missionpinball:dev Feb 22, 2024
14 checks passed
@avanwinkle avanwinkle deleted the auditor-missing-switches branch February 22, 2024 16:03
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