Beispiel #1
0
            def inner_check(message: discord.Message):
                nonlocal target
                argument: list or tuple = message.content.split(' ')
                # 3 Argument beginning with "use" statement
                if argument[0].lower() == "use" and len(
                        argument) == 3 and message.author.id == char.id:
                    # Specify what do player want to do
                    # Using a normal move from Character
                    if argument[1].lower() == "normal":
                        if is_number(argument[2]):
                            target = find_target_by_index(
                                int(argument[2]),
                                opposition_team,
                                move_sample=char._normal_move)
                        else:
                            target = find_target_by_name(
                                argument[2],
                                opposition_team,
                                move_sample=char._normal_move)

                        # Use Character Normal Move
                        if target is not None:
                            char.NormalAttack(target)
                            return True

                    # Using a custom move from Character
                    elif is_number(argument[1]):
                        if int(argument[1]) >= 1 or int(argument[1]) <= len(
                                char._custom_moves):
                            if is_number(argument[2]):
                                target = find_target_by_index(
                                    int(argument[2]),
                                    opposition_team,
                                    move_sample=char._normal_move)
                            else:
                                target = find_target_by_name(
                                    argument[2],
                                    opposition_team,
                                    move_sample=char._normal_move)

                            # Use Character Normal Move
                            if target is not None:
                                char.CustomAttack(target, int(argument[1]))
                                return True

                    # Using a item from Character
                    # elif (argument[1] in moves or argument[1] in items) and (is_number(argument[2]) or argument[2] in names_in_game):
                    #     return True
                return False
Beispiel #2
0
    async def _rpg_nature(self, ctx: commands.Context, *args):
        mbr_data = checkin_member(ctx.author)
        if mbr_data is not None:
            if "CHARID" in mbr_data:
                if len(args) == 0:
                    await self._nature_help(ctx.channel)
                else:
                    # Get Info
                    if args[0].lower() == "info" or args[0].lower() == "-i":
                        pass

                    # Change Nature
                    elif is_number(args[0]):
                        if int(args[0]) > len(self.NATURES) or int(
                                args[0]) <= 0:
                            return
                        else:
                            if mbr_data['CHARID'] == int(args[0]):
                                await ctx.send(
                                    content=
                                    f"*You are already in class {self.NATURES[int(args[0])]}*"
                                )
                            else:
                                db_mbr.SetObject(
                                    {"member_id": str(ctx.author.id)},
                                    {'CHARID': int(args[0])})
                                await ctx.send(
                                    content=
                                    f"*You have changed from {self.NATURES[mbr_data['CHARID']]} to {self.NATURES[int(args[0])]}.*"
                                )
            else:
                await ctx.send(
                    f"__**{ctx.author.name}, You haven't start your character, type {get_prefix(ctx.guild)}start to begin.**__"
                )
Beispiel #3
0
    async def _one_word_story(self, ctx: commands.Context, *args):
        list_of_stories: list = checkin_guild(ctx.guild)["stories"]
        if len(args) == 0:
            await self.print_help(ctx.channel)
        else: 
            # Play
            if args[0].lower() == "-p" or args[0].lower() == "play":
                await self.ows_on_play(ctx.channel)

            # Help
            elif args[0].lower() == "-h" or args[0].lower() == "help":
                await self.print_help(ctx.channel)

            # Read Story
            elif args[0].lower() == "-r":
                story_num: int = random.randint(1, len(list_of_stories))
                if len(args) == 2:
                    isnum: bool = is_number(args[1])
                    story_num = int(args[1]) if isnum is True else random.randint(1, len(list_of_stories))
                picked_story: dict = list_of_stories[story_num - 1]
                emb = discord.Embed(
                    title=picked_story['title'],
                    description=picked_story['story'],
                    colour=WHITE
                    )
                emb.set_footer(text=f"Made on: {picked_story['date-made']}")
                await ctx.send(embed=emb)

            # Guild own Story
            elif args[0].lower() == "-os":
                if len(args) == 2:
                    isnum: bool = is_number(args[1])
                    args[1] = int(args[1]) if isnum is True else 1
                    await self.load_story(ctx.channel, ctx.author, page=args[1])
                else:
                    await self.load_story(ctx.channel, ctx.author)

            # Delete Story
            elif args[0].lower() == "-del":
                if len(args) < 2:
                    emb_err =discord.Embed(
                        title="📚 One Word Story | Delete Story",
                        colour=WHITE
                        )
                    emb_err.add_field(
                        name="How to Use?",
                        value="Use this Command seperated with space and followed by -del and index of story you like to delete."
                            f"Example Command to delete index number 1: {get_prefix(ctx.guild.id)}ows -del 1",
                        inline=False
                        )
                    await ctx.send(embed=emb_err)
                else:
                    isnum: bool = is_number(args[1])
                    if isnum is False:
                        emb_err = discord.Embed(
                            title="📚 One Word Story | Delete Story",
                            colour=WHITE
                            )
                        emb_err.add_field(
                            name="How to Use?",
                            value="Use this Command seperated with space and followed by -del and index of story you like to delete."
                                f"Example Command to delete index number 1: {get_prefix(ctx.guild.id)}ows -del 1",
                            inline=False
                            )
                        await ctx.send(embed=emb_err)
                    else:
                        index: int = int(args[1]) - 1
                        await ctx.send(content= f"Successfully deleted story with title : {list_of_stories[index]['title']}")
                        db_gld.UnsetItem({"guild_id": str(ctx.guild.id)}, {f"stories.{index}": list_of_stories[index]})
                        db_gld.UpdateObject({"guild_id": str(ctx.guild.id)}, {"$pull": {"stories": None}})
            
            # How to Play
            elif args[0].lower() == "-how":
                await self.manual(ctx.channel)
Beispiel #4
0
    async def _currency(self, ctx: commands.Context, *args):
        if len(args) == 0:
            await self.print_help(ctx.channel)
        else:
            guild_info: dict = checkin_guild(ctx.guild.id)
            cur_type: str = guild_info['currency']['type']
            person: discord.User = ctx.author

            # Change Server Currency Type
            if len(args) == 2 and args[0].lower() == "-t":
                emoji = check_emoji(args[1])
                if emoji:
                    emb: discord.Embed
                    if "\\U" in emoji:
                        partial_emoji = emoji.encode("ASCII").decode("unicode-escape")
                        db_gld.SetObject({"guild_id": str(ctx.guild.id)}, {
                            "currency.type": partial_emoji
                            })
                        emb = discord.Embed (
                            title="Server New Currency!",
                            description=f"> Server {ctx.guild.name} Currency is now {partial_emoji}",
                            colour=WHITE
                            )
                    else:
                        db_gld.SetObject({"guild_id": str(ctx.guild.id)}, {
                            "currency.type": emoji
                            })
                        emb = discord.Embed (
                            title="Server New Currency!",
                            description=f"> Server {ctx.guild.name} Currency is now " + emoji,
                            colour=WHITE
                            )
                    db_gld.SetObject({"guild_id": str(ctx.guild.id)}, {
                        "currency.modif-by": person.name,
                        "currency.last-modified": datetime.datetime.now().strftime('%B %d %Y')
                        })
                    await ctx.send(embed=emb)

            # Get Info Currency in Server
            elif args[0].lower() == "-get":
                emb = discord.Embed(
                    title=f"🏦 {ctx.guild.name}",
                    description=f"Currency Type : {cur_type}\n"
                        f"Chat Money [min-max] : {guild_info['currency']['chat-min']}-{guild_info['currency']['chat-max']} {cur_type}",
                    colour=WHITE
                    )
                emb.set_footer(text=f"Last Modified : {guild_info['currency']['last-modified']} | By : {guild_info['currency']['modif-by']}")
                await ctx.send(embed=emb)

            # Set Min Earn Money by Chatting
            elif len(args) == 2 and args[0].lower() == "-min":
                isnum: bool = is_number(args[1])
                if isnum is True:
                    min_in: int = int(args[1])
                    if guild_info["currency"]["chat-max"] < min_in:
                        db_gld.SetObject({"guild_id": str(ctx.guild.id)}, {
                            "currency.chat-max": min_in
                            })
                    db_gld.SetObject({"guild_id": str(ctx.guild.id)}, {
                        "currency.chat-min": min_in
                        })
                    updated_guild_info: dict = checkin_guild(ctx.guild.id)
                    emb = discord.Embed(
                        title="💸 Set Chat Money Success",
                        description=f"Chat Money Increament : {updated_guild_info['currency']['chat-min']}-{updated_guild_info['currency']['chat-max']}",
                        colour=WHITE
                        )
                    db_gld.SetObject({"guild_id": str(ctx.guild.id)}, {
                        "currency.modif-by": person.name,
                        "currency.last-modified": datetime.datetime.now().strftime('%B %d %Y')
                        })
                    await ctx.send(embed=emb)

            # Set Max Earn Money by Chatting
            elif len(args) == 2 and args[0].lower() == "-max":
                isnum: bool = is_number(args[1])
                if isnum is True:
                    max_in: int = int(args[1])
                    if guild_info["currency"]["chat-min"] > max_in:
                        db_gld.SetObject({"guild_id": str(ctx.guild.id)}, {
                            "currency.chat-min": max_in
                            })
                    db_gld.SetObject({"guild_id": str(ctx.guild.id)}, {
                        "currency.chat-max": max_in
                        })
                    updated_guild_info: dict = checkin_guild(ctx.guild.id)
                    emb = discord.Embed(
                        title="💸 Set Chat Money Success",
                        description=f"Chat Money Increament : {updated_guild_info['currency']['chat-min']}-{updated_guild_info['currency']['chat-max']}",
                        colour=WHITE
                        )
                    db_gld.SetObject({"guild_id": str(ctx.guild.id)}, {
                        "currency.modif-by": person.name,
                        "currency.last-modified": datetime.datetime.now().strftime('%B %d %Y')
                        })
                    await ctx.send(embed=emb)
    async def _skill_add(self, ctx: commands.Context, *args):
        mbr_data: dict = checkin_member(ctx.author)
        if mbr_data is not None:
            if "PRIM-STAT" in mbr_data:
                if len(args) == 0:
                    await self.print_skill_add_help(ctx.channel)
                else:
                    amount: int = 1  # Skill Amount
                    get_skill: str = ""
                    which: str = ""

                    # Choose Ability
                    if args[0].lower() == "str" or args[0].lower(
                    ) == "strength":
                        which = "Strength"
                        get_skill = "STR"
                    elif args[0].lower() == "end" or args[0].lower(
                    ) == "endurance":
                        which = "Endurance"
                        get_skill = "END"
                    elif args[0].lower() == "agi" or args[0].lower(
                    ) == "agility":
                        which = "Agility"
                        get_skill = "AGI"
                    elif args[0].lower() == "foc" or args[0].lower(
                    ) == "focus":
                        which = "Focus"
                        get_skill = "FOC"
                    elif args[0].lower() == "ite" or args[0].lower(
                    ) == "intelligence":
                        which = "Intelligence"
                        get_skill = "ITE"
                    elif args[0].lower() == "wis" or args[0].lower() == "wise":
                        which = "Wise"
                        get_skill = "WIS"
                    else:
                        return

                    skill_lvl: int = mbr_data["PRIM-STAT"][get_skill]
                    if len(args) >= 2:
                        if is_number(args[1]) is True:
                            amount = int(args[1])

                    # Check if Able to Upgrade
                    if mbr_data["skill-point"] < amount:
                        emb = discord.Embed(
                            title="Not Enough Skillpoint",
                            description=
                            f"You currently have {mbr_data['skill-point']} and it is not enough.",
                            colour=WHITE)
                        await ctx.send(embed=emb)
                    elif skill_lvl + amount > MAXSKILL:
                        emb = discord.Embed(
                            title="Skill Max Exceeded",
                            description=
                            f"You can't upgrade your {which} to {skill_lvl} / {MAXSKILL}",
                            colour=WHITE)
                        await ctx.send(embed=emb)

                    # Upgrade Skill
                    else:
                        db_mbr.IncreaseItem(
                            {"member_id": mbr_data["member_id"]}, {
                                "skill-point": -amount,
                                f"PRIM-STAT.{get_skill}": amount,
                            })
                        emb = discord.Embed(
                            title=
                            f"You have upgraded your {which} to {skill_lvl + amount} / {MAXSKILL}",
                            colour=WHITE)
                        await ctx.send(embed=emb)
            else:
                await ctx.send(
                    f"__**{ctx.author.name}, You haven't start your character, type {get_prefix(ctx.guild.id)}start to begin.**__"
                )
 def check_type_target(content: str):
     if is_number(content):
         if int(content) in TYPE_TARGET:
             return True
     return False
 def check_type_element(content: str):
     if is_number(content):
         if int(content) in TYPE_ELEMENT:
             return True
     return False
 def check_type_att(content: str):
     if is_number(content):
         if int(content) in TYPE_ATTACK:
             return True
     return False
    async def __make_move_process(self,
                                  channel: discord.TextChannel,
                                  person: discord.User,
                                  *,
                                  name=""):
        """Asynchronously request for detail."""

        # Inner Functions
        # Check User Inputs
        # Check Input Type Attack
        def check_type_att(content: str):
            if is_number(content):
                if int(content) in TYPE_ATTACK:
                    return True
            return False

        # Check Input Element Type
        def check_type_element(content: str):
            if is_number(content):
                if int(content) in TYPE_ELEMENT:
                    return True
            return False

        # Check Input Target Type
        def check_type_target(content: str):
            if is_number(content):
                if int(content) in TYPE_TARGET:
                    return True
            return False

        # Remove unnecessary information, for custom name and custom message
        # Any User tag will be removed from string
        def check_reply_content(content: str):
            tags = re.findall(r"<@!\d+>", content)
            if len(tags) > 0:
                for tag in tags:
                    user: discord.User = self.bot.get_user(
                        int(tag.split('!')[1][:-1]))
                    if user is not None:
                        content = content.replace(tag, user.name)
                    else:
                        content = content.replace(tag, "null")
            return content

        new_move_structure: dict = move_structure
        new_move_structure["NAME"] = check_reply_content(name)
        hm: discord.Message = await channel.send(content="Insert the name of this movement, send a message with any name." if len(name) == 0 \
            else "Insert Type Attack, send a message with number.\n[1=`Physical`, 2=`Magic`]", embed=embed_move_maker(new_move_structure))
        try:
            # if name not settled yet then request for name of move
            if len(name) == 0:
                rep: discord.Message = await self.bot.wait_for(
                    event="message",
                    timeout=40.0,
                    check=lambda message: True if channel == message.channel
                    and person == message.author else False)
                new_move_structure["NAME"] = check_reply_content(rep.content)
                await rep.delete()
                await hm.edit(
                    content=
                    "Insert Type Attack, send a message with number.\n[1=`Physical`, 2=`Magic`]",
                    embed=embed_move_maker(new_move_structure))

            # Ask for Type Attack
            rep: discord.Message = await self.bot.wait_for(
                event="message",
                timeout=40.0,
                check=lambda message: True
                if channel == message.channel and person == message.author and
                check_type_att(message.content) else False)
            new_move_structure["TYPE_ATT"] = int(rep.content)
            await rep.delete()
            await hm.edit(
                content=
                "Insert Element Type, send a message with number.\n[1=`Fire`; 2=`Water`; 3=`Earth`; 4=`Air`]",
                embed=embed_move_maker(new_move_structure))

            # Ask for Element Type
            rep: discord.Message = await self.bot.wait_for(
                event="message",
                timeout=40.0,
                check=lambda message: True
                if channel == message.channel and person == message.author and
                check_type_element(message.content) else False)
            new_move_structure["ELEMENT"] = int(rep.content)
            await rep.delete()
            await hm.edit(
                content=
                "Insert Element Type, send a message with number.\n[1=`Single Target`; 2=`Splash`]",
                embed=embed_move_maker(new_move_structure))

            # Ask for Target Type
            rep: discord.Message = await self.bot.wait_for(
                event="message",
                timeout=40.0,
                check=lambda message: True
                if channel == message.channel and person == message.author and
                check_type_target(message.content) else False)
            new_move_structure["TARGET"] = int(rep.content)
            await rep.delete()
            await hm.edit(
                content=
                "Insert message attack, this will trigger when you have used this move in battlefield."
                "You can add **<me>** as the user and **<enemy>** as the target enemy in the message. Send a message with any/multiple words.",
                embed=embed_move_maker(new_move_structure))

            # Ask for use Message
            rep: discord.Message = await self.bot.wait_for(
                event="message",
                timeout=40.0,
                check=lambda message: True if channel == message.channel and
                person == message.author else False)
            new_move_structure["ATTMSG"] = check_reply_content(rep.content)
            await rep.delete()
            await hm.edit(
                content=
                "Insert required mana to use this move, you can set it to 0. Send a message with number.",
                embed=embed_move_maker(new_move_structure))

            # Ask for required Mana amount
            rep: discord.Message = await self.bot.wait_for(
                event="message",
                timeout=40.0,
                check=lambda message: True
                if channel == message.channel and person == message.author and
                is_number(message.content) else False)
            new_move_structure["MANA"] = int(rep.content)
            await rep.delete()
            await hm.edit(
                content=
                f"Result! made by {person.name}. use command {get_prefix(channel.guild)}learn to learn a new move in this server.",
                embed=embed_move_maker(new_move_structure))

            # Save Move Data into database
            db_gld.UpdateObject(
                {"guild_id": str(channel.guild.id)},
                {"$push": {
                    "shop.movements": new_move_structure
                }})
        except asyncio.TimeoutError:
            await hm.edit(
                content="Request Timeout! Creating Move has been cancelled.")