v0.1.20: 万世无谬(第二轮全量审计歼灭,1011 测试+双金钟罩)
【事件闸(机制重锤)】 - fire(w,id,priority):单闸+优先级——高优(raid/渡劫/大比)顶替被占者、被顶替入 eventQueue 下月兑现不丢失;普通被占返回 false 调用方冷却(raid 被吞也写 CD) - pending 唯一写入入口:渡劫/破境丹改走 fire(防覆盖丢弃);名宿传薪年锚 flag(防同年重复 12 次) - applyEventChoice 前置校验 pendingEvent===id(陈旧 Modal 二次结算防线) 【世界模型四修(真·活世界)】 - era 延续档:flow 权重和<1(留白=续任)——盛世能撑 30 年而非固定 25 - 潮汐供给符号修正:灵涨万物丰(原实现反了)+tide 双界 clamp - driftMarket 弱锚定:rebalance 0.1→0.025——供需/era/灾年真实撬动价格(原五池被锚死±5%) - 断供/池底单常量 poolFloorPct=0.35(消灭禁买暗雷带) 【知识防线(审计虫洞修复)】 - 指纹扩展:era/stance/prosperity/relationsWithOthers/calamityLeft/pendingEvent 全入 hash - 第二金钟罩 GOLDEN_RESOLVED:自动 resolve 长跑锁“现实”世界(原指纹锁的只是“事件流冻结”世界) 【性能与存储】 - 存档节流(疾12/常6/缓4,手动即时)+ saveChronicle O(N)→O(1) 单查增量写(2160 月档告别每 tick 数千 OPFS) - battles≤220/chronicle≤520 截断(stringify 线性膨胀止血);startNewGame/openState 停 timer 摘旧 bus 【杂项】actDirect 对齐 ACT_CATALOG 全 24 项;about 三版本统一 0.1.20;kernel.bus 死总线删;seed 改 RngHub.rollSeed;normalize 补 eraStartYear/overflux/distress;WorldPanel 买卖条件反转修复;音效与视效同闸 【测试】1011 全绿(42 套件):audit-0.1.20 9 例(事件闸/传薪/二次结算/era延续/潮汐符号/断供一致/弱锚定/指纹敏感)
This commit is contained in:
@@ -1,40 +1,17 @@
|
||||
import { GameClock } from './clock'
|
||||
import { Rng, seedToRng } from './rng'
|
||||
import { Rng, seedToRng, RngHub } from './rng'
|
||||
import type { WorldEventBus } from '../runtime/World'
|
||||
|
||||
export interface KernelBus {
|
||||
onLog: WorldEventBus['onLog']
|
||||
onChronicle: WorldEventBus['onChronicle']
|
||||
onBattle: WorldEventBus['onBattle']
|
||||
onPendingEvent: WorldEventBus['onPendingEvent']
|
||||
onGameOver: WorldEventBus['onGameOver']
|
||||
onYearPaper?: WorldEventBus['onYearPaper']
|
||||
onFx?: WorldEventBus['onFx']
|
||||
onSystemChange?: WorldEventBus['onSystemChange']
|
||||
onPluginChange?: WorldEventBus['onPluginChange']
|
||||
}
|
||||
|
||||
/** 三合一内核:游戏时钟 + 种子随机 + 事件总线(单一实例,由 GameEngine 持有) */
|
||||
/** 三合一内核:游戏时钟 + 种子随机(单一实例,由 GameEngine 持有)。
|
||||
* 注:事件转发走 World.out(WorldEventBus[]);kernel 挂钩装由 attach 保留供插件层。 */
|
||||
export class Kernel {
|
||||
readonly clock: GameClock
|
||||
readonly rng: Rng
|
||||
readonly bus: KernelBus
|
||||
private busOut: WorldEventBus[] = []
|
||||
|
||||
constructor(seed: string) {
|
||||
this.clock = new GameClock()
|
||||
this.rng = new Rng(seedToRng(seed))
|
||||
this.bus = {
|
||||
onLog: (kind, text) => this.busOut.forEach((o) => o.onLog(kind, text)),
|
||||
onChronicle: (entry, important) => this.busOut.forEach((o) => o.onChronicle(entry, important)),
|
||||
onBattle: (log) => this.busOut.forEach((o) => o.onBattle(log)),
|
||||
onPendingEvent: (id) => this.busOut.forEach((o) => o.onPendingEvent(id)),
|
||||
onGameOver: (reason, year) => this.busOut.forEach((o) => o.onGameOver(reason, year)),
|
||||
onYearPaper: (r) => this.busOut.forEach((o) => o.onYearPaper?.(r)),
|
||||
onSystemChange: (id, enabled) => this.busOut.forEach((o) => o.onSystemChange?.(id, enabled)),
|
||||
onPluginChange: (id, action) => this.busOut.forEach((o) => o.onPluginChange?.(id, action)),
|
||||
onFx: (em) => this.busOut.forEach((o) => o.onFx?.(em))
|
||||
}
|
||||
}
|
||||
|
||||
/** 注册外部订阅(每引擎一个 World 共享 bus) */
|
||||
@@ -54,5 +31,5 @@ export class Kernel {
|
||||
|
||||
/** 引擎启动统一入口(含默认种子) */
|
||||
export function makeKernel(seed?: string): Kernel {
|
||||
return new Kernel(seed ?? `cotyc-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`)
|
||||
return new Kernel(seed ?? RngHub.rollSeed())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user