新增菜园陷阱
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from typing import Any, Dict, List, Optional, Sequence, Type, Union, override
|
||||
from typing import Any, Dict, List, Optional, Sequence, Tuple, Type, Union, override
|
||||
|
||||
from PWF.Convention.Runtime.Architecture import Architecture
|
||||
from PWF.Convention.Runtime.GlobalConfig import ConsoleFrontColor, ProjectConfig
|
||||
@@ -23,6 +23,7 @@ from .garden_models import (
|
||||
GARDEN_CROPS,
|
||||
GARDEN_FRUITS,
|
||||
GARDEN_MISC_ITEMS,
|
||||
GARDEN_TRAPS,
|
||||
GardenCropDefinition,
|
||||
get_garden_db_models,
|
||||
)
|
||||
@@ -291,6 +292,59 @@ class WPSGardenBase(WPSAPI):
|
||||
BackpackItemTier.COMMON,
|
||||
meta.get("description", ""),
|
||||
)
|
||||
|
||||
# 注册陷阱物品
|
||||
for trap in GARDEN_TRAPS:
|
||||
trap_tier = tier_map.get(trap.tier.lower(), BackpackItemTier.RARE)
|
||||
self._safe_register_item(
|
||||
backpack,
|
||||
trap.item_id,
|
||||
trap.display_name,
|
||||
trap_tier,
|
||||
trap.description,
|
||||
)
|
||||
|
||||
# 注册陷阱的炼金合成配方
|
||||
# 获取稀有树木的木材ID
|
||||
ginkgo_crop = GARDEN_CROPS.get("garden_seed_ginkgo")
|
||||
sakura_crop = GARDEN_CROPS.get("garden_seed_sakura")
|
||||
maple_crop = GARDEN_CROPS.get("garden_seed_maple")
|
||||
|
||||
# 防盗网:矿石 + 银杏木材 + 樱花木材
|
||||
if ginkgo_crop and sakura_crop and ginkgo_crop.extra_item_id and sakura_crop.extra_item_id:
|
||||
self._safe_register_trap_recipe(
|
||||
alchemy,
|
||||
("combat_material_ore", ginkgo_crop.extra_item_id, sakura_crop.extra_item_id),
|
||||
"garden_trap_net",
|
||||
0.75, # 75%成功率
|
||||
)
|
||||
|
||||
# 荆棘陷阱:宝石 + 红枫木材 + 银杏木材
|
||||
if maple_crop and ginkgo_crop and maple_crop.extra_item_id and ginkgo_crop.extra_item_id:
|
||||
self._safe_register_trap_recipe(
|
||||
alchemy,
|
||||
("combat_material_gem", maple_crop.extra_item_id, ginkgo_crop.extra_item_id),
|
||||
"garden_trap_thorn",
|
||||
0.70, # 70%成功率
|
||||
)
|
||||
|
||||
# 魔法结界:水晶 + 两种木材
|
||||
if ginkgo_crop and sakura_crop and ginkgo_crop.extra_item_id and sakura_crop.extra_item_id:
|
||||
self._safe_register_trap_recipe(
|
||||
alchemy,
|
||||
("combat_material_crystal", ginkgo_crop.extra_item_id, sakura_crop.extra_item_id),
|
||||
"garden_trap_magic",
|
||||
0.65, # 65%成功率
|
||||
)
|
||||
|
||||
# 传奇守护:精华 + 水晶 + 红枫木材
|
||||
if maple_crop and maple_crop.extra_item_id:
|
||||
self._safe_register_trap_recipe(
|
||||
alchemy,
|
||||
("combat_material_essence", "combat_material_crystal", maple_crop.extra_item_id),
|
||||
"garden_trap_legend",
|
||||
0.60, # 60%成功率
|
||||
)
|
||||
|
||||
logger.Log(
|
||||
"Info",
|
||||
@@ -393,6 +447,24 @@ class WPSGardenBase(WPSAPI):
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _safe_register_trap_recipe(
|
||||
self,
|
||||
alchemy: WPSAlchemyGame,
|
||||
materials: Tuple[str, str, str],
|
||||
result_item_id: str,
|
||||
success_rate: float,
|
||||
) -> None:
|
||||
"""注册陷阱的炼金合成配方"""
|
||||
try:
|
||||
alchemy.register_recipe(
|
||||
materials,
|
||||
result_item_id,
|
||||
"alchemy_ash", # 失败产物是炉灰
|
||||
success_rate,
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
async def _clock_mark_mature(self, user_id: int, chat_id: int, plot_index: int) -> None:
|
||||
service = self.service()
|
||||
@@ -454,9 +526,16 @@ class WPSGardenBase(WPSAPI):
|
||||
if is_mature:
|
||||
remaining = plot["remaining_fruit"]
|
||||
theft_users = len(json.loads(plot["theft_users"])) if plot.get("theft_users") else 0
|
||||
trap_info = ""
|
||||
if plot.get("trap_item_id"):
|
||||
trap_durability = int(plot.get("trap_durability", 0))
|
||||
from .garden_models import GARDEN_TRAPS_DICT
|
||||
trap = GARDEN_TRAPS_DICT.get(plot["trap_item_id"])
|
||||
if trap:
|
||||
trap_info = f"|陷阱:{trap.display_name}({trap_durability}次)"
|
||||
status = f"✅ 已成熟(成熟于 {formatted_time})"
|
||||
lines.append(
|
||||
f"- 地块 {idx}|{name}|{status}|剩余果实 {remaining}|被偷次数 {theft_users}"
|
||||
f"- 地块 {idx}|{name}|{status}|剩余果实 {remaining}|被偷次数 {theft_users}{trap_info}"
|
||||
)
|
||||
else:
|
||||
status = f"⌛ 生长中,预计成熟 {formatted_time}"
|
||||
|
||||
Reference in New Issue
Block a user