UNPKG

chessengine

Version:

Cchess move validator in node

12 lines (10 loc) 325 B
module.exports = Knight; function Knight (square, player) { this.square = square; this.player = player; this.type = this.constructor; this.character = 'k' } Knight.prototype.isValidMove = function isValidMove(move) { return (move.diff.x === 2 && move.diff.y === 1) || (move.diff.x === 1 && move.diff.y === 2); }