mirror of
https://github.com/baiqwerdvd/StarRailUID.git
synced 2025-05-06 19:53:44 +08:00
拆分一部分代码
This commit is contained in:
parent
ca99169a6b
commit
13731a3d40
@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Union, TypedDict
|
||||
from typing import List, TypedDict, Union
|
||||
|
||||
|
||||
class MihomoData(TypedDict):
|
||||
@ -20,7 +20,7 @@ class Equipment(TypedDict):
|
||||
|
||||
|
||||
class Relic(TypedDict):
|
||||
subAffixList: list[SubAffix]
|
||||
subAffixList: List[SubAffix]
|
||||
tid: int
|
||||
mainAffixId: int
|
||||
type: int
|
||||
@ -33,13 +33,13 @@ class SubAffix(TypedDict):
|
||||
|
||||
|
||||
class Avatar(TypedDict):
|
||||
skillTreeList: list[Behavior]
|
||||
skillTreeList: List[Behavior]
|
||||
rank: Union[int, None]
|
||||
pos: Union[int, None]
|
||||
avatarId: int
|
||||
level: int
|
||||
equipment: Union[Equipment, None]
|
||||
relicList: list[Relic]
|
||||
relicList: List[Relic]
|
||||
promotion: int
|
||||
|
||||
|
||||
@ -61,7 +61,7 @@ class PlayerDetailInfo(TypedDict):
|
||||
assistAvatarDetail: Avatar
|
||||
platform: str
|
||||
isDisplayAvatar: bool
|
||||
avatarDetailList: Union[list[Avatar], None]
|
||||
avatarDetailList: Union[List[Avatar], None]
|
||||
uid: int
|
||||
friendCount: int
|
||||
worldLevel: int
|
||||
|
69
StarRailUID/starrailuid_charinfo/cal_damage.py
Normal file
69
StarRailUID/starrailuid_charinfo/cal_damage.py
Normal file
@ -0,0 +1,69 @@
|
||||
from typing import Dict
|
||||
|
||||
from .draw_char_img import cal_char_info
|
||||
from .effect.Role import RoleInstance
|
||||
|
||||
|
||||
async def cal(char_data: Dict):
|
||||
char = await cal_char_info(char_data)
|
||||
|
||||
skill_info_list = []
|
||||
if char.char_id in [
|
||||
1102,
|
||||
1204,
|
||||
1107,
|
||||
1213,
|
||||
1006,
|
||||
1005,
|
||||
1205,
|
||||
1208,
|
||||
1104,
|
||||
1209,
|
||||
1004,
|
||||
1003,
|
||||
1201,
|
||||
1212,
|
||||
]:
|
||||
if char.char_id == 1213:
|
||||
for skill_type in [
|
||||
'Normal',
|
||||
'Normal1',
|
||||
'Normal2',
|
||||
'Normal3',
|
||||
'Ultra',
|
||||
]:
|
||||
role = RoleInstance(char)
|
||||
im_tmp = await role.cal_damage(skill_type)
|
||||
skill_info_list.append(im_tmp)
|
||||
elif char.char_id == 1005:
|
||||
for skill_type in ['Normal', 'BPSkill', 'Ultra', 'DOT']:
|
||||
role = RoleInstance(char)
|
||||
im_tmp = await role.cal_damage(skill_type)
|
||||
skill_info_list.append(im_tmp)
|
||||
elif char.char_id == 1212:
|
||||
for skill_type in ['Normal', 'BPSkill', 'BPSkill1', 'Ultra']:
|
||||
role = RoleInstance(char)
|
||||
im_tmp = await role.cal_damage(skill_type)
|
||||
skill_info_list.append(im_tmp)
|
||||
elif char.char_id == 1208:
|
||||
for skill_type in ['Normal', 'Ultra']:
|
||||
role = RoleInstance(char)
|
||||
im_tmp = await role.cal_damage(skill_type)
|
||||
skill_info_list.append(im_tmp)
|
||||
elif char.char_id in [1205, 1201]:
|
||||
for skill_type in ['Normal', 'Normal1', 'Ultra']:
|
||||
role = RoleInstance(char)
|
||||
im_tmp = await role.cal_damage(skill_type)
|
||||
skill_info_list.append(im_tmp)
|
||||
else:
|
||||
for skill_type in ['Normal', 'BPSkill', 'Ultra']:
|
||||
role = RoleInstance(char)
|
||||
im_tmp = await role.cal_damage(skill_type)
|
||||
skill_info_list.append(im_tmp)
|
||||
if char.char_id in [1204, 1107, 1005, 1205, 1209, 1003]:
|
||||
role = RoleInstance(char)
|
||||
im_tmp = await role.cal_damage('Talent')
|
||||
skill_info_list.append(im_tmp)
|
||||
return skill_info_list
|
||||
else:
|
||||
return '角色伤害计算未完成'
|
@ -36,7 +36,7 @@ from ..utils.resource.RESOURCE_PATH import (
|
||||
SKILL_PATH,
|
||||
WEAPON_PATH,
|
||||
)
|
||||
from .effect.Role import RoleInstance
|
||||
from .cal_damage import cal
|
||||
from .mono.Character import Character
|
||||
from .to_data import api_to_dict
|
||||
|
||||
@ -726,71 +726,6 @@ async def get_char_data(
|
||||
return json.load(fp)
|
||||
|
||||
|
||||
async def cal(char_data: Dict):
|
||||
char = await cal_char_info(char_data)
|
||||
|
||||
skill_info_list = []
|
||||
if char.char_id in [
|
||||
1102,
|
||||
1204,
|
||||
1107,
|
||||
1213,
|
||||
1006,
|
||||
1005,
|
||||
1205,
|
||||
1208,
|
||||
1104,
|
||||
1209,
|
||||
1004,
|
||||
1003,
|
||||
1201,
|
||||
1212,
|
||||
]:
|
||||
if char.char_id == 1213:
|
||||
for skill_type in [
|
||||
'Normal',
|
||||
'Normal1',
|
||||
'Normal2',
|
||||
'Normal3',
|
||||
'Ultra',
|
||||
]:
|
||||
role = RoleInstance(char)
|
||||
im_tmp = await role.cal_damage(skill_type)
|
||||
skill_info_list.append(im_tmp)
|
||||
elif char.char_id == 1005:
|
||||
for skill_type in ['Normal', 'BPSkill', 'Ultra', 'DOT']:
|
||||
role = RoleInstance(char)
|
||||
im_tmp = await role.cal_damage(skill_type)
|
||||
skill_info_list.append(im_tmp)
|
||||
elif char.char_id == 1212:
|
||||
for skill_type in ['Normal', 'BPSkill', 'BPSkill1', 'Ultra']:
|
||||
role = RoleInstance(char)
|
||||
im_tmp = await role.cal_damage(skill_type)
|
||||
skill_info_list.append(im_tmp)
|
||||
elif char.char_id == 1208:
|
||||
for skill_type in ['Normal', 'Ultra']:
|
||||
role = RoleInstance(char)
|
||||
im_tmp = await role.cal_damage(skill_type)
|
||||
skill_info_list.append(im_tmp)
|
||||
elif char.char_id in [1205, 1201]:
|
||||
for skill_type in ['Normal', 'Normal1', 'Ultra']:
|
||||
role = RoleInstance(char)
|
||||
im_tmp = await role.cal_damage(skill_type)
|
||||
skill_info_list.append(im_tmp)
|
||||
else:
|
||||
for skill_type in ['Normal', 'BPSkill', 'Ultra']:
|
||||
role = RoleInstance(char)
|
||||
im_tmp = await role.cal_damage(skill_type)
|
||||
skill_info_list.append(im_tmp)
|
||||
if char.char_id in [1204, 1107, 1005, 1205, 1209, 1003]:
|
||||
role = RoleInstance(char)
|
||||
im_tmp = await role.cal_damage('Talent')
|
||||
skill_info_list.append(im_tmp)
|
||||
return skill_info_list
|
||||
else:
|
||||
return '角色伤害计算未完成'
|
||||
|
||||
|
||||
async def get_relic_score(
|
||||
subProperty: str, subValue, char_name: str, is_main: bool
|
||||
) -> float:
|
||||
|
@ -30,7 +30,6 @@ async def merge_attribute(base_attr: Dict, attribute_bonus: Dict) -> Dict:
|
||||
attr_value = base_attr.get(attribute, 0)
|
||||
merged_attr[attribute] = attr_value + attribute_bonus[attribute]
|
||||
elif attribute.__contains__('AddedRatio'):
|
||||
# attr = attribute.split('AddedRatio')[0]
|
||||
attr_value = base_attr.get(attribute, 0)
|
||||
merged_attr[attribute] = attr_value + attribute_bonus[attribute]
|
||||
elif attribute.__contains__('DmgAdd'):
|
||||
|
@ -1,16 +1,16 @@
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
from typing import List, Union
|
||||
from typing import Dict, List, Union
|
||||
|
||||
from PIL import Image, ImageDraw
|
||||
|
||||
from .to_data import api_to_dict
|
||||
from ..utils.image.convert import convert_img
|
||||
from ..utils.fonts.first_world import fw_font_28
|
||||
from ..utils.map.SR_MAP_PATH import avatarId2Name
|
||||
from ..utils.map.name_covert import avatar_id_to_char_star
|
||||
from ..utils.fonts.starrail_fonts import sr_font_24, sr_font_30, sr_font_58
|
||||
from ..utils.image.convert import convert_img
|
||||
from ..utils.map.name_covert import avatar_id_to_char_star
|
||||
from ..utils.map.SR_MAP_PATH import avatarId2Name
|
||||
from ..utils.resource.RESOURCE_PATH import CHAR_ICON_PATH, CHAR_PREVIEW_PATH
|
||||
from .to_data import api_to_dict
|
||||
|
||||
half_color = (255, 255, 255, 120)
|
||||
first_color = (29, 29, 29)
|
||||
@ -18,7 +18,6 @@ second_color = (67, 61, 56)
|
||||
white_color = (247, 247, 247)
|
||||
gray_color = (175, 175, 175)
|
||||
|
||||
# MAP_PATH = Path(__file__).parent / 'map'
|
||||
TEXT_PATH = Path(__file__).parent / 'texture2D'
|
||||
char_mask = Image.open(TEXT_PATH / 'char_mask.png')
|
||||
char_bg_mask = Image.open(TEXT_PATH / 'char_bg_mask.png')
|
||||
@ -104,7 +103,7 @@ async def draw_enka_card(uid: str, char_list: List, showfrom: int = 0):
|
||||
return await convert_img(img)
|
||||
|
||||
|
||||
async def draw_mihomo_char(index: int, img: Image.Image, char_data: dict):
|
||||
async def draw_mihomo_char(index: int, img: Image.Image, char_data: Dict):
|
||||
char_id = char_data['avatarId']
|
||||
char_name = char_data['avatarName']
|
||||
char_star = await avatar_id_to_char_star(str(char_id))
|
||||
@ -136,7 +135,7 @@ async def draw_mihomo_char(index: int, img: Image.Image, char_data: dict):
|
||||
img.paste(char_card, (x, 199), char_card)
|
||||
|
||||
|
||||
async def draw_enka_char(index: int, img: Image.Image, char_data: dict):
|
||||
async def draw_enka_char(index: int, img: Image.Image, char_data: Dict):
|
||||
char_id = char_data['avatarId']
|
||||
char_star = await avatar_id_to_char_star(str(char_id))
|
||||
char_card = Image.open(TEXT_PATH / f'char_card_{char_star}.png')
|
||||
|
@ -1,6 +1,6 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import List, Optional, Union
|
||||
from typing import Dict, List, Optional, Union
|
||||
|
||||
from httpx import ReadTimeout
|
||||
|
||||
@ -33,13 +33,13 @@ from .cal_value import cal_relic_main_affix, cal_relic_sub_affix
|
||||
|
||||
async def api_to_dict(
|
||||
sr_uid: str, sr_data: Optional[MihomoData] = None
|
||||
) -> Union[List[dict], str]:
|
||||
) -> Union[List[Dict], str]:
|
||||
"""
|
||||
:说明:
|
||||
访问Mihomo.me API并转换为StarRailUID的数据Json。
|
||||
:参数:
|
||||
* ``uid: str``: 玩家uid。
|
||||
* ``sr_data: Optional[dict] = None``: 来自Mihomo.me的dict, 可留空。
|
||||
* ``sr_data: Optional[Dict] = None``: 来自Mihomo.me的dict, 可留空。
|
||||
:返回:
|
||||
* ``刷新完成提示语: str``: 包含刷新成功的角色列表。
|
||||
"""
|
||||
@ -54,7 +54,7 @@ async def api_to_dict(
|
||||
return '网络不太稳定...'
|
||||
if isinstance(sr_data, str):
|
||||
return []
|
||||
if isinstance(sr_data, dict):
|
||||
if isinstance(sr_data, Dict):
|
||||
if 'detailInfo' not in sr_data:
|
||||
return '服务器正在维护或者关闭中...\n检查Mihomo.me是否可以访问\n如可以访问,尝试上报Bug!'
|
||||
elif sr_data is None:
|
||||
@ -342,7 +342,7 @@ async def get_data(char: Avatar, sr_data: MihomoData, sr_uid: str):
|
||||
|
||||
async def api_to_data(
|
||||
uid: str, mihomo_data: Optional[MihomoData] = None
|
||||
) -> Union[dict, str]:
|
||||
) -> Union[Dict, str]:
|
||||
raw_data = await api_to_dict(uid, mihomo_data)
|
||||
if isinstance(raw_data, str):
|
||||
return raw_data
|
||||
|
@ -1,9 +1,9 @@
|
||||
import json
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
from urllib import parse
|
||||
import json
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from typing import Dict, Optional
|
||||
from urllib import parse
|
||||
|
||||
from ..utils.mys_api import mys_api
|
||||
from ..utils.resource.RESOURCE_PATH import PLAYER_PATH
|
||||
@ -61,7 +61,7 @@ async def get_new_gachalog_by_link(
|
||||
async def save_gachalogs(
|
||||
uid: str,
|
||||
gacha_url: str,
|
||||
raw_data: Optional[dict] = None,
|
||||
raw_data: Optional[Dict] = None,
|
||||
is_force: bool = False,
|
||||
) -> str:
|
||||
path = PLAYER_PATH / str(uid)
|
||||
|
@ -1,15 +1,16 @@
|
||||
import asyncio
|
||||
import base64
|
||||
import io
|
||||
import json
|
||||
import base64
|
||||
import asyncio
|
||||
from http.cookies import SimpleCookie
|
||||
from typing import Any, List, Tuple, Union, Literal
|
||||
from typing import Any, Dict, List, Literal, Tuple, Union
|
||||
|
||||
import qrcode
|
||||
from gsuid_core.bot import Bot
|
||||
from gsuid_core.models import Event
|
||||
from gsuid_core.logger import logger
|
||||
from qrcode.constants import ERROR_CORRECT_L
|
||||
|
||||
from gsuid_core.bot import Bot
|
||||
from gsuid_core.logger import logger
|
||||
from gsuid_core.models import Event
|
||||
from gsuid_core.segment import MessageSegment
|
||||
|
||||
from ..utils.api import get_sqla
|
||||
@ -40,7 +41,7 @@ def get_qrcode_base64(url):
|
||||
|
||||
|
||||
async def refresh(
|
||||
code_data: dict,
|
||||
code_data: Dict,
|
||||
) -> Union[Tuple[Literal[False], None], Tuple[Literal[True], Any]]:
|
||||
scanned = False
|
||||
while True:
|
||||
|
@ -1,5 +1,5 @@
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Union, TypedDict
|
||||
from typing import Dict, List, TypedDict, Union
|
||||
|
||||
from msgspec import json as msgjson
|
||||
|
||||
@ -78,7 +78,7 @@ with Path.open(MAP / rankId2Name_fileName, encoding='UTF-8') as f:
|
||||
rankId2Name = msgjson.decode(f.read(), type=Dict[str, str])
|
||||
|
||||
with Path.open(MAP / characterSkillTree_fileName, encoding='UTF-8') as f:
|
||||
characterSkillTree = msgjson.decode(f.read(), type=Dict[str, dict])
|
||||
characterSkillTree = msgjson.decode(f.read(), type=Dict[str, Dict])
|
||||
|
||||
with Path.open(MAP / avatarId2DamageType_fileName, encoding='UTF-8') as f:
|
||||
avatarId2DamageType = msgjson.decode(f.read(), type=Dict[str, str])
|
||||
@ -97,7 +97,7 @@ with Path.open(
|
||||
)
|
||||
|
||||
with Path.open(MAP / RelicSetSkill_fileName, encoding='UTF-8') as f:
|
||||
RelicSetSkill = msgjson.decode(f.read(), type=Dict[str, dict])
|
||||
RelicSetSkill = msgjson.decode(f.read(), type=Dict[str, Dict])
|
||||
|
||||
with Path.open(MAP / skillId2AttackType_fileName, encoding='UTF-8') as f:
|
||||
skillId2AttackType = msgjson.decode(f.read(), type=Dict[str, str])
|
||||
|
Loading…
x
Reference in New Issue
Block a user