示例#1
0
def until(prefix, target, event, card):
    """
    Roll in `event` until `card` is found and return a privmsg of the number of rolls
    necessary.
    """
    
    try:
        n = event.roll_until(card)
    
    except ValueError:
        line = ("Onii-chan your fat, greasy fingers must've made a typo, {0} isn't in "
                'the {1.formatted_title}!')
        line = line.format(paddb.name(card) or 'that monster', event)
        return cc.privmsg(target, line)
    
    if n:
        line = 'It took me {0} {1} of the {2.formatted_title} to roll {3}!'
        line = line.format(
            engine.number_to_words(n, threshold=100),
            engine.plural('roll', n),
            event,
            paddb.name(card) or 'that monster'
        )
    
    else:
        line = "Sorry onii-chan, looks like you don't have enough stones for that."
        
    return cc.privmsg(target, line)
示例#2
0
def until(prefix, target, event, card):
    """
    Roll in `event` until `card` is found and return a privmsg of the number of rolls
    necessary.
    """

    try:
        n = event.roll_until(card)

    except ValueError:
        line = (
            "Onii-chan your fat, greasy fingers must've made a typo, {0} isn't in "
            'the {1.formatted_title}!')
        line = line.format(paddb.name(card) or 'that monster', event)
        return cc.privmsg(target, line)

    if n:
        line = 'It took me {0} {1} of the {2.formatted_title} to roll {3}!'
        line = line.format(engine.number_to_words(n, threshold=100),
                           engine.plural('roll', n), event,
                           paddb.name(card) or 'that monster')

    else:
        line = "Sorry onii-chan, looks like you don't have enough stones for that."

    return cc.privmsg(target, line)
示例#3
0
def chance(prefix, target, event, card, n=1):
    """
    Calculate the percent chance of rolling `card` in `n` rolls of `event` and return a
    privmsg of the results.
    """

    chance = event.chance(card, n=n)

    line = 'You have a {0} chance of rolling {1} in {2} {3} of the {4.formatted_title}.'
    line = line.format(percent(chance),
                       paddb.name(card) or 'that monster',
                       engine.number_to_words(n, threshold=100),
                       engine.plural('roll', n), event)

    return cc.privmsg(target, line)
示例#4
0
def chance(prefix, target, event, card, n=1):
    """
    Calculate the percent chance of rolling `card` in `n` rolls of `event` and return a
    privmsg of the results.
    """
    
    chance = event.chance(card, n=n)
    
    line = 'You have a {0} chance of rolling {1} in {2} {3} of the {4.formatted_title}.'
    line = line.format(
        percent(chance),
        paddb.name(card) or 'that monster',
        engine.number_to_words(n, threshold=100),
        engine.plural('roll', n),
        event
    )
    
    return cc.privmsg(target, line)