From a27e33c25fce799c4f8e8643827701d36dbcbec2 Mon Sep 17 00:00:00 2001 From: KimigaiiWuyi <444835641@qq.com> Date: Mon, 25 Nov 2024 20:47:14 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=E9=83=A8?= =?UTF-8?q?=E5=88=86=E6=83=85=E5=86=B5=E4=B8=8B=E6=9F=A5=E8=AF=A2=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E6=9B=BF=E6=8D=A2=E6=AD=A6=E5=99=A8=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GenshinUID/genshinuid_enka/mono/Character.py | 30 ++++++++++++++++++-- GenshinUID/utils/ambr_to_minigg.py | 2 +- README.md | 4 +-- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/GenshinUID/genshinuid_enka/mono/Character.py b/GenshinUID/genshinuid_enka/mono/Character.py index 0b65bb05..e6b27fbb 100644 --- a/GenshinUID/genshinuid_enka/mono/Character.py +++ b/GenshinUID/genshinuid_enka/mono/Character.py @@ -1,3 +1,4 @@ +import re from copy import deepcopy from typing import Dict, List, Tuple, Optional @@ -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, @@ -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 {} @@ -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'', + '', + weapon_info['weaponEffect'], + ) else: weapon_info['weaponEffect'] = '无特效。' weapon_info['weaponType'] = weapon_raw_data['weaponText'] diff --git a/GenshinUID/utils/ambr_to_minigg.py b/GenshinUID/utils/ambr_to_minigg.py index 9faffb95..f5ab07d2 100644 --- a/GenshinUID/utils/ambr_to_minigg.py +++ b/GenshinUID/utils/ambr_to_minigg.py @@ -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] diff --git a/README.md b/README.md index d82ba786..91b1152a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

GenshinUID

-

GenshinUID 5.0.1

+

GenshinUID 5.1.2

✨支持OneBot(QQ)、QQ频道、微信、开黑啦、Telegram的全功能原神Bot插件✨

安装文档   ·   @@ -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)