Skip to content

Commit

Permalink
fix: march7th 2
Browse files Browse the repository at this point in the history
  • Loading branch information
omg-xtao committed Jul 30, 2024
1 parent 90df0ff commit d231041
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 32 deletions.
7 changes: 6 additions & 1 deletion func/fetch_avatars.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 15 additions & 4 deletions res_func/avatar.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions res_func/head_icon.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@ 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


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


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

Expand Down
2 changes: 1 addition & 1 deletion res_func/phone_theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
54 changes: 31 additions & 23 deletions res_func/relic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] = []
Expand All @@ -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"],
Expand All @@ -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)]
Expand All @@ -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)]
Expand Down

0 comments on commit d231041

Please sign in to comment.