He needs a lawyer. His decisions are criminal, not unlucky. He wouldn't be in any better shape if the pills were adderall than MDMA. These are felonies and in most states they are of equal magnitude.
I suspect from your comments that he has prior felony convictions.
You deleted the name of the state.
What's likely to happen is PRISON.

