Skip to content

Commit

Permalink
Merge pull request #1725 from avanwinkle/audit-avg-score-int
Browse files Browse the repository at this point in the history
Audits: store average player score as int
  • Loading branch information
avanwinkle authored Nov 21, 2023
2 parents ea1a26f + 9691de6 commit cbf7d4f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mpf/plugins/auditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def audit_player(self, **kwargs):
self.current_audits['player'][item]['top'],
self.config['num_player_top_records']))

self.current_audits['player'][item]['average'] = (
self.current_audits['player'][item]['average'] = int(
((self.current_audits['player'][item]['total'] *
self.current_audits['player'][item]['average']) +
self.machine.game.player[item]) /
Expand Down
2 changes: 2 additions & 0 deletions mpf/tests/machine_files/auditor/modes/base/config/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ variable_player:
my_var: 100
add_not_audited:
not_audited: 100
add_score_odd:
score: 123
12 changes: 12 additions & 0 deletions mpf/tests/test_Auditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ def test_auditor_player_vars(self):
'my_var': {'top': [200, 0], 'average': 100.0, 'total': 2}},
auditor.data_manager.written_data["player"])

# test rounding the average to an integer
self.start_game()

self.post_event("add_score")
self.post_event("add_score_odd")
self.assertPlayerVarEqual(223, "score")

self.drain_all_balls()
self.assertGameIsNotRunning()

self.assertEqual(174, auditor.current_audits['player']['score']['average'])

def test_auditor_switches_events(self):
auditor = self.machine.plugins[0]
self.assertIsInstance(auditor, Auditor)
Expand Down

0 comments on commit cbf7d4f

Please sign in to comment.