新增插件指引网页

This commit is contained in:
2025-11-12 22:58:36 +08:00
parent 4a3beb2153
commit 7332141a92
34 changed files with 2373 additions and 8984 deletions

View File

@@ -3,13 +3,13 @@
from __future__ import annotations
import json
from typing import List, Optional, Type
from typing import Any, Dict, List, Optional, Sequence, 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,
@@ -33,6 +33,166 @@ class WPSGardenBase(WPSAPI):
_service: GardenService | None = None
_initialized: bool = False
def get_guide_subtitle(self) -> str:
return "菜园作物种植与联动系统的核心服务"
def get_guide_metadata(self) -> Dict[str, str]:
service = self.service()
config = service.config
return {
"作物数量": str(len(GARDEN_CROPS)),
"最大地块": str(config.max_plots),
"出售倍率": str(config.sale_multiplier),
}
def collect_item_entries(self) -> Sequence[GuideEntry]:
tier_counter: Dict[str, int] = {}
wine_counter: int = 0
for crop in GARDEN_CROPS.values():
tier_counter[crop.tier] = tier_counter.get(crop.tier, 0) + 1
if crop.wine_item_id:
wine_counter += 1
entries: List[GuideEntry] = []
for tier, count in sorted(tier_counter.items()):
entries.append(
{
"title": f"{tier.title()} 作物",
"description": f"{count} 种作物,可收获果实与额外奖励。",
}
)
entries.append(
{
"title": "果酒配方",
"description": f"{wine_counter} 种作物支持果酒配方,并与战斗系统的果酒增益联动。",
}
)
if GARDEN_MISC_ITEMS:
entries.append(
{
"title": "杂项素材",
"description": f"{len(GARDEN_MISC_ITEMS)} 种额外素材,可用于任务或商店出售。",
}
)
return tuple(entries)
def collect_guide_entries(self) -> Sequence[GuideEntry]:
service = self.service()
return (
{
"title": "成长流程",
"description": (
"种植后根据作物 `growth_minutes` 决定成熟时间,系统会在成熟时通过时钟任务提醒。"
),
},
{
"title": "收获收益",
"description": (
"收获基础产量由 `base_yield` 决定,额外奖励受运势与 `extra_reward` 配置影响。"
),
},
{
"title": "果实售出",
"description": (
f"通过 `菜园 售出` 指令以 {service.config.sale_multiplier} 倍种子价格出售果实并获取积分。"
),
},
)
def collect_additional_sections(self) -> Sequence[GuideSection]:
sections = list(super().collect_additional_sections())
crop_entries: List[GuideEntry] = []
tier_icon = {
"common": "🌱",
"rare": "🌳",
"epic": "🍷",
"legendary": "🏵️",
}
for crop in GARDEN_CROPS.values():
reward_desc = ""
if crop.extra_reward.kind == "points":
payload = crop.extra_reward.payload
reward_desc = (
f"额外积分 {payload.get('min', 0)}~{payload.get('max', 0)}"
f"触发率 {crop.extra_reward.base_rate*100:.0f}%"
)
elif crop.extra_reward.kind == "item":
payload = crop.extra_reward.payload
reward_desc = (
f"额外物品 `{crop.extra_item_id}` 数量 {payload.get('min', 0)}~{payload.get('max', 0)}"
f"触发率 {crop.extra_reward.base_rate*100:.0f}%"
)
details: List[Union[str, Dict[str, Any]]] = [
{
"type": "list",
"items": [
f"生长时间:{crop.growth_minutes} 分钟",
f"基础产量:{crop.base_yield} 个果实",
reward_desc or "无额外奖励",
f"种子售价:{crop.seed_price}",
],
}
]
if crop.wine_item_id:
details.append(
{
"type": "list",
"items": [
f"果酒:{crop.wine_item_id}(稀有度 {crop.wine_tier or 'rare'}",
"炼金配方:三份果实 + 炼金坩埚 → 果酒。",
],
}
)
crop_entries.append(
GuideEntry(
title=crop.display_name,
identifier=crop.seed_id,
description=f"果实 ID{crop.fruit_id}",
category="作物",
metadata={
"稀有度": crop.tier,
"果实ID": crop.fruit_id,
},
icon=tier_icon.get(crop.tier.lower(), "🌿"),
tags=(crop.tier.title(),),
details=details,
)
)
if crop_entries:
sections.append(
GuideSection(
title="作物图鉴",
entries=crop_entries,
layout="grid",
section_id="garden-crops",
description="每种作物的成长周期、产出与额外奖励说明。",
)
)
if GARDEN_MISC_ITEMS:
misc_entries: List[GuideEntry] = []
for item_id, meta in GARDEN_MISC_ITEMS.items():
misc_entries.append(
GuideEntry(
title=meta.get("name", item_id),
identifier=item_id,
description=meta.get("description", ""),
category="杂项素材",
icon="🧺",
)
)
sections.append(
GuideSection(
title="杂项素材",
entries=misc_entries,
layout="grid",
section_id="garden-misc",
description="园艺相关的任务或合成所需的特殊素材。",
)
)
return tuple(sections)
@classmethod
def service(cls) -> GardenService:
if cls._service is None:

View File

@@ -2,10 +2,11 @@
from __future__ import annotations
from typing import Optional
from typing import Optional, Sequence
from PWF.Convention.Runtime.Architecture import Architecture
from Plugins.WPSAPI import GuideEntry
from Plugins.WPSBackpackSystem import WPSBackpackSystem
from Plugins.WPSConfigSystem import WPSConfigAPI
from Plugins.WPSFortuneSystem import WPSFortuneSystem
@@ -14,6 +15,42 @@ from .garden_plugin_base import WPSGardenBase
class WPSGardenHarvest(WPSGardenBase):
def get_guide_subtitle(self) -> str:
return "收获成熟作物并处理额外奖励"
def collect_command_entries(self) -> Sequence[GuideEntry]:
return (
GuideEntry(
title="收获",
identifier="收获 <地块序号>",
description="从成熟地块采摘果实并发放额外奖励。",
metadata={"别名": "harvest"},
icon="🧺",
details=[
{
"type": "steps",
"items": [
"输入正整数地块序号。",
"系统校验成熟状态,计算基础果实数量。",
"发放额外奖励:积分或额外物品会自动结算。",
],
}
],
),
)
def collect_guide_entries(self) -> Sequence[GuideEntry]:
return (
{
"title": "指令格式",
"description": "`收获 <地块序号>`,序号需为正整数。",
},
{
"title": "收益构成",
"description": "基础果实直接入背包,额外奖励可能为积分或额外物品。",
},
)
def wake_up(self) -> None:
super().wake_up()
self.register_plugin("harvest")

View File

@@ -2,16 +2,54 @@
from __future__ import annotations
from typing import Optional
from typing import Optional, Sequence
from PWF.Convention.Runtime.Architecture import Architecture
from Plugins.WPSAPI import GuideEntry
from Plugins.WPSBackpackSystem import WPSBackpackSystem
from .garden_plugin_base import WPSGardenBase
class WPSGardenPlant(WPSGardenBase):
def get_guide_subtitle(self) -> str:
return "种植作物并分配地块"
def collect_command_entries(self) -> Sequence[GuideEntry]:
return (
GuideEntry(
title="种植",
identifier="种植 <种子> [地块序号]",
description="在指定地块种下一颗种子,默认选取下一个空地。",
metadata={"别名": "plant"},
icon="🌱",
details=[
{
"type": "steps",
"items": [
"确认背包中持有对应种子。",
"可选:指定地块序号(正整数),否则使用下一个空地。",
"系统校验库存并写入菜园数据库,生成成熟计时。",
],
},
"种植成功后立即扣除种子数量并返回成熟时间。",
],
),
)
def collect_guide_entries(self) -> Sequence[GuideEntry]:
return (
{
"title": "指令格式",
"description": "`种植 <种子ID|名称> [地块序号]`,默认选择下一个空地。",
},
{
"title": "库存校验",
"description": "会检查背包种子数量,不足时返回提示而不消耗资源。",
},
)
def wake_up(self) -> None:
super().wake_up()
self.register_plugin("plant")

View File

@@ -2,12 +2,44 @@
from __future__ import annotations
from typing import Optional
from typing import Optional, Sequence
from Plugins.WPSAPI import GuideEntry
from .garden_plugin_base import WPSGardenBase
class WPSGardenRemove(WPSGardenBase):
def get_guide_subtitle(self) -> str:
return "清理地块以重新种植"
def collect_command_entries(self) -> Sequence[GuideEntry]:
return (
GuideEntry(
title="铲除",
identifier="铲除 <地块序号>",
description="清空指定地块,移除作物与成熟计时。",
metadata={"别名": "remove"},
icon="🧹",
details=[
{
"type": "list",
"items": [
"常用于处理枯萎或不再需要的作物。",
"操作不可逆,被铲除的作物不会返还种子。",
],
}
],
),
)
def collect_guide_entries(self) -> Sequence[GuideEntry]:
return (
{
"title": "使用场景",
"description": "用于清理枯萎或不再需要的作物,释放地块。",
},
)
def wake_up(self) -> None:
super().wake_up()
self.register_plugin("remove")

View File

@@ -2,17 +2,55 @@
from __future__ import annotations
from typing import Optional
from typing import Optional, Sequence
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 .garden_plugin_base import WPSGardenBase
class WPSGardenSteal(WPSGardenBase):
def get_guide_subtitle(self) -> str:
return "偷取其他用户成熟果实的互动指令"
def collect_command_entries(self) -> Sequence[GuideEntry]:
return (
GuideEntry(
title="偷取",
identifier="偷取 <用户> <地块序号>",
description="从其他用户的成熟作物中偷取果实。",
metadata={"别名": "steal"},
icon="🕵️",
details=[
{
"type": "steps",
"items": [
"输入目标用户 ID 或昵称,以及成熟地块序号。",
"系统校验目标用户菜园与成熟状态。",
"成功后获得 1 个果实并通知对方被偷记录。",
],
},
"同一地块可多次被不同用户偷取,超限后将提示果实不足。",
],
),
)
def collect_guide_entries(self) -> Sequence[GuideEntry]:
return (
{
"title": "指令格式",
"description": "`偷取 <用户ID|昵称> <地块序号>`,不可针对自己。",
},
{
"title": "通知机制",
"description": "成功偷取后会向目标用户推送警报消息,包含剩余果实数量。",
},
)
def wake_up(self) -> None:
super().wake_up()
self.register_plugin("steal")

View File

@@ -2,10 +2,11 @@
from __future__ import annotations
from typing import Optional
from typing import Optional, Sequence
from PWF.Convention.Runtime.Architecture import Architecture
from Plugins.WPSAPI import GuideEntry
from Plugins.WPSBackpackSystem import WPSBackpackSystem
from Plugins.WPSConfigSystem import WPSConfigAPI
@@ -13,6 +14,58 @@ from .garden_plugin_base import WPSGardenBase
class WPSGardenView(WPSGardenBase):
def get_guide_subtitle(self) -> str:
return "查看菜园概览与果实售出"
def collect_command_entries(self) -> Sequence[GuideEntry]:
return (
GuideEntry(
title="菜园 概览",
identifier="菜园",
description="显示当前所有地块状态与剩余果实。",
metadata={"别名": "garden"},
icon="🗺️",
details=[
{
"type": "list",
"items": [
"列出地块序号、作物名称、成熟时间与被偷情况。",
"空地块会提示剩余可用数量。",
],
}
],
),
GuideEntry(
title="菜园 售出",
identifier="菜园 售出 <果实> <数量>",
description="售出成熟果实并换取积分。",
metadata={"别名": "garden sell"},
icon="💰",
details=[
{
"type": "steps",
"items": [
"检查背包持有的果实数量。",
"输入欲出售的果实 ID/名称与数量。",
"系统按配置的售价乘以数量发放积分,同时扣除背包库存。",
],
}
],
),
)
def collect_guide_entries(self) -> Sequence[GuideEntry]:
return (
{
"title": "概览视图",
"description": "默认输出地块编号、成熟状态、剩余果实与被偷记录。",
},
{
"title": "果实售出",
"description": "`菜园 售出 <果实> <数量>`,自动结算积分并扣除背包库存。",
},
)
def wake_up(self) -> None:
super().wake_up()
self.register_plugin("garden")