新增插件指引网页
This commit is contained in:
@@ -2,13 +2,13 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import List, Type
|
||||
from typing import Dict, List, Type, Union
|
||||
|
||||
from PWF.Convention.Runtime.Architecture import Architecture
|
||||
from PWF.Convention.Runtime.GlobalConfig import ConsoleFrontColor, ProjectConfig
|
||||
from PWF.CoreModules.plugin_interface import DatabaseModel
|
||||
|
||||
from Plugins.WPSAPI import WPSAPI
|
||||
from Plugins.WPSAPI import GuideEntry, GuideSection, WPSAPI
|
||||
from Plugins.WPSBackpackSystem import BackpackItemTier, WPSBackpackSystem
|
||||
from Plugins.WPSStoreSystem import WPSStoreSystem
|
||||
from Plugins.WPSConfigSystem import WPSConfigAPI
|
||||
@@ -46,6 +46,270 @@ class WPSCombatBase(WPSAPI):
|
||||
|
||||
_service: CombatService | None = None
|
||||
_initialized: bool = False
|
||||
|
||||
def collect_additional_sections(self) -> Sequence[GuideSection]:
|
||||
sections = list(super().collect_additional_sections())
|
||||
|
||||
equipment_entries = self._build_equipment_entries()
|
||||
if equipment_entries:
|
||||
sections.append(
|
||||
GuideSection(
|
||||
title="装备详单",
|
||||
entries=equipment_entries,
|
||||
layout="grid",
|
||||
section_id="combat-equipment",
|
||||
description="战斗系统预置的装备清单及属性效果。",
|
||||
)
|
||||
)
|
||||
|
||||
potion_entries = self._build_simple_item_entries(
|
||||
COMBAT_POTIONS,
|
||||
category="战斗药剂",
|
||||
)
|
||||
if potion_entries:
|
||||
sections.append(
|
||||
GuideSection(
|
||||
title="药剂与增益",
|
||||
entries=potion_entries,
|
||||
layout="grid",
|
||||
section_id="combat-potions",
|
||||
description="药剂品质影响价格与效果,部分由冒险掉落。",
|
||||
)
|
||||
)
|
||||
|
||||
material_entries = self._build_simple_item_entries(
|
||||
ADVENTURE_MATERIALS,
|
||||
category="冒险材料",
|
||||
)
|
||||
if material_entries:
|
||||
sections.append(
|
||||
GuideSection(
|
||||
title="冒险材料",
|
||||
entries=material_entries,
|
||||
layout="grid",
|
||||
section_id="combat-materials",
|
||||
description="材料主要来源于冒险战斗,稀有度决定获取概率。",
|
||||
)
|
||||
)
|
||||
|
||||
souvenir_entries = self._build_souvenir_entries()
|
||||
if souvenir_entries:
|
||||
sections.append(
|
||||
GuideSection(
|
||||
title="纪念品一览",
|
||||
entries=souvenir_entries,
|
||||
layout="grid",
|
||||
section_id="combat-souvenirs",
|
||||
description="纪念品可在营地或商店出售兑换积分。",
|
||||
)
|
||||
)
|
||||
|
||||
seed_entries = self._build_simple_item_entries(
|
||||
ADVENTURE_SEEDS,
|
||||
category="冒险种子",
|
||||
)
|
||||
if seed_entries:
|
||||
sections.append(
|
||||
GuideSection(
|
||||
title="冒险种子",
|
||||
entries=seed_entries,
|
||||
layout="grid",
|
||||
section_id="combat-seeds",
|
||||
description="冒险专属种子,可在菜园种植获取增益或任务物资。",
|
||||
)
|
||||
)
|
||||
|
||||
skill_entries = self._build_skill_entries()
|
||||
if skill_entries:
|
||||
sections.append(
|
||||
GuideSection(
|
||||
title="技能图鉴",
|
||||
entries=skill_entries,
|
||||
layout="list",
|
||||
section_id="combat-skills",
|
||||
description="装备附带的技能可在战斗中释放,冷却时间以回合计算。",
|
||||
)
|
||||
)
|
||||
|
||||
return tuple(sections)
|
||||
|
||||
def _format_tier(self, tier: BackpackItemTier) -> str:
|
||||
return f"{tier.display_name}"
|
||||
|
||||
def _build_equipment_entries(self) -> List[GuideEntry]:
|
||||
entries: List[GuideEntry] = []
|
||||
attr_names = {
|
||||
"HP": "生命值",
|
||||
"ATK": "攻击力",
|
||||
"DEF": "防御力",
|
||||
"SPD": "速度",
|
||||
"CRIT": "暴击率",
|
||||
"CRIT_DMG": "暴击伤害",
|
||||
}
|
||||
tier_icons = {
|
||||
BackpackItemTier.COMMON: "⚔️",
|
||||
BackpackItemTier.RARE: "🛡️",
|
||||
BackpackItemTier.EPIC: "🔥",
|
||||
BackpackItemTier.LEGENDARY: "🌟",
|
||||
}
|
||||
for eq in EQUIPMENT_REGISTRY.values():
|
||||
attr_list = []
|
||||
for key, value in eq.attributes.items():
|
||||
label = attr_names.get(key, key)
|
||||
suffix = "%" if key in ("CRIT", "CRIT_DMG") else ""
|
||||
attr_list.append(f"{label}+{value}{suffix}")
|
||||
skills = []
|
||||
for skill_id in eq.skill_ids:
|
||||
skill = SKILL_REGISTRY.get(skill_id)
|
||||
if skill:
|
||||
skills.append(f"{skill.icon} {skill.name}")
|
||||
metadata = {
|
||||
"槽位": eq.slot,
|
||||
"稀有度": self._format_tier(eq.tier),
|
||||
}
|
||||
details: List[Dict[str, Any] | str] = []
|
||||
if attr_list:
|
||||
details.append({"type": "list", "items": attr_list})
|
||||
if skills:
|
||||
details.append({"type": "list", "items": [f"技能:{info}" for info in skills]})
|
||||
if eq.description:
|
||||
details.append(eq.description)
|
||||
entries.append(
|
||||
GuideEntry(
|
||||
title=eq.name,
|
||||
identifier=eq.item_id,
|
||||
description=eq.description or "标准装备。",
|
||||
category="装备",
|
||||
metadata=metadata,
|
||||
icon=tier_icons.get(eq.tier, "⚔️"),
|
||||
tags=skills,
|
||||
details=details,
|
||||
)
|
||||
)
|
||||
return entries
|
||||
|
||||
def _build_simple_item_entries(
|
||||
self,
|
||||
registry: Dict[str, tuple],
|
||||
*,
|
||||
category: str,
|
||||
) -> List[GuideEntry]:
|
||||
entries: List[GuideEntry] = []
|
||||
icon_map = {
|
||||
"战斗药剂": "🧪",
|
||||
"冒险材料": "🪨",
|
||||
"纪念品": "🎖️",
|
||||
"冒险种子": "🌱",
|
||||
}
|
||||
for item_id, payload in registry.items():
|
||||
name, tier, *rest = payload
|
||||
description = rest[-1] if rest else ""
|
||||
metadata = {"稀有度": self._format_tier(tier)}
|
||||
if category == "战斗药剂":
|
||||
price_lookup = {
|
||||
BackpackItemTier.COMMON: 50,
|
||||
BackpackItemTier.RARE: 150,
|
||||
BackpackItemTier.EPIC: 500,
|
||||
}
|
||||
price = price_lookup.get(tier)
|
||||
if price:
|
||||
metadata["默认售价"] = f"{price} 分"
|
||||
entries.append(
|
||||
GuideEntry(
|
||||
title=name,
|
||||
identifier=item_id,
|
||||
description=description,
|
||||
category=category,
|
||||
metadata=metadata,
|
||||
icon=icon_map.get(category, "📦"),
|
||||
)
|
||||
)
|
||||
return entries
|
||||
|
||||
def _build_souvenir_entries(self) -> List[GuideEntry]:
|
||||
entries: List[GuideEntry] = []
|
||||
for item_id, (name, tier, price, desc) in ADVENTURE_SOUVENIRS.items():
|
||||
entries.append(
|
||||
GuideEntry(
|
||||
title=name,
|
||||
identifier=item_id,
|
||||
description=desc,
|
||||
category="纪念品",
|
||||
metadata={
|
||||
"稀有度": self._format_tier(tier),
|
||||
"基础售价": f"{price} 分",
|
||||
},
|
||||
icon="🎖️",
|
||||
)
|
||||
)
|
||||
return entries
|
||||
|
||||
def _build_skill_entries(self) -> List[GuideEntry]:
|
||||
entries: List[GuideEntry] = []
|
||||
for skill in SKILL_REGISTRY.values():
|
||||
details: List[Union[str, Dict[str, Any]]] = [
|
||||
{"type": "list", "items": [effect.get("description", str(effect)) for effect in skill.effects]},
|
||||
]
|
||||
if skill.cooldown:
|
||||
details.append(f"冷却:{skill.cooldown} 回合")
|
||||
entries.append(
|
||||
GuideEntry(
|
||||
title=skill.name,
|
||||
identifier=skill.skill_id,
|
||||
description=skill.description,
|
||||
category="技能",
|
||||
icon=skill.icon,
|
||||
metadata={},
|
||||
details=details,
|
||||
)
|
||||
)
|
||||
return entries
|
||||
|
||||
def get_guide_subtitle(self) -> str:
|
||||
return "冒险、战斗与装备体系的基础能力"
|
||||
|
||||
def get_guide_metadata(self) -> Dict[str, str]:
|
||||
return {
|
||||
"装备数量": str(len(EQUIPMENT_REGISTRY)),
|
||||
"药剂数量": str(len(COMBAT_POTIONS)),
|
||||
"纪念品数量": str(len(ADVENTURE_SOUVENIRS)),
|
||||
"冒险材料": str(len(ADVENTURE_MATERIALS)),
|
||||
}
|
||||
|
||||
def collect_item_entries(self) -> Sequence[GuideEntry]:
|
||||
return (
|
||||
{
|
||||
"title": "装备库",
|
||||
"description": f"{len(EQUIPMENT_REGISTRY)} 件装备,自动注册至背包并带有属性描述。",
|
||||
},
|
||||
{
|
||||
"title": "药剂与材料",
|
||||
"description": (
|
||||
f"{len(COMBAT_POTIONS)} 种药剂、{len(ADVENTURE_MATERIALS)} 种冒险素材,"
|
||||
"部分可在商店购买或冒险获得。"
|
||||
),
|
||||
},
|
||||
{
|
||||
"title": "纪念品",
|
||||
"description": f"{len(ADVENTURE_SOUVENIRS)} 种纪念品可在营地出售换取积分。",
|
||||
},
|
||||
)
|
||||
|
||||
def collect_guide_entries(self) -> Sequence[GuideEntry]:
|
||||
return (
|
||||
{
|
||||
"title": "冒险流程",
|
||||
"description": "冒险按阶段推进,使用食物缩短时间并依赖运势与装备强度影响结果。",
|
||||
},
|
||||
{
|
||||
"title": "装备体系",
|
||||
"description": "装备提供属性与技能加成,通过 `装备`/`战斗属性` 等指令查看详情。",
|
||||
},
|
||||
{
|
||||
"title": "积分与资源",
|
||||
"description": "冒险和战斗会产出积分、装备、材料等,通过商店与营地完成循环。",
|
||||
},
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def service(cls) -> CombatService:
|
||||
|
||||
Reference in New Issue
Block a user