修复抽卡记录部分问题

This commit is contained in:
RBAmeto 2023-05-12 09:14:15 +08:00
parent eb698373c5
commit 1c22a65819

View File

@ -97,9 +97,9 @@ async def _draw_card(
) )
else: else:
name = await name_to_weapon_id(name) name = await name_to_weapon_id(name)
_id = await weapon_id_to_en_name(name) # _id = await weapon_id_to_en_name(name)
item_pic = ( item_pic = (
Image.open(WEAPON_PATH / f'{_id}.png') Image.open(WEAPON_PATH / f'{name}.png')
.convert('RGBA') .convert('RGBA')
.resize((124, 124)) .resize((124, 124))
) )
@ -131,10 +131,10 @@ async def get_level_from_list(ast: int, lst: List) -> int:
for num_index, num in enumerate(lst): for num_index, num in enumerate(lst):
if ast <= num: if ast <= num:
level = 5 - num_index level = num_index + 1
break break
else: else:
level = 1 level = 6
return level return level
@ -154,7 +154,7 @@ def check_up(name: str, _time: str) -> bool:
async def draw_gachalogs_img(uid: str, user_id: str) -> Union[bytes, str]: async def draw_gachalogs_img(uid: str, user_id: str) -> Union[bytes, str]:
path = PLAYER_PATH / str(uid) / 'gacha_logs_test.json' path = PLAYER_PATH / str(uid) / 'gacha_logs.json'
if not path.exists(): if not path.exists():
return '你还没有跃迁数据噢~\n请使用命令`sr导入抽卡链接`更新跃迁数据~' return '你还没有跃迁数据噢~\n请使用命令`sr导入抽卡链接`更新跃迁数据~'
with open(path, 'r', encoding='UTF-8') as f: with open(path, 'r', encoding='UTF-8') as f:
@ -319,10 +319,10 @@ async def draw_gachalogs_img(uid: str, user_id: str) -> Union[bytes, str]:
single_y = 150 single_y = 150
# 计算图片尺寸 # 计算图片尺寸
normal_y = (1 + ((total_data['群星跃迁']['total'] - 1) // 6)) * single_y normal_y = (1 + ((total_data['群星跃迁']['total'] - 1) // 5)) * single_y
begin_y = (1 + ((total_data['始发跃迁']['total'] - 1) // 6)) * single_y begin_y = (1 + ((total_data['始发跃迁']['total'] - 1) // 5)) * single_y
char_y = (1 + ((total_data['角色跃迁']['total'] - 1) // 6)) * single_y char_y = (1 + ((total_data['角色跃迁']['total'] - 1) // 5)) * single_y
weapon_y = (1 + ((total_data['光锥跃迁']['total'] - 1) // 6)) * single_y weapon_y = (1 + ((total_data['光锥跃迁']['total'] - 1) // 5)) * single_y
# 获取背景图片各项参数 # 获取背景图片各项参数
_id = str(user_id) _id = str(user_id)
@ -356,7 +356,7 @@ async def draw_gachalogs_img(uid: str, user_id: str) -> Union[bytes, str]:
) )
elif i == '始发跃迁': elif i == '始发跃迁':
level = await get_level_from_list( level = await get_level_from_list(
total_data[i]['avg'], [62, 75, 88, 99, 111] total_data[i]['avg'], [10, 20, 30, 40, 50]
) )
else: else:
if i == '光锥跃迁': if i == '光锥跃迁':
@ -413,7 +413,7 @@ async def draw_gachalogs_img(uid: str, user_id: str) -> Union[bytes, str]:
'mm', 'mm',
) )
y_extend += ( y_extend += (
(1 + ((total_data[type_list[index - 1]]['total'] - 1) // 6)) * 150 (1 + ((total_data[type_list[index - 1]]['total'] - 1) // 5)) * 150
if index != 0 if index != 0
else 0 else 0
) )
@ -421,8 +421,8 @@ async def draw_gachalogs_img(uid: str, user_id: str) -> Union[bytes, str]:
img.paste(title, (0, y), title) img.paste(title, (0, y), title)
tasks = [] tasks = []
for item_index, item in enumerate(total_data[i]['list']): for item_index, item in enumerate(total_data[i]['list']):
item_x = (item_index % 6) * 138 + 45 item_x = (item_index % 5) * 138 + 25
item_y = (item_index // 6) * 150 + y + 355 item_y = (item_index // 5) * 150 + y + 355
xy_point = (item_x, item_y) xy_point = (item_x, item_y)
tasks.append( tasks.append(
_draw_card( _draw_card(