'Mostly parsing for calling the dice roller function'

def func(self):

    if (not self.args):
        self.caller.msg('Usage:    @dice    <nr>d<sides>    [modifier]    [conditional]')
        return
    argstring = ''.join((str(arg) for arg in self.args))
    parts = [part for part in RE_PARTS.split(self.args) if part]
    len_parts = len(parts)
    modifier = None
    conditional = None
    if ((len_parts < 3) or (parts[1] != 'd')):
        self.caller.msg('You    must    specify    the    die    roll(s)    as    <nr>d<sides>.    For    example,    2d6    means    rolling    a    6-sided    die    2    times.')
        return
    ndicelimit = 10000
    nsidelimit = 10000
    if ((int(parts[0]) > ndicelimit) or (int(parts[2]) > nsidelimit)):
        self.caller.msg(('The    maximum    roll    allowed    is    %sd%s.' % (ndicelimit, nsidelimit)))
        return
    (ndice, nsides) = (parts[0], parts[2])
    if (len_parts == 3):
        pass
    elif (len_parts == 5):
        if (parts[3] in ('+', '-', '*', '/')):
            modifier = (parts[3], parts[4])
        else:
            conditional = (parts[3], parts[4])
    elif (len_parts == 7):
        modifier = (parts[3], parts[4])
        conditional = (parts[5], parts[6])
    else:
        self.caller.msg('You    must    specify    a    valid    die    roll')
        return
    try:
        (result, outcome, diff, rolls) = roll_dice(ndice, nsides, modifier=modifier, conditional=conditional, return_tuple=True)
    except ValueError:
        self.caller.msg(('You    need    to    enter    valid    integer    numbers,    modifiers    and    operators.    |w%s|n    was    not    understood.' % self.args))
        return
    if (len(rolls) > 1):
        rolls = ((',    '.join((str(roll) for roll in rolls[:(-1)])) + '    and    ') + str(rolls[(-1)]))
    else:
        rolls = rolls[0]
    if (outcome is None):
        outcomestring = ''
    elif outcome:
        outcomestring = ('    This    is    a    |gsuccess|n    (by    %s).' % diff)
    else:
        outcomestring = ('    This    is    a    |rfailure|n    (by    %s).' % diff)
    yourollstring = 'You    roll    %s%s.'
    roomrollstring = '%s    rolls    %s%s.'
    resultstring = '    Roll(s):    %s.    Total    result    is    |w%s|n.'
    if ('secret' in self.switches):
        string = (yourollstring % (argstring, '    (secret,    not    echoed)'))
        string += ('\n' + (resultstring % (rolls, result)))
        string += (outcomestring + '    (not    echoed)')
        self.caller.msg(string)
    elif ('hidden' in self.switches):
        string = (yourollstring % (argstring, '    (hidden)'))
        self.caller.msg(string)
        string = (roomrollstring % (self.caller.key, argstring, '    (hidden)'))
        self.caller.location.msg_contents(string, exclude=self.caller)
        string = (resultstring % (rolls, result))
        string += (outcomestring + '    (not    echoed)')
        self.caller.msg(string)
    else:
        string = (yourollstring % (argstring, ''))
        self.caller.msg(string)
        string = (roomrollstring % (self.caller.key, argstring, ''))
        self.caller.location.msg_contents(string, exclude=self.caller)
        string = (resultstring % (rolls, result))
        string += outcomestring
        self.caller.location.msg_contents(string)
