Skip to content

Commit cbf7d4f

Browse files
authored
Merge pull request #1725 from avanwinkle/audit-avg-score-int
Audits: store average player score as int
2 parents ea1a26f + 9691de6 commit cbf7d4f

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

mpf/plugins/auditor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def audit_player(self, **kwargs):
224224
self.current_audits['player'][item]['top'],
225225
self.config['num_player_top_records']))
226226

227-
self.current_audits['player'][item]['average'] = (
227+
self.current_audits['player'][item]['average'] = int(
228228
((self.current_audits['player'][item]['total'] *
229229
self.current_audits['player'][item]['average']) +
230230
self.machine.game.player[item]) /

mpf/tests/machine_files/auditor/modes/base/config/base.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ variable_player:
99
my_var: 100
1010
add_not_audited:
1111
not_audited: 100
12+
add_score_odd:
13+
score: 123

mpf/tests/test_Auditor.py

+12
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ def test_auditor_player_vars(self):
6464
'my_var': {'top': [200, 0], 'average': 100.0, 'total': 2}},
6565
auditor.data_manager.written_data["player"])
6666

67+
# test rounding the average to an integer
68+
self.start_game()
69+
70+
self.post_event("add_score")
71+
self.post_event("add_score_odd")
72+
self.assertPlayerVarEqual(223, "score")
73+
74+
self.drain_all_balls()
75+
self.assertGameIsNotRunning()
76+
77+
self.assertEqual(174, auditor.current_audits['player']['score']['average'])
78+
6779
def test_auditor_switches_events(self):
6880
auditor = self.machine.plugins[0]
6981
self.assertIsInstance(auditor, Auditor)

0 commit comments

Comments
 (0)