105 lines
3.6 KiB
Python
105 lines
3.6 KiB
Python
"""状态查看插件 - 显示玩家属性、装备和技能"""
|
||
|
||
from __future__ import annotations
|
||
|
||
from typing import Optional
|
||
|
||
from PWF.Convention.Runtime.Config import *
|
||
from PWF.Convention.Runtime.GlobalConfig import ConsoleFrontColor, ProjectConfig
|
||
from Plugins.WPSCombatSystem.combat_models import PlayerStats, EquipmentDefinition
|
||
from .combat_plugin_base import WPSCombatBase
|
||
|
||
|
||
logger: ProjectConfig = ProjectConfig()
|
||
|
||
|
||
class WPSCombatStatus(WPSCombatBase):
|
||
"""状态查看插件"""
|
||
|
||
def is_enable_plugin(self) -> bool:
|
||
return True
|
||
|
||
def wake_up(self) -> None:
|
||
super().wake_up()
|
||
logger.Log(
|
||
"Info",
|
||
f"{ConsoleFrontColor.GREEN}WPSCombatStatus 插件已加载{ConsoleFrontColor.RESET}"
|
||
)
|
||
self.register_plugin("战斗属性")
|
||
self.register_plugin("combat")
|
||
self.register_plugin("装备栏")
|
||
self.register_plugin("技能列表")
|
||
|
||
async def callback(self, message: str, chat_id: int, user_id: int) -> Optional[str]:
|
||
"""
|
||
处理状态查看命令
|
||
|
||
命令格式:
|
||
- 战斗属性:显示完整属性和装备
|
||
- 装备栏:只显示装备
|
||
- 技能列表:只显示技能
|
||
"""
|
||
message = self.parse_message_after_at(message).strip()
|
||
|
||
service = self.service()
|
||
|
||
# 根据具体命令显示不同内容
|
||
# 这里简化为都显示完整状态
|
||
stats = service.calculate_player_stats(user_id)
|
||
equipped = service.get_equipped_items(user_id)
|
||
|
||
# 格式化输出
|
||
output = self._format_status(stats, equipped)
|
||
|
||
return await self.send_markdown_message(output, chat_id, user_id)
|
||
|
||
def _format_status(self, stats: PlayerStats, equipped: Dict[str, Optional[EquipmentDefinition]]) -> str:
|
||
"""格式化状态输出"""
|
||
lines = ["# ⚔️ 战斗属性"]
|
||
|
||
# 基础属性
|
||
lines.append("\n**基础属性:**")
|
||
lines.append(f"- HP:`{stats.hp}`")
|
||
lines.append(f"- ATK:`{stats.atk}`")
|
||
lines.append(f"- DEF:`{stats.def_}`")
|
||
lines.append(f"- SPD:`{stats.spd}`")
|
||
lines.append(f"- CRIT:`{stats.crit}%`")
|
||
lines.append(f"- CRIT_DMG:`{stats.crit_dmg}%`")
|
||
lines.append(f"- 装备强度:`{stats.equipment_strength:.1f}`")
|
||
|
||
# 装备栏
|
||
lines.append("\n**装备栏:**")
|
||
slot_names = {
|
||
"weapon": "武器",
|
||
"helmet": "头盔",
|
||
"armor": "护甲",
|
||
"boots": "鞋子",
|
||
"accessory": "饰品",
|
||
}
|
||
|
||
for slot, eq_def in equipped.items():
|
||
slot_display = slot_names.get(slot, slot)
|
||
if eq_def:
|
||
# 显示装备属性
|
||
attrs = ", ".join([f"{k}+{v}" for k, v in eq_def.attributes.items()])
|
||
tier_label = eq_def.tier.to_markdown_label(eq_def.tier.display_name)
|
||
lines.append(f"- {slot_display}:{tier_label} {eq_def.name} ({attrs})")
|
||
else:
|
||
lines.append(f"- {slot_display}:`未装备`")
|
||
|
||
# 可用技能
|
||
lines.append("\n**可用技能:**")
|
||
if stats.available_skills:
|
||
for skill in stats.available_skills:
|
||
lines.append(f"- {skill.icon} **{skill.name}**")
|
||
lines.append(f" - {skill.description}")
|
||
if skill.cooldown > 0:
|
||
lines.append(f" - 冷却:{skill.cooldown}回合")
|
||
else:
|
||
lines.append("- `无可用技能`")
|
||
|
||
return "\n".join(lines)
|
||
|
||
|
||
__all__ = ["WPSCombatStatus"]
|