v0.1.23: 生灭千秋 + 插件生态化第一课(1027 全绿)
【世界模型:世界会死人也会新生】 - 家族生灭:declineYears(power<58+景气<38 连续8年)→ 覆灭(最强邻分食+史官广播)+ 新贵补位(6%/年,乱世×2) —— NPC 永远四家铁打的现状终结;玩家补刀(raid×0.82)可加速衰亡 - npcById 双源可空(静态+动态注册表;不再 throw——15 处消费者防御化) - purgeNpc 全局清理(raidCD/事件队列/恩怨网/distress/动态 def) - 秘境产出回池(loot 20% 经 tradeSettle 回流)——资源循环最后单向封口 - WorldSnapshot 只读摘要门面(UI/史书消费,零行为变更) - 潮汐长波(10 年正弦 ±0.08 叠加,灵潮三十年河东) 【插件生态化(0.1.8 后第一次大进化)】 - 持久化:GameState.plugins 落盘 + PLUGIN_REGISTRY 读档重装(engineFromSnapshot 真实路径验证) - plugin-public.ts 公共导出面(第三方单入口+纪律) - 双闸:能力卡随插件启停联动;池自动回滚 - 契约补完:Proxy 追踪(池/卡/pack 自动回滚)+ onUninstall 真调 + 能力卡入 World 实例(防跨档泄漏) - SettingsPanel 启停按钮/依赖详情;demo 与 tests 去重(发现并修复:npcById 双源静态源未绑定——全局 NPC 停滞回归) 【测试】1027 全绿(44 套件):dynasty-plugin 7 例(覆灭/新贵/回池/快照/持久化/双闸/自动回滚); 金钟罩 0.1.23 基线固化;build 通过
This commit is contained in:
@@ -1,45 +1,15 @@
|
||||
import { CotycPlugin } from '../../src/renderer/game/engine/kernel/plugin'
|
||||
// 0.1.23 去重:示例插件以 runtime/demo-plugins.ts 为唯一源
|
||||
import { examplePlugin } from '../../src/renderer/game/engine/runtime/demo-plugins'
|
||||
export { examplePlugin }
|
||||
|
||||
/** 示例内容插件:注入事件池 + 一个护山能力(开发范本) */
|
||||
export const examplePlugin: CotycPlugin = {
|
||||
id: 'demo-peaks',
|
||||
name: '护山妖兽',
|
||||
version: '0.1.0',
|
||||
author: 'demo',
|
||||
description: '示例插件:山鬼妖气事件与护山之力(+2% 战力)。',
|
||||
/** 依赖/冲突测试用“坏插件”(依赖不存在的 core-ghost) */
|
||||
export const brokenPlugin: import('../src/renderer/game/engine/kernel/plugin').CotycPlugin = {
|
||||
id: 'broken-ghost',
|
||||
name: '幽灵依赖',
|
||||
version: '0.0.0',
|
||||
description: 'testing',
|
||||
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')
|
||||
}
|
||||
dependencies: ['core-ghost'],
|
||||
install() { return undefined }
|
||||
}
|
||||
|
||||
/** 依赖缺失的坏插件:应被拒绝安装 */
|
||||
export const brokenPlugin: CotycPlugin = {
|
||||
id: 'demo-broken',
|
||||
name: '依赖断链的插件',
|
||||
version: '0.1.0',
|
||||
kind: 'events',
|
||||
dependencies: ['demo-not-exists'],
|
||||
install() {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user