chessengine
Version:
Cchess move validator in node
12 lines (10 loc) • 344 B
JavaScript
module.exports = Rook;
function Rook (square, player) {
this.square = square;
this.player = player;
this.type = this.constructor;
this.character = 'r'
}
Rook.prototype.isValidMove = function isValidMove(move) {
return (move.square.isInSameColumn(move.destSquare) || move.square.isInSameRow(move.destSquare)) && move.isClearPath;
}