   # toPosition - the index of the pokemon to switch to
   #
   makeSwitch: (player, toPosition) =>
+    # TODO: Fail harder if pokemon not in team
+    # TODO: Add more cases of invalid indices (such as fainted poke or activePokemon)
+    pokemon = @getTeam(player.id).at(toPosition)
+    unless pokemon
+      console.log "#{player.username} made an invalid switch to position #{toPosition}."
+      return
+
     # Record the switch
     @playerActions[player.id] =
       type: 'switch'
       to: toPosition
 
-    # TODO: use splice instead of delete
     delete @requests[player.id]
 
     # Continue the turn if each player has moved.

      type: 'move'
      name: moveName

    # TODO: use splice instead of delete
    delete @requests[player.id]

    # Continue the turn if each player has moved.

    action = @getAction(id)
    pokemon = @getTeam(id).at(0)
    defenders = @getOpponentPokemon(id, @numActive)
    move = moves[action.name]

    @message "#{player.username}'s #{pokemon.name} used #{move.name}!"
