ChessDotNet.ChessGame.ApplyCastle C# (CSharp) Method

ApplyCastle() protected method

protected ApplyCastle ( Move move ) : CastlingType
move Move
return CastlingType
        protected virtual CastlingType ApplyCastle(Move move)
        {
            CastlingType castle;
            int rank = move.Player == Player.White ? 1 : 8;
            File rookFile;
            File newRookFile;
            if (move.NewPosition.File == File.C)
            {
                castle = CastlingType.QueenSide;
                rookFile = File.A;
                newRookFile = File.D;
            }
            else
            {
                castle = CastlingType.KingSide;
                rookFile = File.H;
                newRookFile = File.F;
            }
            SetPieceAt(newRookFile, rank, new Rook(move.Player));
            SetPieceAt(rookFile, rank, null);
            return castle;
        }