From ee2696e5b60cc48dba05fffb091c23ab86484585 Mon Sep 17 00:00:00 2001 From: a376148946 <376148946@qq.com> Date: Mon, 25 Sep 2023 15:35:49 +0800 Subject: [PATCH] =?UTF-8?q?bug:=E4=BF=AE=E5=A4=8D=E4=BF=AE=E6=94=B9model?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- StarRailUID/sruid_utils/api/mys/models.py | 13 +++--- .../starrailuid_abyss/draw_abyss_card.py | 8 ++-- .../starrailuid_rogue/draw_rogue_card.py | 42 ++++++++++--------- 3 files changed, 33 insertions(+), 30 deletions(-) diff --git a/StarRailUID/sruid_utils/api/mys/models.py b/StarRailUID/sruid_utils/api/mys/models.py index e894076..e73658e 100644 --- a/StarRailUID/sruid_utils/api/mys/models.py +++ b/StarRailUID/sruid_utils/api/mys/models.py @@ -161,14 +161,13 @@ class LocustRecordInfo(Struct): buffs: List[RogueBuffs] miracles: List[RogueMiracles] blocks: List[LocustBlocks] - worm_weak: Union[str, str] difficulty: int fury: LocustFury - detail_h: Union[int, None] - start_h: Union[int, None] + detail_h: Union[int, None] = None + start_h: Union[int, None] = None - def __setitem__(self, key: str, value: Any) -> None: - self.__dict__[key] = value + # def __setitem__(self, key: str, value: Any) -> None: + # self.__dict__[key] = value class LocustRecord(Struct): @@ -218,8 +217,8 @@ class AbyssFloorDetail(Struct): name: str round_num: int star_num: int - node_1: List[AbyssNodeDetail] - node_2: List[AbyssNodeDetail] + node_1: AbyssNodeDetail + node_2: AbyssNodeDetail class AbyssData(Struct): diff --git a/StarRailUID/starrailuid_abyss/draw_abyss_card.py b/StarRailUID/starrailuid_abyss/draw_abyss_card.py index bdc2d85..20bc1bd 100644 --- a/StarRailUID/starrailuid_abyss/draw_abyss_card.py +++ b/StarRailUID/starrailuid_abyss/draw_abyss_card.py @@ -235,9 +235,9 @@ async def draw_abyss_img( for index_part in [0, 1]: node_num = index_part + 1 if node_num == 1: - time_array = node_1[-1].challenge_time + time_array = node_1.challenge_time else: - time_array = node_2[-1].challenge_time + time_array = node_2.challenge_time time_str = f'{time_array.year}-{time_array.month}' time_str = f'{time_str}-{time_array.day}' time_str = f'{time_str} {time_array.hour}:{time_array.minute}:00' @@ -257,9 +257,9 @@ async def draw_abyss_img( 'lm', ) if node_num == 1: - avatars_array = node_1[-1] + avatars_array = node_1 else: - avatars_array = node_2[-1] + avatars_array = node_2 for index_char, char in enumerate(avatars_array.avatars): # 获取命座 diff --git a/StarRailUID/starrailuid_rogue/draw_rogue_card.py b/StarRailUID/starrailuid_rogue/draw_rogue_card.py index b2bff6b..45d4981 100644 --- a/StarRailUID/starrailuid_rogue/draw_rogue_card.py +++ b/StarRailUID/starrailuid_rogue/draw_rogue_card.py @@ -1,7 +1,7 @@ import math from pathlib import Path from typing import List, Union, Optional - +import msgspec from PIL import Image, ImageDraw from gsuid_core.logger import logger from gsuid_core.utils.error_reply import get_error @@ -252,6 +252,8 @@ async def draw_rogue_img( # 记录打的宇宙列表 detail_list = [] based_h = 700 + detail_h_list = [] + based_h_list = [] for index_floor, detail in enumerate(rogue_detail): # 100+70+170 # 头+底+角色 @@ -277,14 +279,15 @@ async def draw_rogue_img( else: miracles_h = 0 detail_h = detail_h + miracles_h - rogue_detail[index_floor]['detail_h'] = detail_h - rogue_detail[index_floor]['start_h'] = based_h + detail_h_list.append(detail_h) + based_h_list.append(based_h) if floor: if progress == floor: pass else: detail_h = 0 based_h = based_h + detail_h + # 获取查询者数据 if floor: if floor > 7: @@ -378,11 +381,11 @@ async def draw_rogue_img( else: continue - if detail.detail_h is None: + if detail_h_list[index_floor] is None: continue floor_pic = Image.open(TEXT_PATH / 'detail_bg.png').convert('RGBA') - floor_pic = floor_pic.resize((900, detail.detail_h)) + floor_pic = floor_pic.resize((900, detail_h_list[index_floor])) floor_top_pic = Image.open(TEXT_PATH / 'floor_bg_top.png').convert( 'RGBA' @@ -393,7 +396,7 @@ async def draw_rogue_img( TEXT_PATH / 'floor_bg_center.png' ).convert('RGBA') floor_center_pic = floor_center_pic.resize( - (900, detail.detail_h - 170) + (900, detail_h_list[index_floor] - 170) ) floor_pic.paste(floor_center_pic, (0, 100), floor_center_pic) @@ -401,7 +404,7 @@ async def draw_rogue_img( 'RGBA' ) floor_pic.paste( - floor_bot_pic, (0, detail.detail_h - 70), floor_bot_pic + floor_bot_pic, (0, detail_h_list[index_floor] - 70), floor_bot_pic ) floor_name = progresslist[detail.progress] @@ -496,10 +499,10 @@ async def draw_rogue_img( buff_height, ) - if detail.start_h is None: + if based_h_list[index_floor] is None: continue - img.paste(floor_pic, (0, detail.start_h), floor_pic) + img.paste(floor_pic, (0, based_h_list[index_floor]), floor_pic) # await _draw_floor_card( # level_star, # floor_pic, @@ -536,6 +539,8 @@ async def draw_rogue_locust_img( # 记录打的宇宙列表 # detail_list = [] based_h = 700 + detail_h_list = [] + based_h_list = [] for index_floor, detail in enumerate(rogue_detail): # 100+70+170 # 头+底+角色 @@ -570,9 +575,8 @@ async def draw_rogue_locust_img( else: blocks_num = 0 detail_h = detail_h + blocks_h - - rogue_detail[index_floor]['detail_h'] = detail_h - rogue_detail[index_floor]['start_h'] = based_h + detail_h_list.append(detail_h) + based_h_list.append(based_h) based_h = based_h + detail_h # 获取查询者数据 @@ -653,12 +657,12 @@ async def draw_rogue_locust_img( 'mm', ) - for _, detail in enumerate(rogue_detail): - if detail.detail_h is None: + for index_floor, detail in enumerate(rogue_detail): + if detail_h_list[index_floor] is None: continue floor_pic = Image.open(TEXT_PATH / 'detail_bg.png').convert('RGBA') - floor_pic = floor_pic.resize((900, detail.detail_h)) + floor_pic = floor_pic.resize((900, detail_h_list[index_floor])) floor_top_pic = Image.open(TEXT_PATH / 'floor_bg_top.png').convert( 'RGBA' @@ -669,7 +673,7 @@ async def draw_rogue_locust_img( TEXT_PATH / 'floor_bg_center.png' ).convert('RGBA') floor_center_pic = floor_center_pic.resize( - (900, detail.detail_h - 170) + (900, detail_h_list[index_floor] - 170) ) floor_pic.paste(floor_center_pic, (0, 100), floor_center_pic) @@ -677,7 +681,7 @@ async def draw_rogue_locust_img( 'RGBA' ) floor_pic.paste( - floor_bot_pic, (0, detail.detail_h - 70), floor_bot_pic + floor_bot_pic, (0, detail_h_list[index_floor] - 70), floor_bot_pic ) floor_name = detail.name @@ -805,10 +809,10 @@ async def draw_rogue_locust_img( blocks_height = blocks_height + 80 blocks_height = blocks_height + draw_height - if detail.start_h is None: + if based_h_list[index_floor] is None: continue - img.paste(floor_pic, (0, detail.start_h), floor_pic) + img.paste(floor_pic, (0, based_h_list[index_floor]), floor_pic) # await _draw_floor_card( # level_star, # floor_pic,