v0.1.8: 万物皆是插件 + 全应用审计修复(60+ 缺陷歼灭)
插件协议:
- CotycPlugin Manifest(dependencies/conflicts/protected/install/uninstall)
- PluginManager:安装序确定性/依赖拒绝/异常回滚/追踪型上下文(卸载全摘钩子)
- 三核心插件常驻(Systems/Data/Events);插件清单/安装移除/启停广播
- EventPoolRegistry 多池合并;facade about/query('plugins')/plugin 订阅
- 设置页插件清单(含卸载按钮、核心保护);examplePlugin 开发范本入仓
全应用审计修复(引擎 39 + UI/主进程 40 双路清单,P0→P2 歼灭):
- P0:单亲 rollRoots 崩/插件事件软锁(findEvent 查池)/fire 覆盖幸存事件/
facade 未赋值(act 目录 6/24 生效→全量接通)/packOverride 死实现真接管/
4 能力卡无接线(trib/apprentice/tournament/season)/读档 rowid 方言崩溃/
buildApprentice 空候选崩/插件安装无回滚/trait 加成从未消费/DEV 双跑破坏时序
- P1:定时器幸存/advance in-flight 闸/battle 暂停/tournament 点将真传/
史书 memo 依赖/面板 hooks 顺序违规/远征 squad 残留 id/跨档状态残留/
toast 自清除/读档错误提示/导入后重载世界/pendingEvent 读档回填
- P2:版本三处统一/NewGame 随机收编/学费错误文案/姓氏池去重/
功法品阶错位(凡阶哨兵)/功法定价对齐/market 白名单校验/
战利功法去重/回声漏封缄/clock 迭代快照/core 事件池保护/
渡劫陨落走真突破/寄读 desc 诚实化/doas 死代码清理等 30 项
测试 239→256;金钟罩复验(防御批零漂移)
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import { GameClock } from '../core/clock'
|
||||
import { PluginContext } from '../core/plugin'
|
||||
import type { World } from './world'
|
||||
import { productionTick } from './systems/production'
|
||||
import { deathTick, woundHealTick } from './systems/lifecycle'
|
||||
import { cultivationTick } from './systems/cultivation'
|
||||
@@ -6,7 +8,6 @@ import { missionTick } from './systems/missions'
|
||||
import { eventRoll } from './systems/events'
|
||||
import { diplomacyTick } from './systems/diplomacy'
|
||||
import { yearStartMarriage } from './systems/marriage'
|
||||
import type { World } from './world'
|
||||
|
||||
/** 原语义保留:满门凋零后仅存生产/寿元与收尾 */
|
||||
function ifAlive(fn: (w: World) => void): (w: World) => void {
|
||||
@@ -22,33 +23,59 @@ function viaCap(capId: string, fn: (w: World) => void): (w: World) => void {
|
||||
}
|
||||
}
|
||||
|
||||
export function emptyClock(): GameClock {
|
||||
return new GameClock()
|
||||
}
|
||||
|
||||
/**
|
||||
* 装备时钟:年度钩子与月度 phase 的注册顺序即执行顺序(确定性)。
|
||||
* 内建系统注册(core-systems 插件入口)。
|
||||
* 注册顺序 = 执行顺序(确定性红线,经由金钟罩校验)。
|
||||
* 时间线:婚配养育 → 声望岁贡 → 岁末族簿 —— 再逐月:生产→寿元→修炼→任务→事件→外交→收尾
|
||||
*/
|
||||
export function buildClock(): GameClock {
|
||||
const clock = new GameClock()
|
||||
export function installCoreSystems(ctx: PluginContext): Array<() => void> {
|
||||
const unsubs: Array<() => void> = []
|
||||
const clock = ctx.clock
|
||||
|
||||
clock.onYearStart(viaCap('marriage', (w) => yearStartMarriage(w)))
|
||||
clock.onYearStart(
|
||||
viaCap('marriage', (w) => {
|
||||
w.state.family.reputation += w.postBonus('familyRep')
|
||||
const zhenCount = w
|
||||
.aliveMembers()
|
||||
.filter((c) => c.aspiration === 'zhen').length
|
||||
w.state.family.reputation += Math.round(zhenCount * 0.3 * 100) / 100
|
||||
})
|
||||
unsubs.push(clock.onYearStart(viaCap('marriage', (w) => yearStartMarriage(w))))
|
||||
unsubs.push(
|
||||
clock.onYearStart(
|
||||
viaCap('marriage', (w) => {
|
||||
w.state.family.reputation += w.postBonus('familyRep')
|
||||
const zhenCount = w.aliveMembers().filter((c) => c.aspiration === 'zhen').length
|
||||
w.state.family.reputation += Math.round(zhenCount * 0.3 * 100) / 100
|
||||
})
|
||||
)
|
||||
)
|
||||
clock.onYearStart(viaCap('annals', (w) => w.publishYearReport()))
|
||||
unsubs.push(clock.onYearStart(viaCap('annals', (w) => w.publishYearReport())))
|
||||
|
||||
clock.register('production', viaCap('production', (w: World) => productionTick(w)))
|
||||
clock.register('aging', viaCap('aging', (w: World) => deathTick(w)))
|
||||
clock.register('aging', viaCap('aging', (w: World) => woundHealTick(w)))
|
||||
clock.register('cultivation', viaCap('cultivation', ifAlive((w: World) => cultivationTick(w))))
|
||||
clock.register('missions', viaCap('missions', ifAlive((w: World) => missionTick(w))))
|
||||
clock.register('events', viaCap('events', ifAlive((w: World) => eventRoll(w))))
|
||||
clock.register('diplomacy', viaCap('diplomacy', ifAlive((w: World) => diplomacyTick(w))))
|
||||
clock.register('epilogue', (w: World) => w.epilogueTick())
|
||||
unsubs.push(clock.register('production', viaCap('production', (w: World) => productionTick(w))))
|
||||
unsubs.push(clock.register('aging', viaCap('aging', (w: World) => deathTick(w))))
|
||||
unsubs.push(clock.register('aging', viaCap('aging', (w: World) => woundHealTick(w))))
|
||||
unsubs.push(clock.register('cultivation', viaCap('cultivation', ifAlive((w: World) => cultivationTick(w)))))
|
||||
unsubs.push(clock.register('missions', viaCap('missions', ifAlive((w: World) => missionTick(w)))))
|
||||
unsubs.push(clock.register('events', viaCap('events', ifAlive((w: World) => eventRoll(w)))))
|
||||
unsubs.push(clock.register('diplomacy', viaCap('diplomacy', ifAlive((w: World) => diplomacyTick(w)))))
|
||||
unsubs.push(clock.register('epilogue', (w: World) => w.epilogueTick()))
|
||||
|
||||
return unsubs
|
||||
}
|
||||
|
||||
/** 兼容旧接口:完整安装一套核心系统(测试/工具用) */
|
||||
export function buildClock(): GameClock {
|
||||
const clock = emptyClock()
|
||||
const ctx = {
|
||||
world: undefined as never,
|
||||
clock,
|
||||
register: (phase: Parameters<GameClock['register']>[0], fn: (w: World) => void) => clock.register(phase, fn),
|
||||
onYearStart: (fn: (w: World) => void) => clock.onYearStart(fn),
|
||||
addCapability: () => undefined,
|
||||
removeCapability: () => undefined,
|
||||
enableCapability: () => undefined,
|
||||
overridePack: () => undefined,
|
||||
resetPack: () => undefined,
|
||||
addEventPool: () => undefined,
|
||||
removeEventPool: () => undefined
|
||||
}
|
||||
installCoreSystems(ctx as never)
|
||||
return clock
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user