- 统一时轮 GameClock:七 phase 注册制(production/aging/cultivation/missions/ events/diplomacy/epilogue) + 年首三钩子(婚配→岁贡→族簿);advanceMonth 化作薄壳; 新增系统只注册不改本体;alive 守卫、随机序、族簿时序均与重构前逐一等价 - 金钟罩:3 枚 seed × 560 月指纹常驻(重构前后已验证同哈希;时节属有意变更后重固化) - 统一随机 RngHub:开局播种(crypto UV)、音效白噪独立流、引擎 rng 带 nextCount 审计; 全工程拔除逻辑侧 Math.random - 时节系统:春夏秋冬乘子(春田+10%/夏修+5%/秋市+5%/冬闭+8%)入生产与修炼 - 崩溃保护:advance 异常自动存『出险前』档 + 停速提示回档 - 性能预算:dev-only 单 tick>60ms 报最慢 phase - 横轴年表:十年一格大事/生殇聚合 + 春秋原年轴视图 - 测试 197→225(时钟/收集器/四季/年轴/效果全矩阵/死局链/残留防御)
46 lines
1.8 KiB
TypeScript
46 lines
1.8 KiB
TypeScript
import { GameClock } from '../core/clock'
|
|
import { productionTick } from './systems/production'
|
|
import { deathTick, woundHealTick } from './systems/lifecycle'
|
|
import { cultivationTick } from './systems/cultivation'
|
|
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 {
|
|
return (w: World) => {
|
|
if (w.aliveMembers().length > 0) fn(w)
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 装备时钟:年度钩子与月度 phase 的注册顺序即执行顺序(确定性)。
|
|
* 时间线:婚配养育 → 声望岁贡 → 岁末族簿 —— 再逐月:生产→寿元→修炼→任务→事件→外交→收尾
|
|
*/
|
|
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.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('epilogue', (w: World) => w.epilogueTick())
|
|
|
|
return clock
|
|
}
|