Beispiel #1
0
    async def profile(self, ctx):
        """
        Call the player's profile.
        """

        # init
        # player
        player = Player(ctx, self.client, ctx.message.author)
        await player.resource.update()  # update the resources count
        char_amount = await player.box.get_characters_amount()
        # embed
        profile_embed = await Custom_embed(
            self.client, thumb=player.avatar,
            title=f"{player.name}'s profile").setup_embed()

        # prepare the embed
        profile_embed.add_field(name=":star: Level", value=0, inline=True)

        profile_embed.add_field(
            name=f"{game_icon['dragonstone']} Dragon stone",
            value=f"{player.resource.dragonstone:,}",
            inline=True)

        profile_embed.add_field(name=f"{game_icon['zenis']} Zenis",
                                value=f"{player.resource.zenis:,}",
                                inline=True)

        profile_embed.add_field(name=":trophy: Collection",
                                value=f"{char_amount:,}",
                                inline=True)

        # display the profile
        await ctx.send(embed=profile_embed)
Beispiel #2
0
    async def mission(self, ctx, choice = None):
        """
        Allow the player to display the mission panel

        Or to start a mission if the `choice` parameter is != `None`

        - Parameter :

        `choice` (`int`) : Mission index
        """

        # init
        player = Player(ctx, self.client, ctx.message.author)
        mission = Mission_manager()
        embed = await Custom_embed(
            self.client, title = "Missions", description = "Welcome to the Missions panel"
        ).setup_embed()    
        
        # start mission
        if(choice != None):
            if(choice.isdigit()):
                choice = int(choice)
                await mission.start_mission(ctx, self.client, player, choice)

        else:
            # display the missions panel
            pass
Beispiel #3
0
    async def basic(self, ctx):
        """
        Summon a character from the basic banner.
        """

        # init
        player = Player(ctx, self.client, ctx.message.author)
        summoner = Summoner(self.client)
        displayer = Character_displayer(self.client, ctx, player)

        # get player's resource
        await player.resource.update()

        if (player.resource.dragonstone >= self.cost["basic"]):
            # draw
            drawn_character = await summoner.summon(player, _type="basic")
            await drawn_character.init()

            # display
            displayer.character = drawn_character
            await displayer.display(summon_format=True)

            # apply the cost
            await player.resource.remove_dragonstone(self.cost["basic"])

        else:
            await ctx.send(
                f"<@{player.id}> You do not have enough **Dragon Stones**{game_icon['dragonstone']} to summon ({player.resource.dragonstone:,} / {self.cost['basic']:,})."
            )

        return
Beispiel #4
0
    async def start(self, ctx):
        """
        Allow the player to start an adventure.
        """

        # init
        db = Database(self.client.db)
        player = Player(ctx, self.client, ctx.message.author)
        summoner = Summoner(self.client)

        # insert the player into the tables
        await db.execute(
            """INSERT INTO player_info(player_id, player_name, player_register_date) VALUES ($1, $2, $3)""",
            (player.id, player.name, time.strftime("%d/%m/%y", time.gmtime())))
        await db.execute(
            """INSERT INTO player_resource(player_id, player_name, player_dragonstone) VALUES ($1, $2, 25)""",
            (
                player.id,
                player.name,
            ))
        await db.execute(
            """INSERT INTO player_combat_info(player_id, player_name) VALUES ($1, $2)""",
            (
                player.id,
                player.name,
            ))

        # generate 3 saibaiman
        for i in range(3):
            await db.execute(
                """
                            INSERT INTO character_unique(character_owner_id, character_owner_name, character_global_id, 
                            character_type, character_rarity)
                            VALUES($1, $2, $3, $4, 0)""",
                [player.id, player.name, (i + 1),
                 random.randint(0, 4)])

        await summoner.set_unique_id()

        # get the summoned characters
        summoned = await db.fetch(f"""
            SELECT character_unique_id FROM character_unique WHERE character_owner_id = {player.id};
            """)

        # assign summoned character
        slot = ["a", "b", "c"]

        for a in range(3):
            await asyncio.sleep(0)

            await db.execute(f"""
                UPDATE player_combat_info 
                SET player_fighter_{slot[a]} = '{summoned[a][0]}'
                WHERE player_id = {player.id};
                """)

        # welcome message
        welcome = f"<@{player.id}> Hello and welcome to **Discord Ball Z III** - *Open Beta* !\nWe're hoping you to enjoy your adventure !\n\nHere are **25**{game_icon['dragonstone']}, they will help you to **summon** your first heroes that will fight for you !\n\nIf you have any question, do not hesitate to consult the `d!help` command or join the **Official Server** : https://discord.gg/eZf2p7h"

        await ctx.send(welcome)
Beispiel #5
0
    async def help(self, ctx, command=None):
        """
        Displays the help.

        - Parameter : 

        `command` (str) : The name of the command which the user wants to see the help.
        """

        # init
        player = Player(ctx, self.client, ctx.message.author)
        helper = Helper(self.client, ctx, player)

        if (command == None):
            await helper.helper_manager()

        else:
            help_panel = await helper.get_help_command(command)

            if not help_panel is None:
                await helper.display_help(help_panel)

            else:
                await ctx.send(
                    f"Sorry, the help panel for the command `{command}` has not been found."
                )
Beispiel #6
0
    async def c(self, ctx, character_id):
        """
        Set the fighter slot c
        """

        # init
        player = Player(ctx, self.client, ctx.message.author)
        fighter = Fighter(ctx, self.client, player)

        await fighter.fighter_command("c", character_id)
Beispiel #7
0
    async def box(self, ctx, character_id: int = None):
        """
        Displays the player's box

        - Parameter :

        `character_id` : Represents the character global id to display.
        """

        # init
        player = Player(ctx, self.client, ctx.message.author)

        # box
        await player.box.manager(character_id=character_id)
Beispiel #8
0
    async def show(self, ctx, character_id, level=None):
        """
        Allow the player to see a character's stats and abilities by passing its global id.

        If a unique id is passed, displays the unique character.
        """

        # init
        player = Player(ctx, self.client, ctx.message.author)
        character_getter = Character_getter()
        displayer = Character_displayer(self.client, ctx, player)

        if (level != None):
            if (level.isdigit()):
                level = int(level)

                if (level > 150):
                    level = 150

            else:
                level = None

        # global id
        if (character_id.isdigit()):
            character_id = int(character_id)
            character = await character_getter.get_character(character_id)

            if (character != None):
                displayer.character = character

                await displayer.display(basic_format=True, level=level)

            else:
                await ctx.send(
                    f"<@{player.id}> Character `#{character_id}` not found.")

        # unique id
        else:
            character = await character_getter.get_from_unique(
                self.client, character_id)

            if (character != None):
                displayer.character = character

                await displayer.display(basic_format=True, level=level)

            else:
                await ctx.send(
                    f"<@{player.id}> Character `#{character_id}` not found.")
Beispiel #9
0
    async def fight(self, ctx):
        """
        Allow the player to reset its `in_fight` status
        """

        # init
        player = Player(ctx, self.client, ctx.message.author)
        checker = Fight_checker()

        # check if the player is in a fight
        if player.id in checker.in_fight:
            checker.in_fight.remove(player.id)

            await ctx.send("You are no longer in a fight.")

        else:
            await ctx.send("You're not in a fight.")
Beispiel #10
0
    async def has_team(self, ctx):
        """
        `coroutine`

        Check if the player has set a team or not

        --

        Return : bool
        """

        # init
        player = Player(ctx, ctx.bot, ctx.message.author)
        getter = Character_getter()
        player_team = await player.team.get_team()
        has_fighter = False

        # check if the player has setted up fighters
        if(type(player_team["a"]) == str):
            fighter = await getter.get_from_unique(ctx.bot, player_team["a"])  # check if the fighter exists
            if(fighter != None):
                has_fighter = True
        
        if(type(player_team["b"]) == str):
            fighter = await getter.get_from_unique(ctx.bot, player_team["b"])
            if(fighter != None):
                has_fighter = True
            
        if(type(player_team["c"]) == str):
            fighter = await getter.get_from_unique(ctx.bot, player_team["c"])
            if(fighter != None):
                has_fighter = True

        if not has_fighter:
            await ctx.send(f"<@{player.id}> You did not **set any fighter**, in consequence to it, you cannot use this command.\nUse `d!fighter` for more informations.")

        return(has_fighter)
Beispiel #11
0
    async def remove(self, ctx, slot):
        """
        Allows the player to remove a character from a slot.
        """

        # init
        player = Player(ctx, self.client, ctx.message.author)
        player_team = await player.team.get_team()
        getter = Character_getter()
        possible_slot = ["a", "b", "c"]


        # remove the slot
        if slot.lower() in possible_slot:
            await player.team.remove(slot)
            removed_character = await getter.get_from_unique(self.client, player_team[slot])
            await removed_character.init()

            await ctx.send(f"<@{player.id}> You have successfully removed {removed_character.image.icon}**{removed_character.info.name}** {removed_character.type.icon}{removed_character.rarity.icon} from the slot **{slot.upper()}**.")

        else:  # unexisting slot
            await ctx.send(f"<@{player.id}> Slot **{slot.upper()}** not found.")

        return
Beispiel #12
0
    async def fighter_command(self, slot, character_id):
        """
        Allow the player to select the fighter to set

        `character_id` : int - Represents the character to display
        """

        # init
        player = Player(self.ctx, self.client, self.ctx.message.author)
        tool = Fighter(self.ctx, self.client, player)

        # if a global id is passed
        if(character_id.isdigit()):
            box_data = await player.box.get_data(character_id)
            character_id = int(character_id)
            
            # ask the player to pick the id of his character
            explanation = await self.ctx.send(f"<@{player.id}> Please select a fighter among the following.\n**Close the box** (`❌`) once you have chosen your character, then, **type its index** number :")

            # display the available characters
            await player.box.manager(character_id)

            # ask for choice
            unique_id = await tool.wait_for_fighter_index(box_data)
            if(unique_id == None):
                await self.ctx.send(f"<@{player.id}> Error : character not found.")
                return

            character = await self.getter.get_from_unique(self.client, unique_id)
            await character.init()

            # set the fighter
            possible = await player.team.set_fighter(slot, unique_id)

            if(possible == False):  # the character is already in the team
                await self.ctx.send(f"<@{player.id}> You already have a {character.image.icon}**{character.info.name}** in your team. **Remove** it or choose a different character.")
            
            else:
                # confirm
                await self.ctx.send(f"<@{player.id}> You have successfully set {character.image.icon}**{character.info.name}** {character.type.icon}{character.rarity.icon} lv.{character.level:,} as **fighter {slot.upper()}** !")
            
            await explanation.delete()
        
        else:  # if the character_id is a unique id
            db = Database(self.client.db)
            # check if the player has the character
            owns_character = await db.fetchval(f"SELECT character_owner_name FROM character_unique WHERE character_unique_id = '{character_id}' AND character_owner_id = {player.id};")

            if(owns_character != None):
                character = await self.getter.get_from_unique(self.client, character_id)

                if(character == None):
                    await self.ctx.send(f"<@{player.id}> Character with unique id \"{character_id}\" not found. Please try with another id.\nYou can find your character's unique id by using `d!box [character id]`. The **unique id** format is `aaaa0`.")
                
                else:  # the character has been found
                    await character.init()

                    # set the fighter
                    possible = await player.team.set_fighter(slot, character_id)

                    if(possible == False):  # the character is already in the team
                        await self.ctx.send(f"<@{player.id}> You already have a {character.image.icon}**{character.info.name}** in your team. **Remove** it or choose a different character.")
                
                    else:
                        # confirm
                        await self.ctx.send(f"<@{player.id}> You have successfully set {character.image.icon}**{character.info.name}** {character.type.icon}{character.rarity.icon} lv.{character.level:,} as **fighter {slot.upper()}** !")
                
            else:  # doesn't own the character
                await self.ctx.send(f"<@{player.id}> Character `{character_id}` not found.")
                return
Beispiel #13
0
    async def team(self, ctx):
        """
        Displays the player's team.
        """

        # init
        player = Player(ctx, self.client, ctx.message.author)
        player_team = await player.team.get_team()
        player_team_info = await player.team.get_info()
        embed = await Custom_embed(self.client).setup_embed()

        char_a, char_b, char_c = None, None, None

        # set the info icon
        player_team_info["rarity"] = await self.icon.get_rarity_icon(player_team_info["rarity"])

        # set the player team display
        ### a 
        if(player_team["a"] == None):
            player_team["a"] = "--"
        
        else:
            char_a = await self.getter.get_from_unique(self.client, player_team["a"])
            char_a = f"`{player_team['a']}` | {char_a.image.icon}{char_a.info.name} {char_a.type.icon}{char_a.rarity.icon} lv.{char_a.level:,}"
        
        ### b
        if(player_team["b"] == None):
            player_team["b"] = "--"
        
        else:
            char_b = await self.getter.get_from_unique(self.client, player_team["b"])
            char_b = f"`{player_team['b']}` | {char_b.image.icon}{char_b.info.name} {char_b.type.icon}{char_b.rarity.icon} lv.{char_b.level:,}" 
        
        ### c
        if(player_team["c"] == None):
            player_team["c"] = "--"
        
        else:
            char_c = await self.getter.get_from_unique(self.client, player_team["c"])
            char_c = f"`{player_team['c']}` | {char_c.image.icon}{char_c.info.name} {char_c.type.icon}{char_c.rarity.icon} lv.{char_c.level:,}"

        # set display
        display_infos = f"""
        *Average level* : {player_team_info['level']}
        *Average rarity* : {player_team_info['rarity']}
        """

        display_character = f"""
        A : **{char_a}** 👑
        B : **{char_b}**
        C : **{char_c}**
        """

        # set the embed
        embed.set_thumbnail(url = player.avatar)
        embed.add_field(
            name = f"{player.name}'s team",
            value = display_infos,
            inline = False
        )

        embed.add_field(
            name = "Fighters",
            value = display_character,
            inline = False
        )

        await ctx.send(embed = embed)
Beispiel #14
0
    async def train(self, ctx):
        """
        `coroutine`

        Start a fight against an adaptative team.

        The opponent team level is scaled on the player team level, same for the rarity.

        If the player wins the fight, his character gain some xp.
        """

        # init
        caller = ctx.message.author
        player = Player(ctx, self.client, caller)
        getter = Character_getter()
        tool = Train(self.client)
        leveller = Leveller(self.client, ctx)

        # get caller team
        caller_team = await player.team.get_team()
        player_team = [
            await getter.get_from_unique(self.client, caller_team["a"]), await
            getter.get_from_unique(self.client, caller_team["b"]), await
            getter.get_from_unique(self.client, caller_team["c"])
        ]

        # get opponent team
        opponent_team = await tool.generate_opponent_team(player)

        # test
        opponent_team = [
            await getter.get_character(1), await getter.get_character(2), await
            getter.get_character(3)
        ]

        for char in opponent_team:
            await asyncio.sleep(0)

            char.is_npc = True

        ############ end test ########

        team = [player_team, opponent_team]

        fight = Fight(self.client, ctx, player)

        await ctx.send(f"<@{player.id}> You enter in combat.")

        winner = await fight.run_fight(team)

        # redefine team
        caller_team = await player.team.get_team()

        # check winning condition
        id_team = [caller_team["a"], caller_team["b"], caller_team["c"]]

        # set the xp
        # init
        xp_won = 100
        player_info = await player.team.get_info()
        player_team_level, player_team_rarity = player_info[
            "level"], player_info["rarity"]

        # set the xp gain
        xp_won += (((1.5 * 100) - 100) *
                   player_team_level) + (100 * (player_team_rarity - 1))

        if (winner == 0):  # if the player wins it
            # add xp
            await leveller.team_add_xp(player, id_team, xp_won)

        elif (winner == 2):  # if draw
            # half xp gained
            await leveller.team_add_xp(player, team, xp_won / 2)