added frame counter to gif

This commit is contained in:
esef committed 2026-07-12 17:14:40 +03:00
1 parent 79555de939
commit a59ffac93c
2 files changed
+12 -1

No files matched your search

+1
View File
@@ -9,6 +9,7 @@ BANNER_FILE = Path("data/ba_banner_state.json")
ASSETS_DIR = Path(__file__).parent / "assets" ASSETS_DIR = Path(__file__).parent / "assets"
BG_PATH = ASSETS_DIR / "gacha_bg.png" BG_PATH = ASSETS_DIR / "gacha_bg.png"
GACHA_ANIM_PATH = ASSETS_DIR / "Arona_Blue_Gacha_Animation.gif" GACHA_ANIM_PATH = ASSETS_DIR / "Arona_Blue_Gacha_Animation.gif"
GACHA_ANIM_DURATION = 19.5 # 195 frames × 100 ms
# ── APIs ──────────────────────────────────────────────────────────────────── # ── APIs ────────────────────────────────────────────────────────────────────
BANNER_API = "https://api.ennead.cc/buruaka/banner" BANNER_API = "https://api.ennead.cc/buruaka/banner"
+11 -1
View File
@@ -19,7 +19,7 @@ from .data import (
get_rates_for_banner, get_rates_for_banner,
) )
from .gacha_renderer import render_pull from .gacha_renderer import render_pull
from .constants import SPARK_TARGET, BANNER_FILE, DEFAULT_RATES, PULL10_RATES, GACHA_ANIM_PATH from .constants import SPARK_TARGET, BANNER_FILE, DEFAULT_RATES, PULL10_RATES, GACHA_ANIM_PATH, GACHA_ANIM_DURATION
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@@ -261,8 +261,11 @@ class BlueArchiveGacha(commands.Cog):
# "Opening envelope" teaser — animation GIF, or text fallback # "Opening envelope" teaser — animation GIF, or text fallback
if GACHA_ANIM_PATH.exists(): if GACHA_ANIM_PATH.exists():
teaser = await ctx.reply(file=discord.File(str(GACHA_ANIM_PATH))) teaser = await ctx.reply(file=discord.File(str(GACHA_ANIM_PATH)))
anim_start = asyncio.get_running_loop().time()
is_gif = True
else: else:
teaser = await ctx.reply("Opening recruitment envelope" + ("s..." if count > 1 else "...")) teaser = await ctx.reply("Opening recruitment envelope" + ("s..." if count > 1 else "..."))
is_gif = False
# Build the banner-specific character pool # Build the banner-specific character pool
if banner_id and banner_id != "regular" and banner: if banner_id and banner_id != "regular" and banner:
@@ -314,6 +317,13 @@ class BlueArchiveGacha(commands.Cog):
await ctx.reply(f"Render failed: {e}") await ctx.reply(f"Render failed: {e}")
return return
# If we showed the GIF, wait for it to finish playing before replacing
if is_gif:
elapsed = asyncio.get_running_loop().time() - anim_start
remaining = GACHA_ANIM_DURATION - elapsed
if remaining > 0:
await asyncio.sleep(remaining)
# Send image with spark+eligma caption # Send image with spark+eligma caption
try: try:
file = discord.File(img_bytes, filename="gacha_result.png") file = discord.File(img_bytes, filename="gacha_result.png")