Chess.Data.Piece.King.IsLegalMove C# (CSharp) Method

IsLegalMove() public method

public IsLegalMove ( Square board, Move move, IEnumerable pastMoves = null ) : bool
board Chess.Data.Entities.Square
move Chess.Data.Entities.Move
pastMoves IEnumerable
return bool
        public override bool IsLegalMove(Square[][] board, Move move, IEnumerable<Move> pastMoves = null)
        {
            var destination = board[move.EndRow][move.EndColumn];

            ValidateNotAttackingSameTeam(board, move);

            if (Math.Abs(move.RowChange) > 1)
                throw new Exception("You may not move multiple columns.");
            if (move.ColumnChange > 1)
            {
                if (MoveCount > 0)
                    throw new Exception("You may not move multiple columns.");
                return IsLegalCastle(board, move);
            }

            return !destination.TargetedByTeam(board, GetOppositeTeam());
        }