1.完成战斗/冒险系统2.新增help类
This commit is contained in:
@@ -40,19 +40,11 @@ class WPSCombatEquipment(WPSCombatBase):
|
||||
message = self.parse_message_after_at(message).strip()
|
||||
|
||||
if not message:
|
||||
return await self.send_markdown_message(
|
||||
self._help_message(),
|
||||
chat_id,
|
||||
user_id
|
||||
)
|
||||
return await self._send_equipment_overview(chat_id, user_id)
|
||||
|
||||
tokens = message.split(maxsplit=1)
|
||||
if not tokens:
|
||||
return await self.send_markdown_message(
|
||||
self._help_message(),
|
||||
chat_id,
|
||||
user_id
|
||||
)
|
||||
return await self._send_equipment_overview(chat_id, user_id)
|
||||
|
||||
# 判断是装备还是卸下
|
||||
# 注意:由于命令已经通过register_plugin匹配,这里tokens[0]可能为空
|
||||
@@ -68,15 +60,21 @@ class WPSCombatEquipment(WPSCombatBase):
|
||||
|
||||
# tokens[0] 应该是物品名或槽位
|
||||
target = tokens[0] if len(tokens) > 0 else ""
|
||||
if not target:
|
||||
return await self._send_equipment_overview(chat_id, user_id)
|
||||
|
||||
if target.lower() in ["帮助", "help"]:
|
||||
return await self.send_markdown_message(
|
||||
self._help_message(),
|
||||
chat_id,
|
||||
user_id
|
||||
)
|
||||
|
||||
# 通过检查self被哪个命令触发来判断操作
|
||||
# 但这里我们无法直接知道,所以通过参数判断
|
||||
# 如果是槽位名称(weapon/helmet等),则是卸下操作
|
||||
# 否则尝试装备
|
||||
|
||||
slot_names = ["weapon", "helmet", "armor", "boots", "accessory",
|
||||
"武器", "头盔", "护甲", "鞋子", "饰品"]
|
||||
|
||||
# 简化:检查是否包含"卸下"或"unequip"
|
||||
# 由于命令注册了这些词,我们可以假设如果达到这里,就是对应的操作
|
||||
|
||||
@@ -140,6 +138,7 @@ class WPSCombatEquipment(WPSCombatBase):
|
||||
"""帮助信息"""
|
||||
return """# ⚔️ 装备管理
|
||||
**命令格式:**
|
||||
- `装备`:查看当前装备
|
||||
- `装备 <物品名>`:装备指定物品
|
||||
- `卸下 <槽位>`:卸下指定槽位的装备
|
||||
|
||||
@@ -156,4 +155,39 @@ class WPSCombatEquipment(WPSCombatBase):
|
||||
"""
|
||||
|
||||
|
||||
async def _send_equipment_overview(self, chat_id: int, user_id: int) -> Optional[str]:
|
||||
"""展示当前装备概览"""
|
||||
service = self.service()
|
||||
equipped = service.get_equipped_items(user_id)
|
||||
stats = service.calculate_player_stats(user_id)
|
||||
|
||||
slot_order = [
|
||||
("weapon", "武器"),
|
||||
("helmet", "头盔"),
|
||||
("armor", "护甲"),
|
||||
("boots", "鞋子"),
|
||||
("accessory", "饰品"),
|
||||
]
|
||||
|
||||
lines = [
|
||||
"# 🛡️ 当前装备情况",
|
||||
f"- 装备强度:`{stats.equipment_strength:.1f}`",
|
||||
"",
|
||||
"**装备栏:**",
|
||||
]
|
||||
|
||||
for slot_key, slot_name in slot_order:
|
||||
eq_def = equipped.get(slot_key) if equipped else None
|
||||
if eq_def:
|
||||
attrs = ", ".join([f"{attr}+{value}" for attr, value in eq_def.attributes.items()]) or "无属性加成"
|
||||
tier_label = eq_def.tier.to_markdown_label(eq_def.tier.display_name)
|
||||
lines.append(f"- {slot_name}:{tier_label} {eq_def.name}({attrs})")
|
||||
else:
|
||||
lines.append(f"- {slot_name}:`未装备`")
|
||||
|
||||
lines.append("\n> 使用 `装备 <物品名>` 可以直接穿戴,`卸下 <槽位>` 可卸下装备")
|
||||
|
||||
return await self.send_markdown_message("\n".join(lines), chat_id, user_id)
|
||||
|
||||
|
||||
__all__ = ["WPSCombatEquipment"]
|
||||
|
||||
Reference in New Issue
Block a user