Psyshock is based on the Users special attack, and uses the target's defense. That's why it's so great for Alakazam since he can use his special attack to break through pokemon that once walled him, like Blissey.
"Foul Play uses the target's Attack stat to calculate damage, as opposed to the user's Attack stat. The target's stat boosts (Abilities like Huge Power plus anything that changes the stat stage, such as Swords Dance or Growl) are incorporated into the damage calculations, however any other boosts (such as STAB, being burned, Abilities like Adaptability or Tinted Lens, and items like Choice Band or BlackGlasses) are calculated with the user of Foul Play's items, Abilities, and status. "-Bulbapedia
Foul play works as described above.