Skip to content

Commit

Permalink
🐛 修复部分情况下查询面板替换武器失效
Browse files Browse the repository at this point in the history
  • Loading branch information
KimigaiiWuyi committed Nov 25, 2024
1 parent 9cc2147 commit a27e33c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
30 changes: 27 additions & 3 deletions GenshinUID/genshinuid_enka/mono/Character.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
from copy import deepcopy
from typing import Dict, List, Tuple, Optional

Expand All @@ -14,12 +15,16 @@
from ...genshinuid_config.gs_config import gsconfig
from ..etc.status_change import EXTRA_CHAR_LIST, STATUS_CHAR_LIST
from ..etc.MAP_PATH import ActionMAP, char_action, avatarName2SkillAdd
from ...utils.map.GS_MAP_PATH import avatarName2Weapon, avatarName2Element
from ...utils.map.name_covert import name_to_avatar_id, avatar_id_to_char_star
from ...utils.ambr_to_minigg import (
convert_ambr_to_minigg,
convert_ambr_to_weapon,
)
from ...utils.map.GS_MAP_PATH import (
avatarName2Weapon,
avatarName2Element,
weaponId2Name_data,
)
from ..etc.base_info import (
ATTR_MAP,
ELEMENT_MAP,
Expand Down Expand Up @@ -139,13 +144,25 @@ async def get_card_prop(
weapon_raw_data = await get_weapon_info(weapon)
except ConnectTimeout:
weapon_raw_data = -1

if isinstance(weapon_raw_data, int) or isinstance(
weapon_raw_data, List
):
weapon_id = 0
if weapon in beta_weapons:
weapon_id = beta_weapons[weapon]
else:
for _weapon_id in weaponId2Name_data:
_weapon_name = weaponId2Name_data[_weapon_id]
if _weapon_name == weapon:
weapon_id = _weapon_id
break
else:
return {}

if weapon_id == 0:
return {}

weapon_raw_data = await convert_ambr_to_weapon(weapon_id)
if not weapon_raw_data:
return {}
Expand Down Expand Up @@ -191,12 +208,19 @@ async def get_card_prop(
)
weapon_info['weaponStats'][1]['statValue'] = fake_value

if 'effect' in weapon_raw_data:
weapon_info['weaponEffect'] = weapon_raw_data['effect'].format(
if 'effectTemplateRaw' in weapon_raw_data:
weapon_info['weaponEffect'] = weapon_raw_data[
'effectTemplateRaw'
].format(
*weapon_raw_data[
'r{}'.format(str(weapon_info['weaponAffix']))
]
)
weapon_info['weaponEffect'] = re.sub(
r'</?c[^\u4e00-\u9fa5/d]+>',
'',
weapon_info['weaponEffect'],
)
else:
weapon_info['weaponEffect'] = '无特效。'
weapon_info['weaponType'] = weapon_raw_data['weaponText']
Expand Down
2 changes: 1 addition & 1 deletion GenshinUID/utils/ambr_to_minigg.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ async def convert_ambr_to_weapon(
result[f'r{index+1}'] = {'description': effect_desc}
else:
if index != 0:
result['effect'] = result[f'r{index+1}']['description']
result['effectTemplateRaw'] = result[f'r{index+1}']['description']
atk_curve_type = upgrade['prop'][0]['type']
sp_curve_type = upgrade['prop'][1]['type']
atk_curve = WEAPON_GROW_CURVE['90']['curveInfos'][atk_curve_type]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<p align="center">
<a href="https://github.com/KimigaiiWuyi/GenshinUID/"><img src="https://s2.loli.net/2023/03/25/bareSdYcsmRPOyZ.png" width="256" height="256" alt="GenshinUID"></a>
</p>
<h1 align = "center">GenshinUID 5.0.1</h1>
<h1 align = "center">GenshinUID 5.1.2</h1>
<h4 align = "center">✨支持OneBot(QQ)、QQ频道、微信、开黑啦、Telegram的全功能原神Bot插件✨</h4>
<div align = "center">
<a href="https://docs.sayu-bot.com/" target="_blank">安装文档</a> &nbsp; · &nbsp;
Expand Down Expand Up @@ -51,5 +51,5 @@
+ 如果对本插件有功能建议&Bug报告,欢迎提Issue & Pr,每一条都会详细看过
+ 如果本插件对你有帮助,不要忘了点个Star~
+ 本项目仅供学习使用,请勿用于商业用途
+ [爱发电](https://afdian.net/@KimigaiiWuyi)
+ [爱发电](https://afdian.com/a/KimigaiiWuyi)
+ [GPL-3.0 License](https://github.com/KimigaiiWuyi/GenshinUID/blob/main/LICENSE) ©[@KimigaiiWuyi](https://github.com/KimigaiiWuyi)

0 comments on commit a27e33c

Please sign in to comment.