allow user to edit posts made by others users based on the user role

By giving each role the edit_others_posts capability, plus allowing each role to edit only one CPT, you actually getting what you want. no need to check anything about other users capabilities this way.

Maybe what you’re missing is having a different capability set for each post type. e.g: if you have CPT called books you can create a custom capabilities corresponding only with books, edit_others_books for instance. It’s very easy to code, you can read more about it here:http://justintadlock.com/archives/2010/07/10/meta-capabilities-for-custom-post-types

Hope it’s helpful.