v0.1.6: 时轮与造化(GameClock/RngHub/时节/年轴/保护)

- 统一时轮 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(时钟/收集器/四季/年轴/效果全矩阵/死局链/残留防御)
This commit is contained in:
2026-08-23 09:20:52 +08:00
parent 106db18017
commit a7ee125866
29 changed files with 700 additions and 49 deletions
+15 -23
View File
@@ -14,14 +14,11 @@ import { POSTS } from '../data/posts'
import { TECHNIQUES } from '../data/techniques'
import { aspirationById as aspirationOf } from '../data/aspirations'
import { computeLegacy, resolveLegacy, peakRealmIndex, grandTechniqueCount, LegacyArch } from '../core/legacy'
import { productionTick } from './systems/production'
import { deathTick, woundHealTick } from './systems/lifecycle'
import { cultivationTick, resolveBreakthrough } from './systems/cultivation'
import { missionTick } from './systems/missions'
import { eventRoll, applyEventChoice } from './systems/events'
import { diplomacyTick } from './systems/diplomacy'
import { yearStartMarriage } from './systems/marriage'
import { createWorldState, findInheritor } from './creation'
import { buildClock } from './clocks'
import { GameClock } from '../core/clock'
import { resolveBreakthrough } from './systems/cultivation'
import { applyEventChoice } from './systems/events'
import { combatPowerOf } from './systems/combat'
export type LogKind = LogItem['kind']
@@ -67,12 +64,14 @@ export class World {
state: GameState
rng: Rng
out: WorldEventBus[]
clock: GameClock
constructor(state: GameState, out: WorldEventBus[] = []) {
normalizeGameState(state)
this.state = state
this.rng = new Rng(state.rng)
this.out = out
this.clock = buildClock()
}
seq(): Id {
@@ -141,20 +140,11 @@ export class World {
if (s.month > 12) {
s.month = 1
s.year++
this.yearStart()
this.clock.fireYearStart(this)
}
s.totalTicks++
productionTick(this)
deathTick(this)
woundHealTick(this)
if (this.aliveMembers().length > 0) {
cultivationTick(this)
missionTick(this)
eventRoll(this)
diplomacyTick(this)
}
this.checkHead()
this.clock.stepMonthly(this)
const stonesEnd = s.family.stones
s.finance.accum += stonesEnd - stonesStart
this.trackStats()
@@ -186,11 +176,8 @@ export class World {
return arch
}
private yearStart(): void {
yearStartMarriage(this)
this.state.family.reputation += this.postBonus('familyRep')
const zhenCount = this.aliveMembers().filter((c) => aspirationOf(c.aspiration)?.effect.type === 'rep').length
this.state.family.reputation += Math.round(zhenCount * 0.3 * 100) / 100
publishYearReport(): void {
const rep = this.state.family.reputation
const power = this.familyPower()
const report: YearlyReport = {
@@ -210,6 +197,11 @@ export class World {
this.out.forEach((o) => o.onYearPaper?.(report))
}
epilogueTick(): void {
if (this.state.gameOver) return
this.checkHead()
}
reputationDrift(): void {
const cur = this.state.family.reputation
const drift = cur > 0 ? -1.5 : cur < 0 ? 1.2 : 0