新增菜园陷阱
This commit is contained in:
@@ -9,6 +9,7 @@ from PWF.Convention.Runtime.Architecture import Architecture
|
||||
from PWF.CoreModules.database import get_db
|
||||
from Plugins.WPSAPI import GuideEntry
|
||||
from Plugins.WPSBackpackSystem import WPSBackpackSystem
|
||||
from Plugins.WPSConfigSystem import WPSConfigAPI
|
||||
|
||||
from .garden_plugin_base import WPSGardenBase
|
||||
|
||||
@@ -89,12 +90,36 @@ class WPSGardenSteal(WPSGardenBase):
|
||||
backpack.add_item(user_id, crop.fruit_id, result["stolen_quantity"])
|
||||
|
||||
remaining = result["remaining"]
|
||||
trap_result = result.get("trap_result")
|
||||
|
||||
# 处理陷阱触发
|
||||
if trap_result:
|
||||
trap = trap_result["trap"]
|
||||
config_api: WPSConfigAPI = Architecture.Get(WPSConfigAPI)
|
||||
# 扣除罚金
|
||||
current_points = config_api.get_user_points(user_id)
|
||||
actual_fine = min(trap_result["fine_points"], current_points)
|
||||
if actual_fine > 0:
|
||||
await config_api.adjust_user_points(
|
||||
chat_id, user_id, -actual_fine, f"触发陷阱罚金:{trap.display_name}"
|
||||
)
|
||||
|
||||
# 发送陷阱触发消息给偷盗者
|
||||
trap_message = (
|
||||
f"# 🚨 陷阱触发\n"
|
||||
f"{trap_result['trigger_message']}\n"
|
||||
f"- 扣除罚金:{actual_fine} 分"
|
||||
)
|
||||
await self.send_markdown_message(trap_message, chat_id, user_id)
|
||||
|
||||
message = (
|
||||
"# 🕵️ 偷取成功\n"
|
||||
f"- 目标:{crop.display_name}\n"
|
||||
f"- 获得:{crop.display_name}的果实 × {result['stolen_quantity']}\n"
|
||||
f"- 目标剩余果实:{remaining}"
|
||||
)
|
||||
if trap_result:
|
||||
message += f"\n- ⚠️ 注意:你触发了陷阱!"
|
||||
await self.send_markdown_message(message, chat_id, user_id)
|
||||
|
||||
owner_chat = result.get("chat_id")
|
||||
@@ -104,6 +129,13 @@ class WPSGardenSteal(WPSGardenBase):
|
||||
f"- 你的 {crop.display_name} 被偷走了 1 个果实\n"
|
||||
f"- 当前剩余果实:{remaining}"
|
||||
)
|
||||
if trap_result:
|
||||
trap = trap_result["trap"]
|
||||
durability = trap_result.get("durability", 0)
|
||||
if trap_result.get("durability_exhausted", False):
|
||||
owner_message += f"\n- 🎯 你的{trap.display_name}成功触发了!但陷阱耐久度已耗尽并被移除。"
|
||||
else:
|
||||
owner_message += f"\n- 🎯 好消息:你的{trap.display_name}成功触发了!剩余耐久度:{durability}次"
|
||||
await self.send_markdown_message(owner_message, owner_chat, owner_id)
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user