heavily refactored chess move validity logic