Exemplo n.º 1
0
    async def use_command(self, ctx, item_num=""):
        """ Use an item"""

        name = ctx.message.author.display_name
        init_player_duel_db(name)
        inv = common.users[name]['inventory']
        equip = common.users[name]['equip']
        if item_num == "":
            if len(inv) == 0:
                await self.bot.say("You have no items!")
            else:
                inv_string = "Item_ID: Item_Name (Description)\n"
                for it in inv:
                    inv_string += "{}: {} ({})\n".format(
                        it, get_name(it), get_text(it))
                # If any are in use, go ahead print that info
                if len(equip) > 0:
                    icons = {
                        'armor': ":shirt:",
                        'weapon': ":dagger:",
                        'other': ":ring:"
                    }
                    inv_string += "\nYour current loadout is:\n"
                    for i in equip:
                        item_num = equip[i]
                        used_amount = inv[item_num]
                        inv_string += "{}: {} - {} use(s) remaining.\n" \
                                      .format(icons[i],
                                              get_name(item_num),
                                              (get_uses(item_num)
                                               - used_amount))

                await self.bot.say(inv_string)
        elif item_exists(item_num) and item_num in inv and \
                get_slot(item_num) in equip:
            slot = get_slot(item_num)
            await self.bot.say("You already have the {} equipped in the {} "
                               "slot.".format(get_name(equip[slot]), slot))
        elif item_exists(item_num) and item_num not in inv:
            await self.bot.say("You don't have that item!")
        elif item_exists(item_num) and item_num in inv:
            await self.bot.say("Item \"{}\" will be active starting with your "
                               "next duel.".format(get_name(item_num)))
            common.users[name]['equip'][get_slot(item_num)] = item_num
        else:
            await self.bot.say("**!use <item_id>**: To use an item \n"
                               "**!use**: to view your inventory")
Exemplo n.º 2
0
async def print_at_midnight(bot):
    """
    Prints list at midnight
    :return:
    """
    c_to_send = None

    await bot.wait_until_ready()
    for channel in bot.get_all_channels():
        if channel.name == 'gen_testing' or \
                channel.name == common.ARGS['channel']:
            c_to_send = channel
            break

    while not bot.is_closed:
        now = datetime.now(pytz.timezone('US/Eastern'))
        midnight = now.replace(hour=23, minute=59, second=59, microsecond=59)
        if now > midnight:
            midnight = midnight.replace(day=(now.day + 1))
        print("Scheduling next list print at {}".format(pretty_date(midnight)))
        await asyncio.sleep((midnight - now).seconds)
        await bot.send_message(c_to_send, common.whos_in.whos_in())

        # Community Drop Time
        i_awarded = False
        i = False
        while not i_awarded:
            for m in bot.get_all_members():
                if m.display_name != 'brochat-bot' and m.display_name in \
                        common.users and \
                        'duel_record' in common.users[m.display_name]:
                    i = await item_chance_roll(bot, m.display_name, c_to_send)
                i_awarded = i_awarded or i

        # Drink Debt Enforcement
        for m in bot.get_all_members():
            nc = m.display_name
            if nc != 'brochat-bot' and nc in common.users and \
                    'drinks_owed' in common.users[nc] \
                    and common.users[nc]['drinks_owed'] > 6 \
                    and 'inventory' in common.users[nc] \
                    and len(common.users[nc]['inventory']) > 0:
                item_take = choice(list(common.users[nc]['inventory'].keys()))
                await bot.send_message(
                    c_to_send, "{}, the bank sent me to collect on "
                    "your debt. I'll have to take your {} "
                    "in lieu of one drink. Can't cheat "
                    "friendship around these parts.".format(
                        nc, get_name(item_take)))
                if get_slot(item_take) in common.users[nc]['equip']:
                    del (common.users[nc]['equip'][get_slot(item_take)])
                del common.users[nc]['inventory'][item_take]
                await bot.send_message(
                    c_to_send,
                    "You now owe {} drinks.".format(consume_drink(nc)))
        common.whos_in.update_db()
        await asyncio.sleep(60 * 10)
Exemplo n.º 3
0
async def whoami(ctx):
    """Tell me about myself"""
    author = str(ctx.message.author.display_name)
    if author in common.users and common.users[author] != {}:
        message_output = "Well, I don't know you that well, but " \
                         "from what I've been hearing on the " \
                         "streets...\n"

        for k, v in common.users[author].items():
            if k == "duel_record":
                if v[0] < 10 and v[1] > (v[0] + 5):
                    output = "You're a pretty terrible dueler"
                elif v[0] < 10:
                    output = "You're a pretty green dueler"
                elif v[0] < 100:
                    output = "You're a seasoned dueler"
                else:
                    output = "You're a master dueler"

                output += ", and your record is **{}** wins, **{}** losses," \
                          " and **{}** ties.".format(v[0], v[1], v[2])
            elif k == "a_item":
                if v is None:
                    output = "You don't have a dueling item equipped."
                else:
                    output = "You have **{}** equipped."\
                        .format(get_name(v))
            elif k == "inventory":
                if v == {}:
                    output = "You don't have an inventory for dueling items."
                else:
                    output = "Your inventory of dueling items:"
                    for item, count in v.items():
                        output += "\n    - {}".format(get_name(item))
            else:
                output = "Your {} is **{}**.".format(k, v)

            message_output += "\n" + output
        await bot.say(message_output)

    else:
        await bot.say("You're {}, but that's all I know about you."
                      .format(author))
Exemplo n.º 4
0
    async def unequip_command(self, ctx, slot: str):
        """Unequips an item in use"""

        name = ctx.message.author.display_name

        if 'equip' not in common.users[name] or len(common.users[name]) < 1:
            await self.bot.say("You have no items equipped!")
        elif slot not in common.users[name]['equip']:
            for s in common.users[name]['equip']:
                if common.users[name]['equip'][s] == slot:
                    item_num = common.users[name]['equip'][s]
                    await self.bot.say("You have unquipped the {}".format(
                        get_name(item_num)))
                    del (common.users[name]['equip'][s])
                    return
            await self.bot.say("You don't have an item equipped in that slot!")
        else:
            item_num = common.users[name]['equip'][slot]
            await self.bot.say("You have unquipped the {}".format(
                get_name(item_num)))
            del (common.users[name]['equip'][slot])
Exemplo n.º 5
0
async def item_disarm_check(ctx, c_item, v_item, c_name, v_name):
    """
    Handles the Disarming spec_effect

    :param ctx: Context
    :param c_item: Challenger's weapon
    :param v_item: Victim's weapon
    :param c_name: Challenger's Display name
    :param v_name: Victim's Display name
    """
    notif_str = ""
    c_item_ret = None
    v_item_ret = None
    if c_item is not None and 'disarm_effect' in c_item.type:
        if len(common.users[v_name]['equip']) < 1:
            notif_str += "{} has nothing to disarm, the {} has no effect!\n"\
                         .format(v_name, c_item.name)
            if len(c_item.type) == 1:
                return_item(c_item, c_name)
        else:  # Does the victim have an item that can be disarmed?
            poss_items = []
            for i in common.users[v_name]['equip']:
                if i == 'armor' or i == 'other':
                    poss_items.append(i)
                elif i == 'weapon' and 'disarm_effect' not in v_item.type:
                    poss_items.append(i)

            if len(poss_items) < 1:  # If no possible items give up
                notif_str += "{} only has a disarm item, the {} has no " \
                             "effect!\n".format(v_name, c_item.name)
                if len(c_item.type) == 1:
                    return_item(c_item, c_name)
            else:  # We can disarm something, do so.
                item_to_disarm = common.users[v_name]['equip'][choice(
                    poss_items)]
                notif_str += "{}'s {} has been removed by the {}!\n"\
                             .format(v_name, get_name(item_to_disarm),
                                     c_item.name)
                v_item_ret = DuelItem(0, item_to_disarm)
                return_item(v_item_ret, v_name)

    if v_item is not None and 'disarm_effect' in v_item.type:
        if len(common.users[c_name]['equip']) < 1:
            notif_str += "{} has nothing to disarm, the {} has no effect!\n"\
                         .format(c_name, v_item.name)
            if len(v_item.type) == 1:
                return_item(v_item, v_name)
        else:  # Does the challenger have an item that can be disarmed?
            poss_items = []
            for i in common.users[c_name]['equip']:
                if i == 'armor' or i == 'other':
                    poss_items.append(i)
                elif i == 'weapon' and 'disarm_effect' not in c_item.type:
                    poss_items.append(i)
            if len(poss_items) < 1:  # If no possible items give up
                notif_str += "{} only has a disarm item, the {} has no " \
                             "effect!\n".format(c_name, v_item.name)
                if len(v_item.type) == 1:
                    return_item(v_item, v_name)
            else:  # We can disarm something, do so.
                item_to_disarm = common.users[c_name]['equip'][choice(
                    poss_items)]
                notif_str += "{}'s {} has been removed by the {}!\n"\
                             .format(c_name, get_name(item_to_disarm),
                                     v_item.name)
                c_item_ret = DuelItem(0, item_to_disarm)
                return_item(c_item_ret, c_name)

    await ctx.bot.say(notif_str)
    return c_item_ret, v_item_ret