【世界模型:世界会死人也会新生】 - 家族生灭:declineYears(power<58+景气<38 连续8年)→ 覆灭(最强邻分食+史官广播)+ 新贵补位(6%/年,乱世×2) —— NPC 永远四家铁打的现状终结;玩家补刀(raid×0.82)可加速衰亡 - npcById 双源可空(静态+动态注册表;不再 throw——15 处消费者防御化) - purgeNpc 全局清理(raidCD/事件队列/恩怨网/distress/动态 def) - 秘境产出回池(loot 20% 经 tradeSettle 回流)——资源循环最后单向封口 - WorldSnapshot 只读摘要门面(UI/史书消费,零行为变更) - 潮汐长波(10 年正弦 ±0.08 叠加,灵潮三十年河东) 【插件生态化(0.1.8 后第一次大进化)】 - 持久化:GameState.plugins 落盘 + PLUGIN_REGISTRY 读档重装(engineFromSnapshot 真实路径验证) - plugin-public.ts 公共导出面(第三方单入口+纪律) - 双闸:能力卡随插件启停联动;池自动回滚 - 契约补完:Proxy 追踪(池/卡/pack 自动回滚)+ onUninstall 真调 + 能力卡入 World 实例(防跨档泄漏) - SettingsPanel 启停按钮/依赖详情;demo 与 tests 去重(发现并修复:npcById 双源静态源未绑定——全局 NPC 停滞回归) 【测试】1027 全绿(44 套件):dynasty-plugin 7 例(覆灭/新贵/回池/快照/持久化/双闸/自动回滚); 金钟罩 0.1.23 基线固化;build 通过
57 lines
2.3 KiB
TypeScript
57 lines
2.3 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { stateFingerprint, longRun } from './fingerprint.helper'
|
|
import { World } from '../src/renderer/game/engine/runtime/World'
|
|
|
|
/**
|
|
* 金钟罩:固定种子长跑 560 月的状态指纹。
|
|
* 任何改动(重构日程/调平衡/加系统)若改变了确定性序列或结果,此测试立刻报红。
|
|
* 更新规则:仅当**有意**变更序列逻辑时,三枚 seed 指纹同版更新并注明原因。
|
|
*/
|
|
// 0.1.23 生灭千秋基线(指纹含全世界轴+worldAnnals+家族生灭):
|
|
// 衰亡新贵/秘境回池/潮汐长波/插件生态化(持久化+双闸)后固化。
|
|
const GOLDEN: Record<string, Record<number, string>> = {
|
|
'bell-seed-1': { 560: '855600f5', 1200: 'e131b7d5', 2160: '7917ba3c' },
|
|
'bell-seed-2': { 560: '0184ccc8', 1200: 'ff36b9f7', 2160: '5fb6e896' },
|
|
'bell-seed-3': { 560: '2ecc7add', 1200: '62cfabdc', 2160: '4e0654ff' }
|
|
}
|
|
|
|
/** 第二金钟罩:自动 resolve 长跑("现实"世界——每 tick 处理待决事件;
|
|
* 锁事件闸/事件流全程,防"冻结世界"指纹漏锁)。 */
|
|
const GOLDEN_RESOLVED: Record<string, Record<number, string>> = {
|
|
'bell-seed-1': { 560: 'c17a9f82', 1200: 'cdcbbce9', 2160: '9abdd687' },
|
|
'bell-seed-2': { 560: '800674c1', 1200: 'c1ac7282', 2160: '4826c188' },
|
|
'bell-seed-3': { 560: '2c2ac417', 1200: 'ef9c3e4a', 2160: '2980499a' }
|
|
}
|
|
|
|
const TIERS = [
|
|
[560, '47 年(4 个十年)'],
|
|
[1200, '100 年'],
|
|
[2160, '180 年']
|
|
] as const
|
|
|
|
describe('金钟罩 · 长跑确定性指纹(三档:47/100/180 年)', () => {
|
|
for (const [seed, tiers] of Object.entries(GOLDEN)) {
|
|
for (const [months, label] of TIERS) {
|
|
it(`${seed} ${label}指纹 === ${tiers[months]}`, () => {
|
|
const w = run(seed, months)
|
|
expect(stateFingerprint(w.state)).toBe(tiers[months])
|
|
})
|
|
}
|
|
}
|
|
|
|
it('同 seed 两次长跑指纹一致(无状态污染)', () => {
|
|
const a = stateFingerprint(longRun('bell-seed-1').state)
|
|
const b = stateFingerprint(longRun('bell-seed-1').state)
|
|
expect(a).toBe(b)
|
|
})
|
|
})
|
|
|
|
function run(seed: string, months: number): ReturnType<typeof longRun> {
|
|
const w = World.create({ seed, surname: '钟', familyName: '钟家', motto: 'm', difficulty: 'normal' })
|
|
for (let i = 0; i < months; i++) {
|
|
if (w.state.gameOver) break
|
|
w.advanceMonth()
|
|
}
|
|
return w
|
|
}
|