Skip to content

Commit

Permalink
🐛 修复ba学生排行底色灰蒙蒙的BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
KimigaiiWuyi committed Apr 14, 2024
1 parent 993af24 commit c063595
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
1 change: 1 addition & 0 deletions BlueArchiveUID/bauid_info/draw_user_info_pic.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ async def draw_assist_card(assist: Union[AssistInfo, RankAssistInfo]):
'mm',
)
assist_card.paste(equip_bg, (304 + eindex * 131, 306), equip_bg)

return assist_card


Expand Down
9 changes: 8 additions & 1 deletion BlueArchiveUID/bauid_ranklist/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
sv_ba_xtzx_rank = SV('BA什亭之匣学生排行榜')


@sv_ba_xtzx_rank.on_command(('ba学生排行'))
@sv_ba_xtzx_rank.on_command(
(
'ba学生排行',
'ba学生排名',
'ba角色排名',
'ba角色排行',
)
)
async def send_rank_msg(bot: Bot, ev: Event):
await bot.send(await draw_rank_pic(ev.text.strip()))
6 changes: 4 additions & 2 deletions BlueArchiveUID/bauid_ranklist/draw_rank_pic.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ async def draw_rank_pic(student: str) -> Union[bytes, str]:
student_id = student_name_to_id(student)
if student_id == '9999':
return '要查询的角色不存在或别名未收录, 请尝试使用完整名字。'

data = await xtzx_api.get_xtzx_friend_ranking(1, student_id)
if isinstance(data, int):
return get_error(data)
Expand All @@ -37,7 +38,6 @@ async def draw_rank_pic(student: str) -> Union[bytes, str]:
img = get_bg(1100, 2800)
for index, teacher in enumerate(teacher_data):
info = teacher['assistInfoList'][0]
assist_card = await draw_assist_card(info)
rank_key = info['baRank']['key']
rank_value = info['baRank']['value']
rank_str = f'{rank_key} / {rank_value}'
Expand All @@ -50,6 +50,7 @@ async def draw_rank_pic(student: str) -> Union[bytes, str]:
global_rank_color = get_color(global_rank_key)

card = Image.open(TEXT_PATH / 'card.png')

card_draw = ImageDraw.Draw(card)

card_draw.text(
Expand Down Expand Up @@ -92,9 +93,10 @@ async def draw_rank_pic(student: str) -> Union[bytes, str]:
cf(24),
'mm',
)
card.paste(assist_card, (0, 40), assist_card)
assist_card = await draw_assist_card(info)

img.paste(card, (0, 28 + index * 550), card)
img.paste(assist_card, (0, 68 + index * 550), assist_card)

img = await convert_img(img)
return img
1 change: 1 addition & 0 deletions BlueArchiveUID/utils/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
XTZX_FRIEND_REFRESH = XTZX_API + '/api/friends/refresh'
XTZX_ASSIST = XTZX_API + '/api/friends/assist_query'
XTZX_FRIEND_RANK = XTZX_API + '/api/friends/rank'
XTZX_FIND_RANK = XTZX_API + '/api/friends/findRank'
20 changes: 20 additions & 0 deletions BlueArchiveUID/utils/api/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
ARONA_URL,
BATTLE_URL,
XTZX_RAID_TOP,
XTZX_FIND_RANK,
XTZX_RAID_LIST,
XTZX_RAID_RANK,
XTZX_RAID_CHART,
Expand Down Expand Up @@ -199,6 +200,25 @@ async def get_xtzx_friend_data(
else:
return -500

async def get_xtzx_find_rank(
self,
friend_code: str,
) -> Union[int, FriendData]:
data = await self._ba_request(
XTZX_FIND_RANK,
'POST',
json={
'friend': friend_code,
},
)
if isinstance(data, Dict) and 'code' in data:
if data['code'] == 200:
return cast(FriendData, data['data'])
else:
return data['code']
else:
return -500

async def get_xtzx_friend_ranking(
self,
page: int,
Expand Down

0 comments on commit c063595

Please sign in to comment.