修复为出金卡池BUG

This commit is contained in:
wangyu 2023-03-28 20:49:53 +08:00
parent e7cc5fcb22
commit 08977a68f0

View File

@ -83,8 +83,10 @@ async def draw_pool_detail(pool_name: str,
not_out: int, not_out: int,
record_time: Tuple[datetime.datetime, datetime.datetime]) -> Optional[ record_time: Tuple[datetime.datetime, datetime.datetime]) -> Optional[
PMImage]: PMImage]:
if not data:
if total_count == 0:
return None return None
total_height = 181 + (446 if len(data) > 3 else 0) + 47 + 192 * math.ceil(len(data) / 6) + 20 + 60 total_height = 181 + (446 if len(data) > 3 else 0) + 47 + 192 * math.ceil(len(data) / 6) + 20 + 60
img = PMImage(size=(1009, total_height), mode='RGBA', color=(255, 255, 255, 0)) img = PMImage(size=(1009, total_height), mode='RGBA', color=(255, 255, 255, 0))
# 橙线 # 橙线
@ -95,7 +97,11 @@ async def draw_pool_detail(pool_name: str,
fm.get('bahnschrift_regular', 30), '#252525', 'right') fm.get('bahnschrift_regular', 30), '#252525', 'right')
# 数据 # 数据
await img.text('平均出货', 174, 137, fm.get('hywh', 24), (24, 24, 24, 102)) await img.text('平均出货', 174, 137, fm.get('hywh', 24), (24, 24, 24, 102))
ave = 0
if data:
ave = round((total_count - not_out) / len(data), 2) ave = round((total_count - not_out) / len(data), 2)
await img.text(str(ave), (176, 270), 84, await img.text(str(ave), (176, 270), 84,
fm.get('bahnschrift_regular', 48, 'Regular'), fm.get('bahnschrift_regular', 48, 'Regular'),
'#252525', 'center') '#252525', 'center')
@ -105,7 +111,8 @@ async def draw_pool_detail(pool_name: str,
await img.text('未出五星', 562, 137, fm.get('hywh', 24), (24, 24, 24, 102)) await img.text('未出五星', 562, 137, fm.get('hywh', 24), (24, 24, 24, 102))
await img.text(str(not_out), (562, 655), 84, fm.get('bahnschrift_regular', 48, 'Regular'), await img.text(str(not_out), (562, 655), 84, fm.get('bahnschrift_regular', 48, 'Regular'),
'#252525', 'center') '#252525', 'center')
lucky = '' if ave <= (45 if pool_type == '武器' else 50) else '' if ave <= (55 if pool_type == '武器' else 60) else '' if ave <= (65 if pool_type == '武器' else 70) else '' lucky_num = ave if ave > 0 else total_count
lucky = '' if lucky_num <= (45 if pool_type == '武器' else 50) else '' if lucky_num <= (55 if pool_type == '武器' else 60) else '' if lucky_num <= (65 if pool_type == '武器' else 70) else ''
await img.paste(await load_image(RESOURCE_BASE_PATH / 'gacha_log' / f'{lucky}{random.randint(1, 3)}.png'), (753, 68)) await img.paste(await load_image(RESOURCE_BASE_PATH / 'gacha_log' / f'{lucky}{random.randint(1, 3)}.png'), (753, 68))
# 折线图 # 折线图
if len(data) > 3: if len(data) > 3:
@ -126,6 +133,7 @@ async def draw_pool_detail(pool_name: str,
await img.text(str(chara.count), (point, point + 44), height - 48, fm.get('bahnschrift_regular', 30, await img.text(str(chara.count), (point, point + 44), height - 48, fm.get('bahnschrift_regular', 30,
'Regular'), '#040404', 'center') 'Regular'), '#040404', 'center')
i += 1 i += 1
if data:
# 详细数据统计 # 详细数据统计
chara_bg = PMImage(await load_image(RESOURCE_BASE_PATH / 'gacha_log' / 'detail_bg.png')) chara_bg = PMImage(await load_image(RESOURCE_BASE_PATH / 'gacha_log' / 'detail_bg.png'))
await chara_bg.stretch((47, chara_bg.height - 20), 192 + 192 * (len(data) // 6), 'height') await chara_bg.stretch((47, chara_bg.height - 20), 192 + 192 * (len(data) // 6), 'height')
@ -134,6 +142,7 @@ async def draw_pool_detail(pool_name: str,
*[img.paste(await detail_avatar(data[i]), *[img.paste(await detail_avatar(data[i]),
(18 + i % 6 * 163, (708 if len(data) > 3 else 234) + i // 6 * 192)) (18 + i % 6 * 163, (708 if len(data) > 3 else 234) + i // 6 * 192))
for i in range(len(data))]) for i in range(len(data))])
return img return img
@ -204,7 +213,8 @@ async def draw_gacha_log(user_id: str, uid: str, nickname: Optional[str], signat
await img.text(str(total_gacha_count), (408, 503), 286, fm.get('bahnschrift_regular', 48), '#040404', 'center') await img.text(str(total_gacha_count), (408, 503), 286, fm.get('bahnschrift_regular', 48), '#040404', 'center')
await img.text('总计出金', 597, 335, fm.get('hywh', 24), (24, 24, 24, 102)) await img.text('总计出金', 597, 335, fm.get('hywh', 24), (24, 24, 24, 102))
await img.text(str(total_five_star_count), (598, 694), 286, fm.get('bahnschrift_regular', 48), '#040404', 'center') await img.text(str(total_five_star_count), (598, 694), 286, fm.get('bahnschrift_regular', 48), '#040404', 'center')
lucky = '' if five_star_average <= 50 else '' if five_star_average <= 60 else '' if five_star_average <= 70 else '' lucky_num = five_star_average if five_star_average>0 else total_gacha_count
lucky = '' if lucky_num <= 50 else '' if lucky_num <= 60 else '' if lucky_num <= 70 else ''
await img.paste(await load_image(RESOURCE_BASE_PATH / 'gacha_log' / f'{lucky}{random.randint(1, 3)}.png'), (788, 271)) await img.paste(await load_image(RESOURCE_BASE_PATH / 'gacha_log' / f'{lucky}{random.randint(1, 3)}.png'), (788, 271))
four_star_detail = await draw_four_star_detail(list(data4.values())) four_star_detail = await draw_four_star_detail(list(data4.values()))
if total_five_star_count: if total_five_star_count: