Repository: missionpinball/mpf
Issue: Crash in shot profile

From: https://groups.google.com/forum/#!topic/mpf-users/A94hAMkzaoI

On load of this mode:
```
#config_version=4
mode:
    start_events: ball_starting
    stop_events: left_lock_start
    priority: 120

shots:
    s_left_saucer:
        hit_events: balldevice_bd_left_saucer_ball_enter
        profile: sp_left_saucer

shot_profiles:
    sp_left_saucer:
        show: left_saucer_eject

logic_blocks:
    sequences:
        lb_rod_light_lock:
            events:
                - drop_target_bank_rod_down
            events_when_complete: mode_left_lock_start

scoring:
    sp_left_saucer_hit:
        score: 100

shows:
    left_saucer_eject:
        - time: 0
          shows:
              left_saucer_eject_lights:
                  speed: 8

    left_saucer_eject_lights:
        - time: 0
          lights:
              pfl_left_saucer_1: 00
              pfl_left_saucer_2: 00
              pfl_left_saucer_3: ff
        - time: +1
          lights:
              pfl_left_saucer_1: 00
              pfl_left_saucer_2: ff
              pfl_left_saucer_3: 00
        - time: +1
          lights:
              pfl_left_saucer_1: ff
              pfl_left_saucer_2: 00
              pfl_left_saucer_3: 00
        - time: +1
          lights:
              pfl_left_saucer_1: 00
              pfl_left_saucer_2: 00
              pfl_left_saucer_3: 00
```

We get this error (need to reproduce in a test):
```
INFO : Mode.left_saucer : Mode Starting. Priority: 120
INFO : Machine : Shutting down...
INFO : Machine : Shutting down...
ERROR : asyncio : Exception in callback EventManager.process_event_queue()
handle: <Handle EventManager.process_event_queue()>
Traceback (most recent call last):
  File "/Applications/MPF.app/Contents/Frameworks/python/3.5.0/lib/python3.5/asyncio/events.py", line 125, in _run
    self._callback(*self._args)
  File "/Applications/MPF.app/Contents/Frameworks/python/3.5.0/lib/python3.5/site-packages/mpf/core/events.py", line 502, in process_event_queue
    **event[3])
  File "/Applications/MPF.app/Contents/Frameworks/python/3.5.0/lib/python3.5/site-packages/mpf/core/events.py", line 438, in _process_event
    result = handler.callback(**merged_kwargs)
  File "/Applications/MPF.app/Contents/Frameworks/python/3.5.0/lib/python3.5/site-packages/mpf/core/mode.py", line 192, in start
    self._add_mode_devices()
  File "/Applications/MPF.app/Contents/Frameworks/python/3.5.0/lib/python3.5/site-packages/mpf/core/mode.py", line 379, in _add_mode_devices
    player=self.player)
  File "/Applications/MPF.app/Contents/Frameworks/python/3.5.0/lib/python3.5/site-packages/mpf/devices/shot.py", line 83, in device_added_to_mode
    self.enable(mode)
  File "/Applications/MPF.app/Contents/Frameworks/python/3.5.0/lib/python3.5/site-packages/mpf/devices/shot.py", line 639, in enable
    self.update_profile(profile=profile, enable=True, mode=mode)
  File "/Applications/MPF.app/Contents/Frameworks/python/3.5.0/lib/python3.5/site-packages/mpf/devices/shot.py", line 693, in update_profile
    self._add_profile2(profile=profile, enable=enable, mode=mode)
  File "/Applications/MPF.app/Contents/Frameworks/python/3.5.0/lib/python3.5/site-packages/mpf/devices/shot.py", line 761, in _add_profile2
    self.add_profile(this_entry)
  File "/Applications/MPF.app/Contents/Frameworks/python/3.5.0/lib/python3.5/site-packages/mpf/devices/shot.py", line 724, in add_profile
    self._update_show(mode=profile_dict['mode'], advance=False)
  File "/Applications/MPF.app/Contents/Frameworks/python/3.5.0/lib/python3.5/site-packages/mpf/devices/shot.py", line 230, in _update_show
    profile['settings']['player_variable']]])
IndexError: list index out of range
Shutdown because of an exception:
ERROR : root : list index out of range
Traceback (most recent call last):
  File "/Applications/MPF.app/Contents/Frameworks/python/3.5.0/lib/python3.5/site-packages/mpf/commands/game.py", line 134, in __init__
    MachineController(mpf_path, machine_path, vars(args)).run()
  File "/Applications/MPF.app/Contents/Frameworks/python/3.5.0/lib/python3.5/site-packages/mpf/core/machine.py", line 565, in run
    self._run_loop()
  File "/Applications/MPF.app/Contents/Frameworks/python/3.5.0/lib/python3.5/site-packages/mpf/core/machine.py", line 605, in _run_loop
    raise self._exception['exception']
  File "/Applications/MPF.app/Contents/Frameworks/python/3.5.0/lib/python3.5/asyncio/events.py", line 125, in _run
    self._callback(*self._args)
  File "/Applications/MPF.app/Contents/Frameworks/python/3.5.0/lib/python3.5/site-packages/mpf/core/events.py", line 502, in process_event_queue
    **event[3])
  File "/Applications/MPF.app/Contents/Frameworks/python/3.5.0/lib/python3.5/site-packages/mpf/core/events.py", line 438, in _process_event
    result = handler.callback(**merged_kwargs)
  File "/Applications/MPF.app/Contents/Frameworks/python/3.5.0/lib/python3.5/site-packages/mpf/core/mode.py", line 192, in start
    self._add_mode_devices()
  File "/Applications/MPF.app/Contents/Frameworks/python/3.5.0/lib/python3.5/site-packages/mpf/core/mode.py", line 379, in _add_mode_devices
    player=self.player)
  File "/Applications/MPF.app/Contents/Frameworks/python/3.5.0/lib/python3.5/site-packages/mpf/devices/shot.py", line 83, in device_added_to_mode
    self.enable(mode)
  File "/Applications/MPF.app/Contents/Frameworks/python/3.5.0/lib/python3.5/site-packages/mpf/devices/shot.py", line 639, in enable
    self.update_profile(profile=profile, enable=True, mode=mode)
  File "/Applications/MPF.app/Contents/Frameworks/python/3.5.0/lib/python3.5/site-packages/mpf/devices/shot.py", line 693, in update_profile
    self._add_profile2(profile=profile, enable=enable, mode=mode)
  File "/Applications/MPF.app/Contents/Frameworks/python/3.5.0/lib/python3.5/site-packages/mpf/devices/shot.py", line 761, in _add_profile2
    self.add_profile(this_entry)
  File "/Applications/MPF.app/Contents/Frameworks/python/3.5.0/lib/python3.5/site-packages/mpf/devices/shot.py", line 724, in add_profile
    self._update_show(mode=profile_dict['mode'], advance=False)
  File "/Applications/MPF.app/Contents/Frameworks/python/3.5.0/lib/python3.5/site-packages/mpf/devices/shot.py", line 230, in _update_show
    profile['settings']['player_variable']]])
IndexError: list index out of range
```

Changed files:
mpf/core/shot_profile_manager.py

diff --git a/mpf/core/shot_profile_manager.py b/mpf/core/shot_profile_manager.py
index 923fab654..1fcb534ee 100644
--- a/mpf/core/shot_profile_manager.py
+++ b/mpf/core/shot_profile_manager.py
@@ -86,6 +86,9 @@ class ShotProfileManager(object):
         if not config['player_variable']:
             config['player_variable'] = '%_' + profile_name
 
+        if not config['states']:
+            raise AssertionError("Shot profile {} has to contain at least one state.".format(profile_name))
+
         if self.debug:
             self.log.debug("Processed '%s' profile configuration: %s",
                            profile_name, config)