Why does ecstasy affect your brain?

it does no direct damage but affects mood, and memory