Chess.Data.Piece.Pawn.IsLegalMove C# (CSharp) Méthode

IsLegalMove() public méthode

public IsLegalMove ( Square board, Move move, IEnumerable pastMoves = null ) : bool
board Chess.Data.Entities.Square
move Chess.Data.Entities.Move
pastMoves IEnumerable
Résultat bool
        public override bool IsLegalMove(Square[][] board, Move move, IEnumerable<Move> pastMoves = null)
        {
            var defender = GetDestinationPiece(board, move);

            if (move.RowChange != LegalDirectionByTeam())
                if (!ValidOpeningPushWithNoDefender(board, move))
                    return false;

            if (move.ColumnChange != 0)
            {
                CheckForMultipleColumnMovement(move);

                CheckForLegalDirection(move);

                if (defender == null && !IsLegalEnPassant(board, move, pastMoves))
                    return false;

                ValidateNotAttackingSameTeam(board, move);

                return true;
            }

            if (defender != null)
                throw new Exception("There is a piece in the way!");

            return true;
        }