diff --git a/ballsdex/core/image_generator/image_gen.py b/ballsdex/core/image_generator/image_gen.py index b10264d5..0c7ea40a 100755 --- a/ballsdex/core/image_generator/image_gen.py +++ b/ballsdex/core/image_generator/image_gen.py @@ -30,6 +30,8 @@ def draw_card(ball_instance: "BallInstance"): ball = ball_instance.countryball ball_health = (237, 115, 101, 255) + extra_data = ball_instance.extra_data or {} + if ball_instance.shiny: image = Image.open(str(SOURCES_PATH / "shiny.png")) ball_health = (255, 255, 255, 255) @@ -84,18 +86,22 @@ def draw_card(ball_instance: "BallInstance"): stroke_fill=(0, 0, 0, 255), anchor="ra", ) + ball_credits = extra_data.get("credits", ball.credits) # type: ignore draw.text( (30, 1870), # Modifying the line below is breaking the licence as you are removing credits # If you don't want to receive a DMCA, just don't - "Created by El Laggron\n" f"Artwork author: {ball.credits}", + "Created by El Laggron\n" f"Artwork author: {ball_credits}", font=credits_font, fill=(0, 0, 0, 255), stroke_width=0, stroke_fill=(255, 255, 255, 255), ) - artwork = Image.open("." + ball.collection_card).convert("RGBA") + if extra_data.get("card"): # type: ignore + artwork = Image.open("." + extra_data["card"]).convert("RGBA") # type: ignore + else: + artwork = Image.open("." + ball.collection_card).convert("RGBA") image.paste(ImageOps.fit(artwork, artwork_size), CORNERS[0]) # type: ignore if icon: diff --git a/ballsdex/core/models.py b/ballsdex/core/models.py index b86ce778..a6225b14 100755 --- a/ballsdex/core/models.py +++ b/ballsdex/core/models.py @@ -272,6 +272,8 @@ def to_string(self, bot: discord.Client | None = None, is_trade: bool = False) - emotes += " " if self.specialcard: emotes += self.special_emoji(bot) + if self.extra_data.get("card"): # type: ignore + emotes += "🖼️" country = ( self.countryball.country if isinstance(self.countryball, Ball) diff --git a/ballsdex/packages/balls/countryballs_paginator.py b/ballsdex/packages/balls/countryballs_paginator.py index 52eb4b41..0d2a1f99 100644 --- a/ballsdex/packages/balls/countryballs_paginator.py +++ b/ballsdex/packages/balls/countryballs_paginator.py @@ -35,9 +35,13 @@ def set_options(self, balls: List[BallInstance]): favorite = "❤️ " if ball.favorite else "" shiny = "✨ " if ball.shiny else "" special = ball.special_emoji(self.bot, True) + custom_art = "🖼️" if "card" in ball.extra_data else "" options.append( discord.SelectOption( - label=f"{favorite}{shiny}{special}#{ball.pk:0X} {ball.countryball.country}", + label=( + f"{favorite}{shiny}{custom_art}{special}" + f"#{ball.pk:0X} {ball.countryball.country}" + ), description=( f"ATK: {ball.attack}({ball.attack_bonus:+d}%) " f"• HP: {ball.health}({ball.health_bonus:+d}%) • " diff --git a/ballsdex/packages/countryballs/components.py b/ballsdex/packages/countryballs/components.py index ed8a0a0e..d87568f5 100755 --- a/ballsdex/packages/countryballs/components.py +++ b/ballsdex/packages/countryballs/components.py @@ -3,6 +3,7 @@ import logging import math import random +from datetime import datetime from typing import TYPE_CHECKING, cast import discord @@ -87,6 +88,12 @@ async def on_submit(self, interaction: discord.Interaction["BallsDexBot"]): special += f"✨ ***It's a shiny {settings.collectible_name}!*** ✨\n" if ball.specialcard and ball.specialcard.catch_phrase: special += f"*{ball.specialcard.catch_phrase}*\n" + date = datetime.now().strftime("%m-%d") + if date in self.ball.model.capacity_logic: + capacity = self.ball.model.capacity_logic[date] # type: ignore + if "catch" in capacity: + catch = capacity["catch"] + special += f"{catch}\n" if has_caught_before: special += ( f"This is a **new {settings.collectible_name}** " @@ -137,6 +144,11 @@ async def catch_ball( special = random.choices(population=population + [None], weights=weights, k=1)[0] is_new = not await BallInstance.filter(player=player, ball=self.ball.model).exists() + date = datetime.now().strftime("%m-%d") + if date in self.ball.model.capacity_logic: + extra_data = self.ball.model.capacity_logic[date] # type: ignore + else: + extra_data = {} ball = await BallInstance.create( ball=self.ball.model, player=player, @@ -146,6 +158,7 @@ async def catch_ball( health_bonus=bonus_health, server_id=user.guild.id, spawned_time=self.ball.time, + extra_data=extra_data, ) if user.id in bot.catch_log: log.info( diff --git a/ballsdex/packages/countryballs/countryball.py b/ballsdex/packages/countryballs/countryball.py index a647385e..88d01139 100755 --- a/ballsdex/packages/countryballs/countryball.py +++ b/ballsdex/packages/countryballs/countryball.py @@ -54,8 +54,14 @@ def generate_random_name(): source = string.ascii_uppercase + string.ascii_lowercase + string.ascii_letters return "".join(random.choices(source, k=15)) - extension = self.model.wild_card.split(".")[-1] - file_location = "." + self.model.wild_card + date = datetime.now().strftime("%m-%d") + extra_logic = self.model.capacity_logic.get(date, {}) # type: ignore + if extra_logic.get("spawn"): # special image + extension = extra_logic["spawn"].split(".")[-1] + file_location = "." + extra_logic["spawn"] + else: + extension = self.model.wild_card.split(".")[-1] + file_location = "." + self.model.wild_card file_name = f"nt_{generate_random_name()}.{extension}" try: permissions = channel.permissions_for(channel.guild.me) diff --git a/ballsdex/packages/trade/menu.py b/ballsdex/packages/trade/menu.py index 7f1d50e3..553ed8bc 100644 --- a/ballsdex/packages/trade/menu.py +++ b/ballsdex/packages/trade/menu.py @@ -401,9 +401,13 @@ def set_options(self, balls: List[BallInstance]): favorite = "❤️ " if ball.favorite else "" shiny = "✨ " if ball.shiny else "" special = ball.special_emoji(self.bot, True) + custom_art = "🖼️" if "card" in ball.extra_data else "" options.append( discord.SelectOption( - label=f"{favorite}{shiny}{special}#{ball.pk:0X} {ball.countryball.country}", + label=( + f"{favorite}{shiny}{custom_art}{special}" + f"#{ball.pk:0X} {ball.countryball.country}" + ), description=f"ATK: {ball.attack_bonus:+d}% • HP: {ball.health_bonus:+d}% • " f"Caught on {ball.catch_date.strftime('%d/%m/%y %H:%M')}", emoji=emoji,