diff --git a/src/renderer/game/core/plugin.ts b/src/renderer/game/core/plugin.ts index 2ca9fad..60b2124 100644 --- a/src/renderer/game/core/plugin.ts +++ b/src/renderer/game/core/plugin.ts @@ -49,6 +49,7 @@ export interface PluginStatus { installed: boolean enabled: boolean protected: boolean + description: string dependencies?: string[] } diff --git a/src/renderer/game/engine/demo-plugins.ts b/src/renderer/game/engine/demo-plugins.ts new file mode 100644 index 0000000..65e52fe --- /dev/null +++ b/src/renderer/game/engine/demo-plugins.ts @@ -0,0 +1,46 @@ +import { CotycPlugin } from '../core/plugin' + +/** 示例内容插件:注入事件池 + 一个护山能力(开发范本) */ +export const examplePlugin: CotycPlugin = { + id: 'demo-peaks', + name: '护山妖兽', + version: '0.1.0', + author: 'demo', + description: '示例插件:山鬼妖气事件与护山之力(+2% 战力)。', + kind: 'content', + install(ctx) { + ctx.addCapability({ id: 'demo-guardian', name: '护山之力', version: '0.1.0', desc: '示例:年首山灵庇佑,全族修为小幅精进。' }) + ctx.onYearStart((w) => { + if (w.sysEnabled('demo-guardian')) { + for (const c of w.aliveMembers()) { + c.realmProgress = Math.min(100, c.realmProgress + 1.5) + } + } + }) + ctx.addEventPool('demo-peaks', [ + { + id: 'ev-demo-guardian', + name: '山鬼怒吼', + category: 'daily', + weight: 3, + text: '夜半山鸣,护山兽影现身墙外——莫非是山中精怪在拜望?', + options: [{ label: '蒸饼供奉', hint: '声望+2', eff: { rep: 2 } }] + } + ]) + }, + uninstall(ctx) { + ctx.removeEventPool('demo-peaks') + ctx.removeCapability('demo-guardian') + } +} + +/** 依赖缺失的坏插件:应被拒绝安装 */ +export const brokenPlugin: CotycPlugin = { + id: 'demo-broken', + name: '依赖断链的插件', + version: '0.1.0', + kind: 'events', + description: '故意缺少依赖的示例插件(安装应被拒绝)。', + dependencies: ['demo-not-exists'], + install() {} +} diff --git a/src/renderer/game/engine/pluginManager.ts b/src/renderer/game/engine/pluginManager.ts index 3de2d73..dc9f58c 100644 --- a/src/renderer/game/engine/pluginManager.ts +++ b/src/renderer/game/engine/pluginManager.ts @@ -116,6 +116,7 @@ export class PluginManager { installed: rt.status.installed, enabled: rt.status.enabled, protected: !!p.protected, + description: p.description, dependencies: p.dependencies } }) diff --git a/src/renderer/ui/panels/SettingsPanel.tsx b/src/renderer/ui/panels/SettingsPanel.tsx index fe9a188..b884476 100644 --- a/src/renderer/ui/panels/SettingsPanel.tsx +++ b/src/renderer/ui/panels/SettingsPanel.tsx @@ -1,4 +1,7 @@ import { useGameStore } from '../store' +import { examplePlugin } from '../../game/engine/demo-plugins' +import { SYSTEM_DEFS } from '../../game/engine/capabilities' +import { buildBiography } from '../../game/core/biography' export default function SettingsPanel() { const world = useGameStore((s) => s.world) @@ -15,89 +18,181 @@ export default function SettingsPanel() { const setSpeed = useGameStore((s) => s.setSpeed) const soundOn = useGameStore((s) => s.soundOn) const toggleSound = useGameStore((s) => s.toggleSound) + const setNextToast = useGameStore((s) => s.setNextToast) if (!world) return null + const hasDemo = world.pluginList().some((p) => p.id === 'demo-peaks') + return ( -
-
存档与导出
-
- 手动存点(当前第 {slot} 档) - -
-
- 回档时间轴(每季自动快照,最近12份) - -
- {snapshots.length > 0 ? ( -
- {snapshots.slice(0, 12).map((sn, i) => ( -
- - {sn.year}年{sn.month}月{sn.label !== '自动' ? ` · ${sn.label}` : ''} - {sn.year === world.state.year && sn.month === world.state.month ? '(当前)' : ''} - - +
+ {/* ===== 插件层:万物皆是插件的实证窗口 ===== */} +
+
插件层(manifest 清单)
+
+ 「万物皆是插件」:系统 / 数据包 / 事件池统一走 CotycPlugin 协议。核心三插件受保护常驻, + 第三方插件可随时安装/卸载(卸载即全摘钩子)。点击下方体验按钮,立刻注入一个真实插件—— + 事件「山鬼怒吼」将在消息池中定期浮现,同时年首添『护山之力』。 +
+
+ {world.pluginList().map((p) => ( +
+
{p.id}
+
+ {p.name} + + v{p.version} · {p.kind} · {p.description} + +
+
+ + {p.protected ? '核心' : p.enabled ? '已启用' : '已停用'} + + {!p.protected && ( + + )} +
))}
- ) : ( -
尚未生成快照(推进时间或保存后自动出现)
- )} -
- 导出存档(JSON 文件) - + {!hasDemo && ( + + )}
-
- 导入存档到当前位置 - + + {/* ===== 系统仪表盘:12 能力卡启停 ===== */} +
+
系统仪表盘(能力卡 · 12 张启停)
+
+ {SYSTEM_DEFS.map((s) => { + const enabled = world.sysEnabled(s.id) + return ( +
+
+ {s.name} + {s.id} v{s.version} +
+
{s.desc}
+ +
+ ) + })} +
-
- 刷新存档槽 - + + {/* ===== 存档与导出 ===== */} +
+
存档与导出
+ + + + + + + + + + + {snapshots.slice(0, 12).map((sn, i) => ( + + + + + ))} + + + + + + + + + + + + + + + + + + + + + +
手动存点(当前第 {slot} 档)
回档时间轴(每季自动快照,最近12份)
+ {sn.year}年{sn.month}月{sn.label !== '自动' ? ` · ${sn.label}` : ''} + {sn.year === world.state.year && sn.month === world.state.month ? '(当前)' : ''} + + +
导出存档(JSON 文件)
导入存档到当前位置
音效(合成音:鼓点·钟鸣·纸韵) + +
暂停时间
回到主菜单(会先自动保存) + +
-
- 音效(合成音:鼓点·钟鸣·纸韵) - + +
+
玩法说明
+
+ · 日常以「月」流转:成员修炼、建筑产出、往事兴替、事件沓来。
+ · 「宗」字牌成员可闭关、服丹、冲击瓶颈;瓶颈即修为满百者,成功率看灵气、丹药与家主督学。
+ · 「探秘」选人结队远行,途中见战报;凯旋带回灵石、法帖、法器诸宝。
+ · 「外交」与四邻结好联姻;仇雠之族隔岁来犯,打得赢名望大涨,打不赢蚀钱伤丁。
+ · 「史书」自动记述繁华与凋零——百年之后,后人翻开这一卷家族志,见代代薪火、历历雪泥。 +
+
版本 0.1.12 · Chronicle of the Immortal Clan
-
- 暂停时间 - -
-
- 回到主菜单(会先自动保存) - -
-
玩法说明
-
- · 日常以「月」流转:成员修炼、建筑产出、往事兴替、事件沓来。
- · 「宗」字牌成员可闭关、服丹、冲击瓶颈;瓶颈即修为满百者,成功率看灵气、丹药与家主督学。
- · 「探秘」选人结队远行,途中见战报;凯旋带回灵石、法帖、法器诸宝。
- · 「外交」与四邻结好联姻;仇雠之族隔岁来犯,打得赢名望大涨,打不赢蚀钱伤丁。
- · 「史书」自动记述繁华与凋零——百年之后,后人翻开这一卷家族志,见代代薪火、历历雪泥。 -
-
版本 0.1.11 · Chronicle of the Immortal Clan
) } + +void buildBiography diff --git a/src/renderer/ui/store.ts b/src/renderer/ui/store.ts index 038afb4..2827efc 100644 --- a/src/renderer/ui/store.ts +++ b/src/renderer/ui/store.ts @@ -61,6 +61,7 @@ export interface GameStore { toggleSound: () => void facade?: GameFacade advancing: boolean + setNextToast: (msg: string) => void act: (name: ActName, payload: import('../game/engine/api').ActPayload) => boolean } @@ -87,6 +88,7 @@ function stopTimer(): void { export const useGameStore = create((set, get) => ({ facade: undefined as GameFacade | undefined, advancing: false, + setNextToast: (msg: string) => setNextToast(msg), screen: 'boot', world: null, slot: 1, diff --git a/src/renderer/ui/styles.css b/src/renderer/ui/styles.css index 10063e6..95ba226 100644 --- a/src/renderer/ui/styles.css +++ b/src/renderer/ui/styles.css @@ -1374,16 +1374,91 @@ body { /* ============================================================ 设置 & 杂项 ============================================================ */ -.set-row { +.settings-wrap { + max-width: 100%; +} +.settings-card { + margin-bottom: 16px; + background: rgba(20, 15, 9, 0.6); + border: 1px solid rgba(120, 98, 55, 0.3); +} +.settings-table { + width: 100%; + border-collapse: collapse; +} +.settings-table td { + padding: 9px 8px; + border-bottom: 1px dashed rgba(144, 122, 76, 0.25); + color: #cdbd97; + font-size: 0.95rem; +} +.settings-table td:last-child { + width: 220px; + text-align: right; + white-space: nowrap; +} +.settings-table tr:hover td { + background: rgba(201, 162, 39, 0.04); +} +/* 插件行网格 */ +.plugin-grid { + display: grid; + grid-template-columns: 1fr; + gap: 6px; + margin-bottom: 10px; +} +.plugin-row { display: flex; align-items: center; - justify-content: space-between; gap: 12px; - padding: 11px 4px; - border-bottom: 1px dashed rgba(144, 122, 76, 0.3); - max-width: 660px; - color: #cdbd97; - font-size: 0.96rem; + padding: 9px 12px; + background: rgba(242, 233, 212, 0.05); + border: 1px solid rgba(120, 98, 55, 0.25); + border-radius: 3px; +} +.plugin-id { + font-size: 0.78rem; + color: #8a7f6a; + background: rgba(0, 0, 0, 0.25); + padding: 2px 8px; + border-radius: 2px; + flex-shrink: 0; +} +.plugin-info { + flex: 1; + min-width: 0; +} +.plugin-actions { + display: flex; + align-items: center; + gap: 6px; + flex-shrink: 0; +} +.plugin-row.proto { + border-left: 2px solid var(--gold); +} +/* 系统能力卡网格(12 张,填满宽度消除右侧空白) */ +.sys-grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); + gap: 8px; +} +.sys-cell { + background: rgba(242, 233, 212, 0.05); + border: 1px solid rgba(120, 98, 55, 0.25); + border-radius: 3px; + padding: 8px 10px; + display: flex; + flex-direction: column; + gap: 4px; +} +.sys-cell.off { + opacity: 0.55; +} +.sys-head { + display: flex; + justify-content: space-between; + align-items: baseline; } .toast { diff --git a/tests/helpers/examplePlugin.ts b/tests/helpers/examplePlugin.ts index 77945cf..cc8fcf9 100644 --- a/tests/helpers/examplePlugin.ts +++ b/tests/helpers/examplePlugin.ts @@ -1,4 +1,4 @@ -import { CotycPlugin } from '../src/renderer/game/core/plugin' +import { CotycPlugin } from '../../src/renderer/game/core/plugin' /** 示例内容插件:注入事件池 + 一个护山能力(开发范本) */ export const examplePlugin: CotycPlugin = {