Пример #1
0
async def handle(message, db):
    id = message.author.id
    name = message.author.name
    info = db.init_info_check(message)

    # Check if the player is in a raid, and if it's their turn
    if raid_manager.is_player_in_raid(id):
        await message.channel.send(messages.data['invalid_in_raid'].replace(
            '%name%', name))
        return

    # check if there's more than one argument
    if len(message.content.split(" ")) > 1:

        item_name = message.content[message.content.find(" ") + 1:].lower()
        item_id_equips = info['equips']

        # Get the requested item's ID, from the name
        requested_item_id = items.item_map.item_name_to_id.get(item_name, None)
        if requested_item_id is None or requested_item_id not in item_id_equips:
            await message.channel.send(
                messages.data['invalid_dequip_item'].replace('%name%', name))
            return

        item = items.item_map.item_map[requested_item_id]()
        # De-equip the item
        await item.dequip(message, db)

    else:
        await message.channel.send(messages.data['equip_usage'])
Пример #2
0
async def handle(message, db):
    id = message.author.id
    server_id = message.guild.id
    name = message.author.name
    info = db.init_info_check(message)

    # Check if there's a raid going on
    if not raid_manager.has_raid(server_id):
        return

    raid = raid_manager.get_raid(server_id)

    # Check if player is in raid
    if not raid_manager.is_player_in_raid(id, server_id=server_id):
        return

    # Check if raid state is player's turns
    if not raid.get_raid_state() == RaidState.PLAYER_TURN:
        return

    if raid.get_current_player() is not None:
        # Check if it's the player's turn
        if raid.get_current_player().id == id:
            player = raid.get_current_player()

            # In case of buffer... we immediately disable player moves by setting current player to none
            raid.current_player = None
            await message.channel.send(messages.data['raid_fled'].replace(
                '%name%', name))

            # Remove player from list
            raid.players.pop(raid.current_player_index)

            await raid.next_player(raid.default_channel, flee=True)
Пример #3
0
async def handle(message, db):
    id = message.author.id
    name = message.author.name
    info = db.init_info_check(message)

    # Check if the player is in a raid, and if it's their turn
    if raid_manager.is_player_in_raid(id):
        await message.channel.send(messages.data['invalid_in_raid'].replace(
            '%name%', name))
        return

    # check if there's more than one argument
    if len(message.content.split(" ")) > 1:

        item_name = message.content[message.content.find(" ") + 1:].lower()
        item_id_inventory = info['items']

        # Get the requested item's ID, from the name
        requested_item_id = items.item_map.item_name_to_id.get(item_name, None)
        if requested_item_id is None or requested_item_id not in item_id_inventory:
            await message.channel.send(
                messages.data['invalid_use_item'].replace('%name%', name))
            return

        # We know it's an item, just check if it's a consumable
        item = items.item_map.item_map[requested_item_id]()
        if not item.get_item_type() == ItemType.CONSUMABLE:
            await message.channel.send(
                messages.data['invalid_use_item'].replace('%name%', name))
            return

        # Use the item
        await item.use(message, db)
    else:
        await message.channel.send(messages.data['use_usage'])
Пример #4
0
async def handle(message, db):
    id = message.author.id
    server_id = message.guild.id
    name = message.author.name
    info = db.init_info_check(message)

    # Check if there's a raid going on
    if not raid_manager.has_raid(server_id):
        return

    raid = raid_manager.get_raid(server_id)

    # Check if player is in raid
    if not raid_manager.is_player_in_raid(id, server_id=server_id):
        return

    # Check if raid state is player's turns
    if not raid.get_raid_state() == RaidState.PLAYER_TURN:
        return

    if raid.get_current_player() is not None:
        # Check if it's the player's turn
        if raid.get_current_player().id == id:
            player = raid.get_current_player()

            # In case of buffer... we immediately disable attacking ability by setting current player to none
            raid.current_player = None

            if not raid.get_raid_boss().evaded_roll():
                # Damage the boss
                damage = player.get_info()['atk'] + player.extra_atk

                raid.get_raid_boss().damage(damage)

                await message.channel.send(
                    messages.data['raid_attack_hit'].replace(
                        '%boss_name%',
                        raid.get_raid_boss().get_name()).replace(
                            '%amount%', str(damage)).replace(
                                '%hp%', str(raid.get_raid_boss().get_hp())))

            else:
                await message.channel.send(
                    messages.data['raid_attack_dodged'].replace(
                        '%boss_name%',
                        raid.get_raid_boss().get_name()))

            # Alive check
            if raid.get_raid_boss().is_alive():
                # This should update the current player
                await raid.next_player(raid.default_channel)
            else:
                await raid.end_raid(raid.default_channel)
Пример #5
0
async def handle(message, db):
    id = message.author.id
    name = message.author.name
    info = db.init_info_check(message)

    player_cds = db.init_cd_check(message)
    curr_time = int(time.time())

    # Check if the player is in a raid!
    if raid_manager.is_player_in_raid(id):
        await message.channel.send(messages.data['invalid_in_raid'].replace(
            '%name%', name))
        return

    if curr_time >= player_cds['heal']:
        amount = int(info['max_hp'] *
                     random.uniform(0.4, 0.7))  # 40-70% of max hp
        mp_amount = int(info['max_mp'] *
                        random.uniform(0.4, 0.7))  # 40-70% of max mp

        info['hp'] += amount
        info['mp'] += amount

        if info['hp'] > info['max_hp']:
            info['hp'] = info['max_hp']
        if info['mp'] > info['max_mp']:
            info['mp'] = info['max_mp']

        # Update db
        db.set_player_info(id, info)

        # set cd (3 hrs)
        player_cds[
            'heal'] = curr_time + 10800  # 10800 for 3 hrs, lower for testing
        db.set_player_cds(id, player_cds)

        await message.channel.send(messages.data['heal_successful'].replace(
            '%name%',
            name).replace('%amount%',
                          str(amount)).replace('%amount2%', str(mp_amount)))

        pass
    else:
        seconds = player_cds['heal'] - curr_time
        time_msg = utils.format_time(seconds)

        await message.channel.send(messages.data['cooldown_timer'].replace(
            '%name%', name).replace('%action%',
                                    'Heal').replace('%time%', time_msg))
Пример #6
0
async def handle(message, db):
    id = message.author.id
    name = message.author.name

    # Don't if the player is in a raid
    if raid_manager.is_player_in_raid(id):
        await message.channel.send(messages.data['invalid_in_raid'].replace(
            '%name%', name))
        return

    await message.channel.send(messages.data['reset_confirmation'].replace(
        '%name%', name))
    confirmation_dict.confirmations[id] = (
        confirmation_dict.ConfirmationType.RESET, message.id)
    await cancel(message)
Пример #7
0
async def handle(message, db):
    id = message.author.id
    name = message.author.name
    server_id = message.guild.id
    info = db.init_info_check(message)

    # Check if the player has a class
    if info['class'] == "None":
        await message.channel.send(messages.data['no_class_raid'].replace(
            "%name%", name))
        return

    # Check if there is a raid going on
    if not raid_manager.has_raid(server_id):
        await message.channel.send(messages.data['no_raid'])
        return

    raid = raid_manager.get_raid(server_id)

    # Check if it's in the lobby state (open to joining)
    if not raid.get_raid_state() == RaidState.LOBBY:
        await message.channel.send(
            messages.data['raid_already_started'].replace("%name%", name))
        return

    # Check if the player is already in the raid
    if raid.has_player(id):
        await message.channel.send(messages.data['already_in_raid'].replace(
            "%name%", name))
        return

    # Check if the player is already in a raid (in another server)
    if raid_manager.is_player_in_raid(id):
        await message.channel.send(
            messages.data['raid_in_other_server'].replace("%name%", name))
        return

    if raid.add_player(id, name, db):
        time_left = strftime("%M:%S", gmtime(raid.get_timer().get_time_left()))
        await message.channel.send(
            messages.data['raid_join_successful'].replace(
                '%name%', name).replace('%time%', time_left))
    else:
        await message.channel.send(messages.data['raid_full'].replace(
            "%name%", name))