新增插件指引网页
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user