v0.1.7: 仙门之钥(门面化/能力注册表/数据包/开发者面板)

- GameFacade 统一门面:act(23 种动作白名单)/query(6 类只读快照)/subscribe(七大事件协议)/
  about(版本+模块清单+数据包指纹);UI store 接入门面(act 直达,散装调用收口)
- CapabilityRegistry:12 张能力卡(id/name/version/desc/hooks),world.systems 启停即拔插,
  时钟按能力开关过滤(禁修炼则无人精进…沙盒玩法);sysChanged 广播
- DataPackRegistry:默认包与静态数据同引用(金钟罩零漂移),override/reset/fingerprint,
  高频读口 6 处迁移 pack()——未来 MOD=注入数据包覆写
- 开发者面板:设置页系统仪表盘(清单+启停开关+警示文案)
- 测试 225→239(能力清单/拔插分殊四路/广播幂等/包覆盖物价/act 目录/query/协议退订/about/
  金钟罩复验零漂移)
This commit is contained in:
2026-08-23 09:32:21 +08:00
parent a7ee125866
commit 9e0b06e898
11 changed files with 543 additions and 29 deletions
+25 -16
View File
@@ -15,6 +15,13 @@ function ifAlive(fn: (w: World) => void): (w: World) => void {
}
}
/** 能力开关:禁用即拔插(对应 capability id */
function viaCap(capId: string, fn: (w: World) => void): (w: World) => void {
return (w: World) => {
if (w.sysEnabled(capId)) fn(w)
}
}
/**
* 装备时钟:年度钩子与月度 phase 的注册顺序即执行顺序(确定性)。
* 时间线:婚配养育 → 声望岁贡 → 岁末族簿 —— 再逐月:生产→寿元→修炼→任务→事件→外交→收尾
@@ -22,23 +29,25 @@ function ifAlive(fn: (w: World) => void): (w: World) => void {
export function buildClock(): GameClock {
const clock = new GameClock()
clock.onYearStart((w) => yearStartMarriage(w))
clock.onYearStart((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((w) => w.publishYearReport())
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
})
)
clock.onYearStart(viaCap('annals', (w) => w.publishYearReport()))
clock.register('production', (w: World) => productionTick(w))
clock.register('aging', (w: World) => deathTick(w))
clock.register('aging', (w: World) => woundHealTick(w))
clock.register('cultivation', ifAlive((w: World) => cultivationTick(w)))
clock.register('missions', ifAlive((w: World) => missionTick(w)))
clock.register('events', ifAlive((w: World) => eventRoll(w)))
clock.register('diplomacy', ifAlive((w: World) => diplomacyTick(w)))
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())
return clock