国服特色数据修正
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
from pathlib import Path
|
||||
|
||||
from database.connect import BACKEND_DIR
|
||||
|
||||
|
||||
OPENAPI_DATA_DIR = BACKEND_DIR / 'openapi' / 'data'
|
||||
LOCALES = {'cn', 'kr'}
|
||||
|
||||
|
||||
def openapi_locale_path(locale: str, job_id: str, job_grow_id: str, *parts: str) -> Path:
|
||||
return OPENAPI_DATA_DIR / locale / job_id / job_grow_id / Path(*parts)
|
||||
|
||||
|
||||
def logical_skill_detail_path(prefix: str) -> Path:
|
||||
parts = prefix.split('/')
|
||||
if len(parts) < 5 or parts[2] not in LOCALES:
|
||||
return OPENAPI_DATA_DIR / f'{prefix}.json'
|
||||
|
||||
job_id, job_grow_id, locale = parts[:3]
|
||||
return openapi_locale_path(locale, job_id, job_grow_id, *parts[3:]).with_suffix('.json')
|
||||
|
||||
|
||||
def logical_skill_detail_prefix(path: Path) -> str:
|
||||
relative = path.relative_to(OPENAPI_DATA_DIR).with_suffix('')
|
||||
parts = relative.parts
|
||||
if len(parts) >= 5 and parts[0] in LOCALES:
|
||||
locale, job_id, job_grow_id = parts[:3]
|
||||
return '/'.join((job_id, job_grow_id, locale, *parts[3:]))
|
||||
|
||||
return relative.as_posix()
|
||||
@@ -1,14 +1,30 @@
|
||||
import json
|
||||
from functools import cache
|
||||
from pathlib import Path
|
||||
|
||||
from api.utils.openapi_data import openapi_locale_path
|
||||
from database.connect import BACKEND_DIR
|
||||
|
||||
|
||||
SKILL_TREE_WITH_DESC_SPECIAL_VERSION = 'skillTreeWithDescSpecial:v1'
|
||||
SKILL_TREE_NAME_MAP_VERSION = 'skillTreeNameMap:v1'
|
||||
|
||||
|
||||
@cache
|
||||
def load_skill_tree_name_map(job_id: str, job_grow_id: str) -> dict[str, str]:
|
||||
skill_tree_path = openapi_locale_path('cn', job_id, job_grow_id, 'skill_tree.json')
|
||||
with skill_tree_path.open(encoding='utf-8') as file:
|
||||
skills_data = json.load(file)
|
||||
|
||||
return {
|
||||
str(skill['id']): skill['name']
|
||||
for skill in skills_data
|
||||
if skill.get('id') is not None and skill.get('name') is not None
|
||||
}
|
||||
|
||||
|
||||
def load_skill_tree_with_desc_special(job_id: str, job_grow_id: str) -> list[dict]:
|
||||
skill_tree_path = BACKEND_DIR / 'openapi' / 'data' / job_id / job_grow_id / 'cn' / 'skill_tree.json'
|
||||
skill_tree_path = openapi_locale_path('cn', job_id, job_grow_id, 'skill_tree.json')
|
||||
detail_dir = skill_tree_path.parent / 'skillDetail'
|
||||
|
||||
with skill_tree_path.open(encoding='utf-8') as file:
|
||||
|
||||
Reference in New Issue
Block a user