Update position.cpp

Check for king attacked only if pawn is a pinned piece.
Optimized a little legality check.