From 4fc9f5e5f2ddd649fb48fc362f1c4fa676040f12 Mon Sep 17 00:00:00 2001 From: Ice9Coffee <438971718@qq.com> Date: Fri, 5 Jun 2026 11:54:56 +0800 Subject: [PATCH 1/3] Make card-long loading fall back when selected asset is missing --- NTEUID/utils/image.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/NTEUID/utils/image.py b/NTEUID/utils/image.py index 47be647..2efd100 100644 --- a/NTEUID/utils/image.py +++ b/NTEUID/utils/image.py @@ -337,8 +337,9 @@ def get_nte_title_bg(width: int, height: int, *, game: str = "yihuan") -> Image. def _load_card_long(card_long_id: str | None = None) -> Image.Image: if card_long_id: path = CARD_LONG_PATH / f"{card_long_id}.png" - else: - path = random.choice(list(CARD_LONG_PATH.glob("*.png"))) + if path.exists(): + return Image.open(path).convert("RGBA") + path = random.choice(list(CARD_LONG_PATH.glob("*.png"))) return Image.open(path).convert("RGBA") From aa603d7da9a3a7920e1ca1a055a17d4fc1e6f3a3 Mon Sep 17 00:00:00 2001 From: Ice9Coffee <438971718@qq.com> Date: Fri, 5 Jun 2026 11:57:07 +0800 Subject: [PATCH 2/3] Pick gacha header card background from drawn characters --- NTEUID/nte_gacha/gacha_card.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/NTEUID/nte_gacha/gacha_card.py b/NTEUID/nte_gacha/gacha_card.py index edbba4f..6a9a6c8 100644 --- a/NTEUID/nte_gacha/gacha_card.py +++ b/NTEUID/nte_gacha/gacha_card.py @@ -1,5 +1,6 @@ from __future__ import annotations +import random from pathlib import Path from datetime import datetime @@ -133,6 +134,18 @@ def _truncate(draw: ImageDraw.ImageDraw, text: str, font, max_w: int, suffix: st return text + suffix if text else suffix +def _pick_card_long_id(summary: NTEGachaSummary) -> str | None: + candidates = { + item.item_id + for section in summary.sections + for item in section.items + if item.item_id.isdigit() + } + if not candidates: + return None + return random.choice(tuple(candidates)) + + async def _load_gacha_icon(item_id: str) -> Image.Image | None: if item_id.startswith("fork_"): return await get_weapon_img(item_id) @@ -261,7 +274,7 @@ async def draw_gacha_summary_img( canvas = get_nte_bg(_PAGE_W, total_h, "bg2") canvas.alpha_composite( - make_nte_role_title(await get_event_avatar(ev), role_name, role_id), + make_nte_role_title(await get_event_avatar(ev), role_name, role_id, card_long_id=_pick_card_long_id(summary)), (0, _TITLE_Y), ) From 2defe53ae833eb9021abbe8248b941e92843fbc4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 5 Jun 2026 04:23:55 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- NTEUID/nte_gacha/gacha_card.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/NTEUID/nte_gacha/gacha_card.py b/NTEUID/nte_gacha/gacha_card.py index 6a9a6c8..78f9e1c 100644 --- a/NTEUID/nte_gacha/gacha_card.py +++ b/NTEUID/nte_gacha/gacha_card.py @@ -135,12 +135,7 @@ def _truncate(draw: ImageDraw.ImageDraw, text: str, font, max_w: int, suffix: st def _pick_card_long_id(summary: NTEGachaSummary) -> str | None: - candidates = { - item.item_id - for section in summary.sections - for item in section.items - if item.item_id.isdigit() - } + candidates = {item.item_id for section in summary.sections for item in section.items if item.item_id.isdigit()} if not candidates: return None return random.choice(tuple(candidates))