示例#1
0
    async def show_inventory(self, ctx, *args):
        """
            Shows your inventory
        """
        if not character.checkRegistration(str(ctx.author.id)):
            return await ctx.send(
                "You are not registered. Please register by using the command `!register`"
            )
        playerID = str(ctx.author.id)
        battler = db.Player.objects.get(battler_id=playerID)
        if len(battler.characters_list) == 0:
            return await ctx.send("You don't have an active character")

        pCharac = battler.getCharacter()
        embedList = mdisplay.displayInventoryList(pCharac)
        totalTabs = len(embedList)
        c_t = 0
        if len(embedList) == 0:
            return await ctx.send("You have no items in your inventory!")
        msg = await ctx.send(embed=embedList[0])
        if totalTabs > 1:
            loop = True
            previous_tab = '◀️'
            next_tab = '▶️'
            await msg.add_reaction(previous_tab)
            await msg.add_reaction(next_tab)

            def reaction_filter(reaction, user):
                return str(user.id) == str(ctx.author.id) and str(
                    reaction.emoji) in [previous_tab, next_tab]

            while loop:
                try:
                    pending_collectors = [
                        self.bot.wait_for('reaction_add',
                                          timeout=5,
                                          check=reaction_filter),
                        self.bot.wait_for('reaction_remove',
                                          timeout=5,
                                          check=reaction_filter)
                    ]
                    done_collectors, pending_collectors = await asyncio.wait(
                        pending_collectors,
                        return_when=asyncio.FIRST_COMPLETED)
                    for collector in pending_collectors:
                        collector.cancel()
                    for collector in done_collectors:
                        reaction, user = await collector
                    if reaction.emoji == next_tab:
                        c_t = (c_t + 1) % totalTabs
                    elif reaction.emoji == previous_tab:
                        c_t = (c_t - 1)
                        if c_t < 0:
                            c_t = totalTabs - 1
                    msg.edit(embed=embedList[c_t])
                except asyncio.TimeoutError:
                    await msg.add_reaction('💤')
                    loop = False
示例#2
0
 async def show(self, ctx, user: discord.User = None):
     """Shows your Profile, or the profile of a mentioned user."""
     if not character.checkRegistration(str(ctx.author.id)):
         return await ctx.send(
             "You are not registered. Please register by using the command `!register`"
         )
     userID = str(ctx.author.id)
     if user != None:
         userID = str(user.id)
     await ctx.channel.send(embed=character.show(userID, self.bot))
示例#3
0
 async def migrate(self, ctx):
     """Change the Serve/Guild you are registered to."""
     if not character.checkRegistration(str(ctx.author.id)):
         return await ctx.send(
             "You are not registered. Please register by using the command `!register`"
         )
     playerID = str(ctx.author.id)
     guildID = str(ctx.guild.id)
     battler = db.Player.objects.get(battler_id=playerID)
     battler.guild_id = guildID
     battler.save()
     await ctx.send("Migrated to **" + ctx.guild.name + "** succesfully!")
示例#4
0
 async def suicide(self, ctx):
     """Kills your currently active character"""
     if not character.checkRegistration(str(ctx.author.id)):
         return await ctx.send(
             "You are not registered. Please register by using the command `!register`"
         )
     playerID = str(ctx.author.id)
     battler = db.Player.objects.get(battler_id=playerID)
     pCharac = battler.getCharacter()
     message_to_send = pCharac.kill()
     battler.updateCurrentCharacter(pCharac)
     battler.save()
     await ctx.send(message_to_send)
示例#5
0
 async def unequip_item(self, ctx, *args):
     """Place an equipped item in your inventory"""
     if not character.checkRegistration(str(ctx.author.id)):
         return await ctx.send(
             "You are not registered. Please register by using the command `!register`"
         )
     if not await character.playabilityCheck(ctx, str(ctx.author.id)):
         return
     battler = db.Player.objects.get(battler_id=str(ctx.author.id))
     pCharac = battler.getCharacter()
     node = pCharac.getInstance()
     if isinstance(node, db.Battle):
         return await ctx.send(
             "You can't change your equipment during a battle.")
     if len(args) != 1:
         return await ctx.send("Invalid number of arguments")
     slot_index = int(args[0])
     return await ctx.send(mim.unequipItem(battler, slot_index))
示例#6
0
    async def compare_items(self, ctx, *args):
        """Compare an item, with the one you have equipped in the according slot, use with"""
        if not character.checkRegistration(str(ctx.author.id)):
            return await ctx.send(
                "You are not registered. Please register by using the command `!register`"
            )
        if not await character.playabilityCheck(ctx, str(ctx.author.id)):
            return
        battler = db.Player.objects.get(battler_id=str(ctx.author.id))

        if len(args) < 1 or len(args) > 2:
            return await ctx.send("Invalid number of arguments")
        storage_aliases = ["-s", "s", "storage", "vault", "house"]
        if args[1] in storage_aliases:
            return await ctx.send(
                embed=mim.compare_item(int(args[0]), battler, True))
        else:
            return await ctx.send(
                embed=mim.compare_item(int(args[0]), battler, False))
示例#7
0
 async def switch_to_character(self, ctx, *args):
     """Switch your Active character to the one you define with an index.
        Use the index as seen in your character's list. ( !mycharacters ) 
        Correct usage: !switch_to_character index
     """
     if not character.checkRegistration(str(ctx.author.id)):
         return await ctx.send(
             "You are not registered. Please register by using the command `!register`"
         )
     playerID = str(ctx.author.id)
     battler = db.Player.objects.get(battler_id=playerID)
     if int(args[0]) < 0 or int(args[0]) >= len(battler.characters_list):
         message_to_send = "Invalid argument"
     else:
         battler.active_character = int(args[0])
         battler.save()
         message_to_send = "Successfully changed active character to: **" + battler.getCharacter(
         ).name + "**."
     await ctx.send(message_to_send)
示例#8
0
 async def image(self, ctx, *args):
     """Shows your active character's image
        
        +myimage set imageURL 
        In order to set a new picture for your character.
     """
     if not character.checkRegistration(str(ctx.author.id)):
         return await ctx.send(
             "You are not registered. Please register by using the command `!register`"
         )
     playerID = str(ctx.author.id)
     battler = db.Player.objects.get(battler_id=playerID)
     pCharac = battler.getCharacter()
     if len(args) == 0:
         await ctx.send(pCharac.imageURL)
     else:
         if len(args) == 2 and args[0] == "set":
             pCharac.imageURL = args[1]
             battler.updateCurrentCharacter(pCharac)
             battler.save()
示例#9
0
 async def abandon_character(self, ctx, *args):
     """Permamently deletes a character.
        Use it to clear up space for more characters.
     """
     if not character.checkRegistration(str(ctx.author.id)):
         return await ctx.send(
             "You are not registered. Please register by using the command `!register`"
         )
     playerID = str(ctx.author.id)
     battler = db.Player.objects.get(battler_id=playerID)
     if int(args[0]) < 0 or int(args[0]) >= len(battler.characters_list):
         message_to_send = "Invalid argument"
     else:
         temp = battler.characters_list[int(args[0])].name
         del battler.characters_list[int(args[0])]
         if battler.active_character >= int(args[0]):
             battler.active_character = max(0, battler.active_character - 1)
         battler.save()
         message_to_send = "Goodbye forever: **" + temp + "**."
     await ctx.send(message_to_send)
示例#10
0
 async def set_pve_password(self, ctx, *args):
     """If you wish for your PvE Sessions to be password protected, use this
        Command in order to create a password.
     """
     if not character.checkRegistration(str(ctx.author.id)):
         return await ctx.send(
             "You are not registered. Please register by using the command `!register`"
         )
     if len(args) == 0:
         return await ctx.send("This command requires at least one argument"
                               )
     if len(args[0]) < 6:
         return await ctx.send(
             "If you wish to set a new password it needs to be at least 6 Characters."
         )
     playerID = str(ctx.author.id)
     battler = db.Player.objects.no_dereference().get(battler_id=playerID)
     battler.pve_join_password = args[0]
     battler.save()
     await ctx.send(
         "You have successfully created a password for your PvE Sessions")
     return
示例#11
0
 async def my_characters(self, ctx):
     """Shows an index of your characters"""
     if not character.checkRegistration(str(ctx.author.id)):
         return await ctx.send(
             "You are not registered. Please register by using the command `!register`"
         )
     playerID = str(ctx.author.id)
     battler = db.Player.objects.get(battler_id=playerID)
     embed = discord.Embed(
         title=battler.name + " (" + playerID + ")",
         description=
         "Index of your characters. Use the indexes here when attempting to select another of your characters",
         colour=discord.Colour.red(),
         timestamp=datetime.datetime.now())
     counter = 0
     for chara in battler.characters_list:
         disabling_conditions = [False, False, False]
         this_value = "Conditions: "
         for con in chara.conditions:
             if con.name == 'DEAD':
                 disabling_conditions[0] = True
             if con.name == 'PETRIFIED':
                 disabling_conditions[1] = True
             if con.name == 'ASLEEP':
                 disabling_conditions[2] = True
             this_value += "`" + con.name + "` "
         name_plugin = " "
         if disabling_conditions[2]:
             name_plugin += ":zzz: "
         if disabling_conditions[1]:
             name_plugin += ":rock: "
         if disabling_conditions[0]:
             name_plugin += ":skull: "
         embed.add_field(name=str(counter) + ": " + chara.name +
                         name_plugin,
                         value=this_value,
                         inline=False)
         counter += 1
     await ctx.send(embed=embed)
示例#12
0
 async def store_item(self, ctx, *args):
     """Place an item from inventory to Storage"""
     if not character.checkRegistration(str(ctx.author.id)):
         return await ctx.send(
             "You are not registered. Please register by using the command `!register`"
         )
     if not await character.playabilityCheck(ctx, str(ctx.author.id)):
         return
     battler = db.Player.objects.get(battler_id=str(ctx.author.id))
     pCharac = battler.getCharacter()
     node = pCharac.getInstance()
     if node.guild_id != battler.guild_id:
         return await ctx.send(
             "Your currently active character is not near your guild.")
     if len(args) != 1:
         return await ctx.send("Invalid number of arguments")
     slot_index = int(args[0])
     await ctx.send(mim.storeItem(pCharac.inventory, slot_index, battler))
     inventory = pCharac.inventory
     del inventory[slot_index]
     pCharac.inventory = inventory
     battler.updateCurrentCharacter(pCharac)
     battler.save()
     return