Ejemplo n.º 1
0
    async def get_proposition_display(self, proposition):
        """Manage the proposition display

        @param list of dict proposition

        --

        @return str"""

        display = ""
        icon = GameIcon()

        for element in proposition:
            await asyncio.sleep(0)

            # If the element is a character, display the character name
            # level, and rarity
            if element["object"].lower() in self.short_character:
                getter = CharacterGetter()
                character_id = element["value"]

                char = await getter.get_from_unique(self.client,
                                                    self.client.database,
                                                    character_id)

                if char is not None:
                    display += f"{char.rarity.icon} **{char.name}** {char.type.icon} - lv.{char.level:,}\n"

            # If the element is zenis
            elif element["object"].lower() in self.short_zenis:
                amount = int(element["value"])
                display += f"{icon.zeni} **{amount:,}**"

        return display
Ejemplo n.º 2
0
    def __init__(self, client):
        self.client = client

        self.id = 0
        self.name = ""
        self.description = ""
        self.tooltip = ""
        self.tooltip_set = False
        self.icon = GameIcon().special_attack

        self.cost = 0
        self.cooldown = 0
        self.current_cd = 0

        self.need_target = False
        self.target_ally = False
        self.target_enemy = False
        self.target_number = 0

        self.damage_direct = 0
        self.damage_physical = 0
        self.damage_ki = 0

        self.self_heal = False
        self.heal_direct = 0
        self.heal_physical = 0
        self.heal_ki = 0

        self.ki_regen = 0

        self.apply_effect = []

        self.cleanse = False
Ejemplo n.º 3
0
    async def summon(self, context, banner_reference: int = None):

        # Log
        await self.client.logger.log(context)

        # Init
        player = Player(context, self.client, context.message.author)
        icon = GameIcon()

        # Get the banner
        if banner_reference is None:  # If the banner reference is not specified
            banner = await self.__getter.get_current_banner()

        # If the banner reference is specified
        else:
            banner = await self.__getter.get_banner(banner_reference)

        # Check if the player has enough resource to summon
        player_dargonstone = await player.resource.get_dragonstone()

        # If the player has enough to summon
        if player_dargonstone >= self.__cost and banner is not None:
            # Get the summoned character
            summoned = await banner.summon()

            # Setup the embed
            character_display = await summoned.get_display_card(self.client)
            character_display.set_thumbnail(url=player.avatar)
            character_display.description = f"Summoned from **{banner.name}** banner"

            # Remove the amount of stones used
            await player.resource.remove_dragonstone(self.__cost)

            # Add the character to the character_unique table
            await self.client.database.execute(
                """
                                               INSERT INTO character_unique(
                                               character_reference, character_owner_id, character_owner_name,
                                               character_rarity)
                                               VALUES($1, $2, $3, $4);
                                               """,
                [summoned.id, player.id, player.name, summoned.rarity.value])

            # Generate an unique id
            await banner.set_unique_id(self.client)

            # Display the card
            await context.send(embed=character_display)

            await player.experience.add_power(2)

        # If the banner has not been found
        elif banner is None:
            await context.send(f"Banner **{banner_reference:,}** not found")

        # If the player doesn't have enough resources
        else:
            await context.send(
                f"You do not have enough **Dragon stones**{icon.dragonstone} to summon"
            )
Ejemplo n.º 4
0
    def __init__(self, context, client, player):
        """
        :param context: (`discord.ext.commands.Context`)

        :param client: (`discord.ext.commands.Bot`)

        :param player: (`Player`)
        """

        # Inheritance
        Capsule.__init__(self, context, client, player)

        # Public
        self.reference = 0
        self.name = "Normal Capsule"
        self.icon = GameIcon().capsule_0

        # Rewards
        self.dragonstone = 5000
        self.zeni = 150000
        self.item = [Sword0]

        # Rates
        self.rate_item = 20
        self.rate_dragonstone = 50
        self.rate_zeni = 100
Ejemplo n.º 5
0
    def __init__(self, client):
        # Public
        self.client = client

        # Private
        self.__database = self.client.database
        self.__icon = GameIcon()
Ejemplo n.º 6
0
    def __init__(self, client):
        """
        :param client: (`discord.ext.commands.Bot`)
        """

        # Inheritance
        TrainingItem.__init__(self, client)

        # Public
        self.reference = 0
        self.name = "Z-Sword lv.1"
        self.icon = GameIcon().sword_0
Ejemplo n.º 7
0
    async def on_dbl_test(self, data):
        """Triggered when a vote is cast on top.gg

        @param data - `dict`

        @return - `None`"""

        weekend = data["isWeekend"]
        icon = GameIcon()
        user_id = int(data["user"])
        user = await self.client.fetch_user(user_id)

        # Rewards
        reward_ds = 25
        reward_zenis = 1000
        reward_power = 100

        # If it's weekend, rewards are doubled
        if weekend:
            reward_ds *= 2
            reward_zenis *= 2
            reward_power *= 2

        player = Player(None, self.client, user)

        if player is not None:
            # Sends rewards to the player
            await player.resource.add_dragonstone(reward_ds)
            await player.resource.add_zeni(reward_zenis)
            await player.experience.add_power(reward_power)

            # Send dm
            try:
                await user.send(
                    f"Thanks for voting ! Here are **{reward_ds}**{icon.dragonstone}, as well as **{reward_zenis}**{icon.zeni} and **{reward_power}**:star:"
                )

            except discord.Forbidden:
                print(
                    f"Failed to send reward message to {user_id} : Permission denied"
                )
                pass

            except discord.HTTPException:
                print(f"Failed to send reward message to {user_id}")
                pass

            else:
                pass

        return
Ejemplo n.º 8
0
    def __init__(self, context, client, player):
        """:param context: (`discord.ext.commands.Context`)
           
           :param client: (`discord.ext.commands.Bot`)

           :param player: (`Player`)"""

        # Public
        self.client = client
        self.context = context
        self.player = player
        self.game_icon = GameIcon()

        # Info
        self.name = ""
        self.icon = ""
        self.reference = 0
        self.unique_id = ""

        # Rewards
        self.dragonstone = 0
        self.zeni = 0
        self.experience = 0
        self.item = []

        # Rate
        # As %
        # One of the rates must be 100 as we eliminate
        self.rate_dragonstone = 0
        self.rate_zeni = 0
        self.rate_experience = 0
        self.rate_item = 0

        # Reward gap
        self.reward_gap = 0.9  # 10 %

        # Private
        self.__database = self.client.database
        self.__global_tool = GlobalTool()

        # Generation %
        self.__gen_n = 100
        self.__gen_r = 66
        self.__gen_sr = 33
        self.__gen_ssr = 16.5
        self.__gen_ur = 8.25
        self.__gen_lr = 3
Ejemplo n.º 9
0
    async def get_player_proposition(self, context, player):
        """Get the player's get_proposition

        @param discord.ext.commands.Context

        @param Player player

        --

        @return list of dict or None"""

        # Stores the proposed items by the player
        proposition = []
        input = MessageInput(self.client)
        icon = GameIcon()

        z = icon.zeni

        # Stores error
        error = ""

        # Checkers
        total_zenis = 0

        player_input = await input.get_input(player)

        if player_input is not None:
            player_input = player_input.content

            # Get a list of string
            player_input = player_input.split()
            max_length = 10
            length = len(player_input)

            if length > max_length:
                length = max_length

            # Retrieve the input data
            # step : 2
            for i in range(0, length, 2):
                await asyncio.sleep(0)

                # Get the object data
                object = player_input[i]
                value = None

                # Avoid out of range error
                if i + 1 <= len(player_input) - 1:
                    value = player_input[i + 1]

                if value is not None:
                    # Generate current dict
                    current = {"object": object, "value": value}

                else:
                    return None

                # Check the characters
                if current["object"].lower() in self.short_character:
                    # Check if the player owns the character
                    owns = await player.item.has_character(current["value"])

                    # If the player owns the character, add it to the
                    # proposition
                    if owns:
                        proposition.append(current)

                    else:
                        char = current["value"]
                        error += f"- You do not own the character `{char}` or this character is not tradable\n"

                # Check if it's zenis
                elif current["object"].lower() in self.short_zenis:
                    # Convert the current value to int
                    value = int(current["value"])

                    # Check if the player has enough funds
                    player_zenis = await player.resource.get_zeni()

                    # If the value is not negative
                    if value > 0:
                        # If the player has enough zenis
                        if (player_zenis >= value
                                and player_zenis >= total_zenis):
                            # Update the value
                            total_zenis += value
                            proposition.append(current)

                        else:
                            error += f"- You do not have {z} **{value:,}**\n"
                    # Negative value
                    else:
                        error += "- You provided a negative value"

        # No input provided
        else:
            return

        # Send error message
        if error != "":
            await context.send(
                f"<@{player.id}> Your proposition contains errors :\n{error}")

        return proposition
Ejemplo n.º 10
0
 def __init__(self, client):
     self.client = client
     self.i = GameIcon()
Ejemplo n.º 11
0
    async def hourly(self, context):
        # Log
        await self.client.logger.log(context)

        # Init
        player = Player(context, self.client, context.message.author)

        premium_bonus = await self.global_tool.get_player_premium_resource_bonus(
            player)
        current_time = time.time()
        icon = GameIcon()

        # Get the player's last hourly
        player_hourly = await player.time.get_hourly()

        # If there is more than 1 hour between the current time and the player's
        # last hourly : do the hourly
        # The player has 1h59 to do his hourly to gain a combo point
        elapsed = current_time - player_hourly

        # If an hour has passed
        # Time is in seconds
        if elapsed >= self.__time_hourly:
            # Init
            combo = 0

            # The player is on a combo streak
            if elapsed < self.__time_combo:
                # Get the combo value
                combo = await player.time.get_hourly_combo()

                # Increase the combo
                combo += 1

            # Get the rewards value
            reward_ds = int(self.__dragonstone *
                            pow(self.__combo_rate, combo) * premium_bonus)
            reward_zeni = int(self.__zeni * pow(self.__combo_rate, combo) *
                              premium_bonus)
            reward_xp = int(self.__experience * pow(self.__combo_rate, combo) *
                            premium_bonus)

            # Update the player_time table
            # Time
            await player.time.update_hourly_time(current_time)

            # Combo
            await player.time.update_hourly_combo(combo)

            # Update the player resources
            await player.resource.add_dragonstone(reward_ds)
            await player.resource.add_zeni(reward_zeni)

            # Rewarding message
            message = f"""
Hourly : **+{reward_ds:,}**{icon.dragonstone}, **+{reward_zeni:,}**{icon.zeni}, **+{reward_xp:,}**:star: 
*(Combo **x{combo}**)*"""

            # Add power points
            await player.experience.add_power(3)

            await context.send(message)

        # Not the time yet
        else:
            time_remaining = self.__time_hourly - elapsed

            # Get the string that tells when the player has to come back
            come_back = await self.__tool_time.convert_time(time_remaining)

            await context.send(
                f"It's to early for this, come back in **{come_back}**")
Ejemplo n.º 12
0
    async def send_rewards(self, context, player):
        """Send the mission rewards to the player

        @param discord.ext.commands.Context context

        @param Player player

        --

        @return str"""

        rewards = ""
        premium_bonus = await self.global_tool.get_player_premium_resource_bonus(
            player)
        character_exp = CharacterExperience(self.client)
        icon = GameIcon()

        # Rewards
        r_exp = self.experience
        r_zenis = self.zenis
        r_dragonstone = self.dragonstone

        # Reducing the reward according to the player's team level
        average_level = await player.combat.get_average_team_level()
        reward_reduction = 1  # If it reaches 0, the player doesn't get anything

        # Every 5 level gap, reduce the rewards by 25 % (reward_reduction - 0.25)
        gap = average_level - self.opponent_lvl

        if gap > 0:
            # Reduce the rewards by 25 % every 5 lvl gap
            reward_reduction -= 0.25 * int(gap / 5)

            if reward_reduction < 0:
                reward_reduction = 0

        # Update rewards
        r_exp = int((self.experience * reward_reduction) * premium_bonus)
        r_zenis = int((self.zenis * reward_reduction) * premium_bonus)
        r_dragonstone = int(
            (self.dragonstone * reward_reduction) * premium_bonus)
        await player.experience.add_power(int(5 * reward_reduction))

        if reward_reduction == 0:
            self.capsule = None

        # Add xp to the player's characters
        if self.experience is not None:
            rewards += f"**{r_exp:,}**xp | "

            player_team = player.combat.unique_id_team
            for character in player_team:
                await asyncio.sleep(0)

                await character_exp.add_experience(character, r_exp)

        if self.dragonstone is not None:
            rewards += f"**{r_dragonstone:,}** {icon.dragonstone} | "

            await player.resource.add_dragonstone(r_dragonstone)

        if self.zenis is not None:
            rewards += f"**{r_zenis:,}** {icon.zeni} | "

            await player.resource.add_zeni(r_zenis)

        if self.capsule is not None:
            capsule = Capsule(context, self.client, player)
            capsule = await capsule.get_capsule_by_reference(self.capsule)

            rewards += f"**{capsule.name}** {capsule.icon}"

            await player.item.add_capsule(self.capsule)

        return rewards
Ejemplo n.º 13
0
    async def multisummon(self, context):
        """Allows the player to do a multisummon"""

        # Log
        await self.client.logger.log(context)

        # Init
        player = Player(context, self.client, context.message.author)
        icon = GameIcon()
        color = GameColor()

        # Check if the player has enough resource to proceed
        # a multisummon
        player_ds = await player.resource.get_dragonstone()
        banner = await self.__getter.get_current_banner()

        if player_ds >= self.__cost * 10:
            summoned = await banner.multi_summon()
            summon_content = ""

            high_rarity = summoned[0].rarity.value
            for character in summoned:
                await asyncio.sleep(0)

                if character.rarity.value > high_rarity:
                    high_rarity = character.rarity.value

                summon_content += f"`#{character.id}`- {character.rarity.icon} **{character.name}**\n"

                await self.client.database.execute(
                    """
                                                   INSERT INTO character_unique(
                                                   character_reference, character_owner_id, character_owner_name,
                                                   character_rarity)
                                                   VALUES($1, $2, $3, $4);
                                                   """, [
                        character.id, player.id, player.name,
                        character.rarity.value
                    ])

            summon_color = await color.get_rarity_color(high_rarity)

            embed = await CustomEmbed().setup(
                self.client,
                title=f"{player.name}'s multi summon",
                color=summon_color,
                thumbnail_url=player.avatar)

            embed.add_field(name="Content :",
                            value=summon_content,
                            inline=False)

            await context.send(embed=embed)

            # Remove resource
            await player.resource.remove_dragonstone(self.__cost * 10)

            # Generate an unique id
            await banner.set_unique_id(self.client)

            await player.experience.add_power(20)

        else:
            await context.send(
                f"You do not have enough **Dragon stones**{icon.dragonstone} to summon"
            )
Ejemplo n.º 14
0
 def __init__(self, client):
     self.client = client
     self.icon = GameIcon()
     self.tool = GlobalTool()
     self.rarity = ['n', 'r', "sr", "ssr", "ur", "lr"]