diff --git a/.gitignore b/.gitignore index 1267db3ee..2ad443be6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.pyc -/logs \ No newline at end of file +/logs +*.local \ No newline at end of file diff --git a/machine_files/demo_man/audits/audits.yaml b/machine_files/demo_man/audits/audits.yaml index d18eca587..8de426a05 100755 --- a/machine_files/demo_man/audits/audits.yaml +++ b/machine_files/demo_man/audits/audits.yaml @@ -1,10 +1,10 @@ Events: ball_search_begin_phase1: 0 - game_ended: 22 - game_started: 106 + game_ended: 23 + game_started: 110 Player: score: - average: 7756563 + average: 7471061 top: - 20651990 - 17610920 @@ -16,88 +16,88 @@ Player: - 10849190 - 8799580 - 7880250 - total: 22 + total: 23 Shots: center_ramp: 77 - left_orbit: 33 - left_ramp: 34 + left_orbit: 34 + left_ramp: 40 right_orbit: 35 right_ramp: 11 side_ramp: 9 Switches: s_always_closed: 0 - s_ball_launch: 105 + s_ball_launch: 108 s_bottom_popper: 56 s_buy_in: 0 - s_car_chase_1: 65 - s_car_chase_2: 56 - s_car_chase_standup: 7 + s_car_chase_1: 68 + s_car_chase_2: 61 + s_car_chase_standup: 8 s_center_coin: 0 s_center_ramp: 93 - s_center_rollover: 19 + s_center_rollover: 20 s_claw_capture_simon: 2 - s_claw_lock_freeze: 3 - s_claw_position_1: 17 + s_claw_lock_freeze: 4 + s_claw_position_1: 19 s_claw_position_2: 6 s_claw_prison_break: 1 - s_claw_start_acmag: 8 + s_claw_start_acmag: 9 s_claw_super_jets: 2 s_coin_door_closed: 1 s_down: 0 - s_eject: 77 - s_elevator_hold: 27 - s_elevator_index: 16 + s_eject: 80 + s_elevator_hold: 31 + s_elevator_index: 18 s_enter: 0 s_esc: 0 s_eyeball_standup: 1 - s_flipper_lower_left: 644 - s_flipper_lower_left_eos: 636 - s_flipper_lower_right: 450 - s_flipper_lower_right_eos: 442 + s_flipper_lower_left: 675 + s_flipper_lower_left_eos: 667 + s_flipper_lower_right: 476 + s_flipper_lower_right_eos: 468 s_flipper_upper_left: 12 s_flipper_upper_left_eos: 0 s_flipper_upper_right: 14 - s_flipper_upper_right_eos: 634 + s_flipper_upper_right_eos: 665 s_fourth_coin: 0 s_left_coin: 0 s_left_handle_button: 0 - s_left_inlane: 94 + s_left_inlane: 102 s_left_jet: 30 - s_left_loop: 173 - s_left_outlane: 10 - s_left_ramp_enter: 193 - s_left_ramp_exit: 74 + s_left_loop: 178 + s_left_outlane: 11 + s_left_ramp_enter: 222 + s_left_ramp_exit: 83 s_left_rollover: 23 s_left_slingshot: 57 s_lower_rebound: 31 s_plumb_bob: 4 s_right_coin: 0 s_right_freeway: 59 - s_right_inlane: 85 + s_right_inlane: 88 s_right_jet: 94 s_right_outlane: 5 - s_right_ramp_enter: 109 + s_right_ramp_enter: 113 s_right_ramp_exit: 16 s_right_rollover: 11 - s_right_slingshot: 57 - s_shooter_lane: 115 + s_right_slingshot: 60 + s_shooter_lane: 122 s_side_ramp_enter: 24 s_side_ramp_exit: 11 s_slam_tilt: 0 - s_standup_1: 45 - s_standup_2: 48 - s_standup_3: 39 - s_standup_4: 36 - s_standup_5: 28 + s_standup_1: 46 + s_standup_2: 49 + s_standup_3: 42 + s_standup_4: 39 + s_standup_5: 29 s_start: 1 - s_top_popper: 16 - s_top_slingshot: 249 - s_trough_1: 105 - s_trough_2: 130 - s_trough_3: 98 - s_trough_4: 86 - s_trough_5: 87 - s_trough_jam: 91 + s_top_popper: 17 + s_top_slingshot: 250 + s_trough_1: 109 + s_trough_2: 134 + s_trough_3: 102 + s_trough_4: 90 + s_trough_5: 91 + s_trough_jam: 95 s_up: 0 - s_upper_left_flipper_gate: 202 + s_upper_left_flipper_gate: 210 s_upper_rebound: 23 diff --git a/mpf/devices/playfield.py b/mpf/devices/playfield.py index 09d75f8f9..2ee09bb0d 100644 --- a/mpf/devices/playfield.py +++ b/mpf/devices/playfield.py @@ -114,7 +114,7 @@ def get_additional_ball_capacity(self): return 999 def add_ball(self, balls=1, source_name=None, source_device=None, - player_controlled=False): + trigger_event=None): """Adds live ball(s) to the playfield. @@ -124,10 +124,9 @@ def add_ball(self, balls=1, source_name=None, source_device=None, add the ball(s) from. source_device: Optional ball device object you'd like to add the ball(s) from. - player_controlled: Boolean which specifies whether the player needs - to hit a button to cause the source device to eject a ball. - (i.e. when the player has to hit the 'launch' button to eject a - ball from the plunger lane.) Default is False. + trigger_event: The optional name of an event that MPF will wait for + before adding the ball into play. Typically used with player- + controlled eject tag events. Note that both source_name and source_device args are included to give you two options for specifying the source of the ball(s) to be added. @@ -156,15 +155,17 @@ def add_ball(self, balls=1, source_name=None, source_device=None, if not source_device: self.log.critical("Received request to add a ball to the playfield, " - "but no source device was passed and no ball devices" - "are tagged with 'ball_add_live'. Cannot add a ball.") + "but no source device was passed and no ball " + "devices are tagged with 'ball_add_live'. Cannot " + "add a ball.") raise Exception("Received request to add a ball to the playfield, " - "but no source device was passed and no ball devices" - "are tagged with 'ball_add_live'. Cannot add a ball.") + "but no source device was passed and no ball " + "devices are tagged with 'ball_add_live'. Cannot " + "add a ball.") self.log.debug("Received request to add %s ball(s). Source device: %s. " - "Player controlled: %s", balls, source_device.name, - player_controlled) + "Wait for event: %s", balls, source_device.name, + trigger_event) # If we don't have a coil that's fired by the player, and we our source # device has the ability to eject, then we do the eject now. @@ -181,50 +182,33 @@ def add_ball(self, balls=1, source_name=None, source_device=None, # eject now since there's no player_controlled tag and the device has an # eject coil. - if not player_controlled and source_device.config['eject_coil']: + if not trigger_event and source_device.config['eject_coil']: source_device.eject(balls=balls, target=self, get_ball=True) else: - # We have a player-controlled eject. Set up the event handler to - # watch for it. - self.setup_player_controlled_eject(balls, device) + self.setup_player_controlled_eject(balls, device, trigger_event) - #todo add support to pass a switch for this - - def setup_player_controlled_eject(self, balls, device): - """Used to set up a player-controlled eject from a ball device which - will eject a ball to the playfield. + def setup_player_controlled_eject(self, balls, device, trigger_event): + """Used to set up an eject from a ball device which will eject a ball to + the playfield. Args: balls: Integer of the number of balls this device should eject. device: The ball device object that will eject the ball(s) when a switch with the player-controlled eject tag is hit. + trigger_event: The name of the MPF event that will trigger the + eject. When this method it called, MPF will set up an event handler to look for - a switch hit from a switch with the tag specified in the - Game: player_controlled_eject_tag: setting in your config file. If you - don't have that setting in your config file, MPF will quit. + the trigger_event. """ - if 'player_controlled_eject_tag' in self.machine.config['Game']: - - if not device.balls: - device.request_ball(balls=balls) + if not device.balls: + device.request_ball(balls=balls) - self.machine.events.add_handler('sw_' + - self.machine.config['Game'] - ['player_controlled_eject_tag'], - self.player_eject_request, - balls=balls, device=device) - else: - self.log.critical("Received request to set up player-controlled " - "eject, but there is no " - "'player_controlled_eject_tag in the config file." - "Exiting.") - raise Exception("Received request to set up player-controlled " - "eject, but there is no " - "'player_controlled_eject_tag in the config file." - "Exiting.") + self.machine.events.add_handler(trigger_event, + self.player_eject_request, + balls=balls, device=device) def remove_player_controlled_eject(self): """Removed the player-controlled eject so a player hitting a switch diff --git a/mpf/game/game.py b/mpf/game/game.py index c9d16aec0..bb76025e7 100644 --- a/mpf/game/game.py +++ b/mpf/game/game.py @@ -196,7 +196,11 @@ def ball_started(self, ev_result=True): self.machine.events.post('ball_started', ball=self.player.ball, player=self.player.number) - self.machine.playfield.add_ball(player_controlled=True) + try: + self.machine.playfield.add_ball(trigger_event='sw_' + + self.machine.config['Game']['player_controlled_eject_tag']) + except KeyError: + self.machine.playfield.add_ball() def ball_drained(self, balls=0): self.log.debug("Entering Game.ball_drained()") diff --git a/version.py b/version.py index 78067f60c..b5a4c9e0c 100644 --- a/version.py +++ b/version.py @@ -1,2 +1,2 @@ -__version_info__ = ('0', '16', '1') +__version_info__ = ('0', '16', '2') __version__ = '.'.join(__version_info__)