new:MCP及openapi新增技能特殊属性查询

This commit is contained in:
2026-06-12 13:22:09 +08:00
parent d17d340c20
commit 729e08046d
7 changed files with 91 additions and 15 deletions
+39
View File
@@ -0,0 +1,39 @@
import json
from pathlib import Path
from database.connect import BACKEND_DIR
SKILL_TREE_WITH_DESC_SPECIAL_VERSION = 'skillTreeWithDescSpecial:v1'
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'
detail_dir = skill_tree_path.parent / 'skillDetail'
with skill_tree_path.open(encoding='utf-8') as file:
skills_data = json.load(file)
for skill in skills_data:
skill_id = skill.get('skillId')
desc_special = None
if skill_id:
detail_path = detail_dir / f'{skill_id}.json'
if detail_path.exists():
with detail_path.open(encoding='utf-8') as file:
desc_special = json.load(file).get('descSpecial')
skill['descSpecial'] = desc_special
return skills_data
def filter_skill_tree_by_desc_special(skills_data: list[dict], desc_special: str) -> list[dict]:
if not desc_special:
return skills_data
print(f'Filtering skills by descSpecial: {desc_special}')
print(skills_data)
return [
skill
for skill in skills_data
if any(desc_special in item for item in (skill.get('descSpecial') or []))
]