Skip to content

Commit

Permalink
Merge pull request #602 from missionpinball/improve_logging_in_ball_c…
Browse files Browse the repository at this point in the history
…ontroller

dump ball devices when game does not start
  • Loading branch information
jabdoa2 committed Oct 10, 2016
2 parents 98c46b7 + e0b072e commit 8b2d0f7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions mpf/core/ball_controller.py
Expand Up @@ -242,6 +242,11 @@ def _initialize(self, **kwargs):
'_ball_enter',
self._ball_drained_handler)

def dump_ball_counts(self):
"""Dump ball count of all devices."""
for device in self.machine.ball_devices:
self.log.info("%s contains %s balls. Tags %s", device.name, device.balls, device.tags)

def request_to_start_game(self, **kwargs):
"""Method registered for the *request_to_start_game* event.
Expand All @@ -255,12 +260,10 @@ def request_to_start_game(self, **kwargs):
except ValueError:
balls = -1
self.log.debug("Received request to start game.")
self.log.debug("Balls contained: %s, Min balls needed: %s",
balls,
self.machine.config['machine']['min_balls'])
if balls < self.machine.config['machine']['min_balls']:
self.dump_ball_counts()
self.log.warning("BallController denies game start. Not enough "
"balls")
"balls. %s found. %s required", balls, self.machine.config['machine']['min_balls'])
return False

if self.machine.config['game']['allow_start_with_ball_in_drain']:
Expand All @@ -273,6 +276,7 @@ def request_to_start_game(self, **kwargs):

elif not self.are_balls_collected(allowed_positions):
self.collect_balls('home')
self.dump_ball_counts()
self.log.warning("BallController denies game start. Balls are not "
"in their home positions.")
return False
Expand Down

0 comments on commit 8b2d0f7

Please sign in to comment.