gif loop fix
This commit is contained in:
1 parent
4d1949bdc2
commit
cc0e154385
2 files changed
+13
-5
No files matched your search
@@ -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 # total seconds — 195 frames × 100 ms
|
||||||
|
|
||||||
# ── APIs ────────────────────────────────────────────────────────────────────
|
# ── APIs ────────────────────────────────────────────────────────────────────
|
||||||
BANNER_API = "https://api.ennead.cc/buruaka/banner"
|
BANNER_API = "https://api.ennead.cc/buruaka/banner"
|
||||||
|
|||||||
+12
-5
@@ -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__)
|
||||||
|
|
||||||
@@ -258,8 +258,9 @@ class BlueArchiveGacha(commands.Cog):
|
|||||||
banner_name = f"{gtype} — {rateups}"
|
banner_name = f"{gtype} — {rateups}"
|
||||||
rates = get_rates_for_banner(banner)
|
rates = get_rates_for_banner(banner)
|
||||||
|
|
||||||
# "Opening envelope" teaser — send animation GIF
|
# "Opening envelope" teaser — send animation GIF (plays once, auto-deleted by timer)
|
||||||
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()
|
||||||
|
|
||||||
# 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:
|
||||||
@@ -311,13 +312,19 @@ class BlueArchiveGacha(commands.Cog):
|
|||||||
await ctx.reply(f"Render failed: {e}")
|
await ctx.reply(f"Render failed: {e}")
|
||||||
return
|
return
|
||||||
|
|
||||||
# Send image with spark+eligma caption
|
# Wait for the animation to finish playing, then replace with result
|
||||||
try:
|
elapsed = asyncio.get_running_loop().time() - anim_start
|
||||||
file = discord.File(img_bytes, filename="gacha_result.png")
|
remaining = GACHA_ANIM_DURATION - elapsed
|
||||||
|
if remaining > 0:
|
||||||
|
await asyncio.sleep(remaining)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await teaser.delete()
|
await teaser.delete()
|
||||||
except (discord.NotFound, discord.Forbidden):
|
except (discord.NotFound, discord.Forbidden):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
file = discord.File(img_bytes, filename="gacha_result.png")
|
||||||
await ctx.reply(
|
await ctx.reply(
|
||||||
f"Recruitment Points: {spark}/{SPARK_TARGET}{dupe_msg}",
|
f"Recruitment Points: {spark}/{SPARK_TARGET}{dupe_msg}",
|
||||||
file=file,
|
file=file,
|
||||||
|
|||||||
Reference in new issue
Block a user