Exemplo n.º 1
0
def handle_tellme(message):
    #safety first
    if len(message.content.split()) == 1:
        return 'What do you want to know, {}?'.format(co.whois(message.author))

    msg = ''
    key = message.content[message.content.index('me ') + 3:]
    if (co.whois(message.author) + '_char') not in db.keys() or not isinstance(
            db[co.whois(message.author) + '_char'], co.RPGCharacter):
        msg = 'You don\'t own a character, {}'.format(co.whois(message.author))
    elif co.whois(message.author) != str(message.author):
        val = db[co.whois(message.author) + '_char'].get_roll(key)

        if (val == None):
            val = co.chars[co.whois(message.author) + '_char'].get(key)

        try:
            int(val)
            msg = '{}\'s {} gets {} dice'.format(co.whois(message.author), key,
                                                 val)
        except Exception:
            msg = '{}\'s {}: {}'.format(co.whois(message.author), key, val)
    else:
        msg = 'You don\'t have an alterego, {}'.format(co.whois(
            message.author))

    return msg
Exemplo n.º 2
0
def handle_damage(message):
    severity = None
    try:
        severity = int(message.content.split()[1]) - 1
        db[co.whois(message.author) + '_char'].get("wounds")[severity] += 1
        return 'Wound of Level {} added. {} in total\n{}'.format(
            severity + 1,
            db[co.whois(message.author) + '_char'].get("Wounds")[severity],
            db[co.whois(message.author) + '_char'].get("Wounds"))
    except Exception as e:
        if co.whois(message.author) == str(message.author)[:-5]:
            return 'You don\'t own a character'
        elif severity == None:
            return 'Needs a number'
        return 'Unknown failure: ' + str(e)
Exemplo n.º 3
0
def handle_roll(message):
    if ' fate' in message.content:
        return handle_fate(message)
    else:
        request = RollRequest(message.content)
        rnd = request.process()
        return 'Roll as requested by {}:\n{}'.format(co.whois(message.author),
                                                     rnd)
Exemplo n.º 4
0
def handle_heal(message):
    try:
        severity = int(message.content.split()[1]) - 1
        if db[co.whois(message.author) + '_char'].get("Wounds")[severity] <= 0:
            return 'Nothing to heal here\n{}'.format(
                db[co.whois(message.author) + '_char'].get("Wounds"))
        db[co.whois(message.author) + '_char'].get("Wounds")[severity] = max(
            db[co.whois(message.author) + '_char'].get("Wounds")[severity] - 1,
            0)
        return 'A wound of Level {} healed. {} remain\n{}'.format(
            severity + 1,
            db[co.whois(message.author) + '_char'].get("Wounds")[severity],
            db[co.whois(message.author) + '_char'].get("Wounds"))
    except Exception as e:
        return 'Needs a number\n' + str(e)
Exemplo n.º 5
0
def handle_become(message):
    if len(message.content.split(' ', 1)) > 1:
        arg = message.content.split(' ', 1)[1]
        key = str(message.author)[:-5] + "_nick"
        if arg.lower() == "myself":
            del db[key]
            msg = "{} is theirself again.".format(str(message.author))
        else:
            db[key] = arg

            #check if arg is character name
            if (arg + '_char') in db.keys():
                append = '\nCharacter found; it\'s now controlled by you'
            else:
                append = '\nNo character found'

            msg = "{} is now {}.{}".format(str(message.author), (db[key]),
                                           append)
    else:
        msg = 'No nickname given. How should I call you from now, {}?'.format(
            co.whois(message.author))
    return msg
Exemplo n.º 6
0
def handle_probability(message):
    request = probability_request(message.content)
    return 'Probable result as requested by {}:\n{}'.format(
        co.whois(message.author), request.process())