From d231041a815b90b117967cf95b0e35d2ebeeb89a Mon Sep 17 00:00:00 2001 From: xtaodada Date: Tue, 30 Jul 2024 17:30:08 +0800 Subject: [PATCH] fix: march7th 2 --- func/fetch_avatars.py | 7 +++++- res_func/avatar.py | 19 ++++++++++++--- res_func/head_icon.py | 6 ++--- res_func/phone_theme.py | 2 +- res_func/relic.py | 54 +++++++++++++++++++++++------------------ 5 files changed, 56 insertions(+), 32 deletions(-) diff --git a/func/fetch_avatars.py b/func/fetch_avatars.py index a87c1d1..d1c80df 100644 --- a/func/fetch_avatars.py +++ b/func/fetch_avatars.py @@ -40,7 +40,12 @@ async def get_all_avatar() -> List[str]: async def fix_avatar_icon(content: Content): - avatar = all_avatars_name.get(content.title.replace("·", "•")) + key = content.title.replace("·", "•") + key_map = {"三月七": 1001, "仙舟三月七": 1224} + if key in key_map: + avatar = all_avatars_map.get(key_map[key]) + else: + avatar = all_avatars_name.get(key) if not avatar: return avatar.icon = content.icon diff --git a/res_func/avatar.py b/res_func/avatar.py index d6b0eae..7b7b378 100644 --- a/res_func/avatar.py +++ b/res_func/avatar.py @@ -1,7 +1,7 @@ import asyncio import re from pathlib import Path -from typing import Dict, List +from typing import Dict, List, Optional import aiofiles import ujson @@ -22,7 +22,7 @@ async def fetch_config() -> List[AvatarConfig]: text_map_data = await get_base_data(text_map) data = await get_base_data(avatar_config) datas = [] - for i in data.values(): + for i in data: a = AvatarConfig(**i) a.name = text_map_data[str(a.AvatarName.Hash)] datas.append(a) @@ -110,15 +110,26 @@ async def fetch_station(configs_map: Dict[str, AvatarConfig]) -> List[AvatarIcon async def fix_avatar_config_ktz(): - data_map = {"开拓者·毁灭": (8001, 8002), "开拓者·存护": (8003, 8004)} + data_map = { + "开拓者·毁灭": (8001, 8002), + "开拓者·存护": (8003, 8004), + "开拓者·同谐": (8005, 8006), + } for key, value in data_map.items(): for i in value: all_avatars_map[i].name = key +async def fix_mult_avatar_config(configs_map: Dict[str, Optional[AvatarConfig]]): + configs_map["三月七"] = None + + async def fix_avatar_config(): configs = await fetch_config() - configs_map: Dict[str, AvatarConfig] = {config.name: config for config in configs} + configs_map: Dict[str, Optional[AvatarConfig]] = { + config.name: config for config in configs + } + await fix_mult_avatar_config(configs_map) print(f"读取到原始数据:{list(configs_map.keys())}") data_path = Path("data") await read_avatars() diff --git a/res_func/head_icon.py b/res_func/head_icon.py index 55d24a3..a4f1df3 100644 --- a/res_func/head_icon.py +++ b/res_func/head_icon.py @@ -29,7 +29,7 @@ async def get_text_map() -> dict[str, str]: async def get_avatar_player_icon() -> List[AvatarPlayerIcon]: data = await get_base_data(avatar_player_icon_url) datas = [] - for i in data.values(): + for i in data: datas.append(AvatarPlayerIcon(**i)) return datas @@ -37,7 +37,7 @@ async def get_avatar_player_icon() -> List[AvatarPlayerIcon]: async def get_player_icon() -> List[PlayerIcon]: data = await get_base_data(player_icon_url) datas = [] - for i in data.values(): + for i in data: datas.append(PlayerIcon(**i)) return datas @@ -45,7 +45,7 @@ async def get_player_icon() -> List[PlayerIcon]: async def get_item_player_card() -> List[ItemPlayerCard]: data = await get_base_data(item_player_card_url) datas = [] - for i in data.values(): + for i in data: datas.append(ItemPlayerCard(**i)) return datas diff --git a/res_func/phone_theme.py b/res_func/phone_theme.py index 73c7058..4e732f8 100644 --- a/res_func/phone_theme.py +++ b/res_func/phone_theme.py @@ -17,7 +17,7 @@ async def get_phone_theme() -> List[PhoneThemeConfig]: data = await get_base_data(phone_theme_url) datas = [] - for i in data.values(): + for i in data: datas.append(PhoneThemeConfig(**i)) return datas diff --git a/res_func/relic.py b/res_func/relic.py index 844fdb3..dd87959 100644 --- a/res_func/relic.py +++ b/res_func/relic.py @@ -7,7 +7,6 @@ from models.enums import RelicAffix, RelicPosition from models.relic_affix import RelicAffixAll, SingleRelicAffix from res_func.base_data import get_base_data -from res_func.client import client from res_func.url import relic_config, relic_main_affix_config, relic_sub_affix_config final_datas: List[RelicAffixAll] = [] @@ -17,7 +16,8 @@ async def fetch_all_relic(): print("开始获取遗器配置") relic_data = await get_base_data(relic_config) - for key, value in relic_data.items(): + for value in relic_data: + key = value["ID"] relic_affix_all = RelicAffixAll( id=int(key), set_id=value["SetID"], @@ -38,16 +38,20 @@ async def fetch_main_affix(): print("开始获取遗器主词条配置") main_affix_data = await get_base_data(relic_main_affix_config) main_affix_groups_map: Dict[str, Dict[str, SingleRelicAffix]] = {} - for key, value in main_affix_data.items(): - data: Dict[str, SingleRelicAffix] = {} - for key2, value2 in value.items(): - data[key2] = SingleRelicAffix( - id=value2["AffixID"], - property=RelicAffix(value2["Property"]), - base_value=value2["BaseValue"]["Value"], - level_value=value2["LevelAdd"]["Value"], - is_main=True, - ) + for value in main_affix_data: + key = str(value["GroupID"]) + data: Dict[str, SingleRelicAffix] = main_affix_groups_map.get(key, {}) + + value2 = value + key2 = str(value2["AffixID"]) + data[key2] = SingleRelicAffix( + id=value2["AffixID"], + property=RelicAffix(value2["Property"]), + base_value=value2["BaseValue"]["Value"], + level_value=value2["LevelAdd"]["Value"], + is_main=True, + ) + main_affix_groups_map[key] = data for final_data in final_datas: final_data.main_affix = main_affix_groups_map[str(final_data.main_affix_group)] @@ -58,17 +62,21 @@ async def fetch_sub_affix(): print("开始获取遗器副词条配置") sub_affix_data = await get_base_data(relic_sub_affix_config) sub_affix_groups_map: Dict[str, Dict[str, SingleRelicAffix]] = {} - for key, value in sub_affix_data.items(): - data: Dict[str, SingleRelicAffix] = {} - for key2, value2 in value.items(): - data[key2] = SingleRelicAffix( - id=value2["AffixID"], - property=RelicAffix(value2["Property"]), - base_value=value2["BaseValue"]["Value"], - step_value=value2["StepValue"]["Value"], - is_main=False, - max_step=value2["StepNum"], - ) + for value in sub_affix_data: + key = str(value["GroupID"]) + data: Dict[str, SingleRelicAffix] = sub_affix_groups_map.get(key, {}) + + value2 = value + key2 = str(value2["AffixID"]) + data[key2] = SingleRelicAffix( + id=value2["AffixID"], + property=RelicAffix(value2["Property"]), + base_value=value2["BaseValue"]["Value"], + step_value=value2["StepValue"]["Value"], + is_main=False, + max_step=value2["StepNum"], + ) + sub_affix_groups_map[key] = data for final_data in final_datas: final_data.sub_affix = sub_affix_groups_map[str(final_data.sub_affix_group)]