Files
ChronicleOfTheImmortalClan/src/renderer/game/engine/runtime/demo-plugins.ts
T
thzxx ff6df8054c refactor(0.1.14-P1): 内核归位——game/ 按引擎架构重排(零行为漂移)
结构(旧 game/core+engine → 新 engine/ 域):
- engine/kernel/  时钟/随机/插件协议/fxqueue/timesense/format/urgency/guide/names(原 core)
- engine/narrative/  legacy/报告/列传/谱系/年轴(原 core 叙事族)
- engine/runtime/   World/creation/pcgen/ApiFacade/capabilities/pluginManager/boot/clocks + Systems/*(12 系统)
- engine/sim/     Market(未来 WorldSim 同行)
- 旧 game/core、engine/systems、engine/world.ts 等路径全部废弃(无 re-export 兼容层)

验证:35 套件/967 测试全绿(金钟罩三档零漂移=纯搬迁无行为变化)
typecheck 0 error
2026-08-23 13:23:25 +08:00

47 lines
1.5 KiB
TypeScript

import { CotycPlugin } from '../kernel/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() {}
}