v0.1.18: 时代绘卷 + 特效入引擎(双主线完成,1002 测试破千)

【主线一:世界自演进深化《时代绘卷》】
- 世纪弧 era 状态机:盛世/平世/乱世/末法四态(ERA_CONF 全参数化)。
  灾年概率×0.5~1.6、世界供需×0.7~1.25、拍卖概率×0.6~1.3、tide 偏置 ±0.09;
  ERA_DURA 控制转换节奏(15~45年),转移时史官快讯+log。世界有大节律了
- NPC 景气仓廪:npcDyn.prosperity(8~100)月结余——买卖+0.5~0.8、断供-2、灾年-3;
  >75 景气 power+1、<30 衰闷 power-1;换代焕新(55~75)。NPC 在过日子
- 蝴蝶效应:互攻胜率 power 加权(强者恒强)、打残广播(败家邻望-8/胜家+4);
  玩家劫掠胜利/结盟直接写 NPC·NPC 关系网(-6/-3)——玩家行动推进世界历史
- 天下十年一鉴:每十年史官综述(灾/换代/行情/灵潮聚合,kind='annal')
- 灾年↔秘境:灾年灵脉恢复减半(末法感)
- WorldPanel 天下志:era 徽标(悬停描述)/史官十年鉴/群雄势衡柱状图/衰微标注

【主线二:特效系统并入引擎(架构升级)】
- WorldEventBus.onFx + Kernel 转发 + World.emitFx 语义发射(零 rng 消耗)
- 12 个语义发射点:突破/化神/渡劫/劫掠胜负/遭遇战/拍卖/大比/灾年起散/换代
  —— 取代 UI log 文本正则猜测(spark/blade 双源锁死)
- makeBus 桥接 FxGate(kind→gate.emit),gate 挡位/密度/reduced 逻辑保留在 UI

【测试】1002 全绿(40 套件):fxqueue-semantic 3 例 + era-world 5 例;
金钟罩 0.1.18 基线固化(era/prosperity/蝴蝶效应受控变更)
This commit is contained in:
2026-08-23 14:38:27 +08:00
parent ea9f5c9c5d
commit 2f62eecb08
20 changed files with 347 additions and 41 deletions
+2 -2
View File
@@ -82,7 +82,7 @@ describe('审计回归:P0 修复固化', () => {
})
it('防御性修补后金钟罩不变(行为等价确认)', () => {
expect(stateFingerprint(longRun('bell-seed-1').state)).toBe('c923fdd1')
expect(stateFingerprint(longRun('bell-seed-3').state)).toBe('5edde2cd')
expect(stateFingerprint(longRun('bell-seed-1').state)).toBe('d07ebe85')
expect(stateFingerprint(longRun('bell-seed-3').state)).toBe('ecdc62da')
})
})
+5 -5
View File
@@ -7,12 +7,12 @@ import { World } from '../src/renderer/game/engine/runtime/World'
* 任何改动(重构日程/调平衡/加系统)若改变了确定性序列或结果,此测试立刻报红。
* 更新规则:仅当**有意**变更序列逻辑时,三枚 seed 指纹同版更新并注明原因。
*/
// 0.1.17 世界真炉膛基线:市场实体化(供给/需求呼吸+NPC上桌+玩家买卖回写)
// + NPC博弈(互攻/关系网/战争伤骨)+ 灾年持续化后固化。
// 0.1.18 时代绘卷基线:世纪弧 era 状态机(四态/调制)+ NPC 景气 prosperity
// + 蝴蝶效应(互攻加权/打残广播/玩家行动写关系网)+ 十年一鉴后固化。
const GOLDEN: Record<string, Record<number, string>> = {
'bell-seed-1': { 560: 'c923fdd1', 1200: '2cb58265', 2160: 'a367ba40' },
'bell-seed-2': { 560: 'e98eb9fa', 1200: '3dd495e9', 2160: '17a588c2' },
'bell-seed-3': { 560: '5edde2cd', 1200: '476512f7', 2160: 'bc2d55d8' }
'bell-seed-1': { 560: 'd07ebe85', 1200: '32d9267f', 2160: '046967c9' },
'bell-seed-2': { 560: '3fcec396', 1200: '3c40f605', 2160: 'b3ec6229' },
'bell-seed-3': { 560: 'ecdc62da', 1200: '562bd778', 2160: '6ebb02a3' }
}
const TIERS = [
+64
View File
@@ -0,0 +1,64 @@
import { describe, expect, it } from 'vitest'
import { World } from '../src/renderer/game/engine/runtime/World'
import { ERA_CONF, WorldSimState } from '../src/renderer/game/engine/sim/worldsim-data'
import { combatPowerOf } from '../src/renderer/game/engine/runtime/Systems/combat'
describe('0.1.18 时代绘卷', () => {
it('世纪弧状态机恒定在四态内且会转移', () => {
const w = World.create({ seed: 'era-1', surname: '姜', familyName: '姜家', motto: 'm', difficulty: 'normal' })
let seen = new Set<string>()
let lastEra = ''
for (let i = 0; i < 2400; i++) {
if (w.state.gameOver) break
w.advanceMonth()
const ws = w.state.worldSim as WorldSimState
const e = ws.era ?? 'pingshi'
expect(Object.keys(ERA_CONF)).toContain(e)
if (e !== lastEra) {
seen.add(e)
lastEra = e
}
}
expect(seen.size).toBeGreaterThanOrEqual(2) // 200 年内至少转移过一次
})
it('NPC 景气存在且随断供/灾年受挫(值域 8~100)', () => {
const w = World.create({ seed: 'era-2', surname: '路', familyName: '路家', motto: 'm', difficulty: 'normal' })
for (let i = 0; i < 600; i++) w.advanceMonth()
const dyns = (w.state.worldSim as WorldSimState).npcDyn
for (const d of Object.values(dyns)) {
expect(d.prosperity).toBeGreaterThanOrEqual(8)
expect(d.prosperity).toBeLessThanOrEqual(100)
}
})
it('十年鉴每十年一条史官快讯', () => {
const w = World.create({ seed: 'era-3', surname: '柴', familyName: '柴家', motto: 'm', difficulty: 'normal' })
for (let i = 0; i < 1200; i++) w.advanceMonth()
const news = (w.state.worldSim as WorldSimState).newsFeed
const annals = news.filter((r) => r.kind === 'annal')
expect(annals.length).toBeGreaterThanOrEqual(3)
expect(annals[0]!.text).toContain('史官')
})
it('玩家战力排位随局势变化(群雄谱输入有效)', () => {
const w = World.create({ seed: 'era-4', surname: '宋', familyName: '宋家', motto: 'm', difficulty: 'normal' })
for (let i = 0; i < 120; i++) w.advanceMonth()
const myPower = w.aliveMembers().reduce((a, c) => a + combatPowerOf(w, c), 0)
expect(myPower).toBeGreaterThan(0)
})
it('灾年时秘境恢复减半(灵脉闭锁)', () => {
const w = World.create({ seed: 'era-5', surname: '吕', familyName: '吕家', motto: 'm', difficulty: 'normal' })
w.advanceMonth() // 先实例化 worldSimsecretQi 各处 50
const ws = w.state.worldSim as WorldSimState
if (!ws) throw new Error('worldSim 未初始化')
// 钉死灾年后观察恢复量(此时灵气从 50 起,减值格 >70 规则不触发)
ws.calamity = '旱灾'
ws.calamityLeft = 3
const before = ws.secretQi['m-anmoku'] ?? 50
w.advanceMonth()
const after = (w.state.worldSim as WorldSimState).secretQi['m-anmoku'] ?? 0
expect(after - before).toBeLessThanOrEqual(3) // 灾年恢复 0.5x=1~2.5 上限
})
})
+2 -2
View File
@@ -170,7 +170,7 @@ describe('GameFacade 门面', () => {
it('默认配置金钟罩不受门面化影响', () => {
PACK.reset()
expect(stateFingerprint(longRun('bell-seed-1').state)).toBe('c923fdd1')
expect(stateFingerprint(longRun('bell-seed-3').state)).toBe('5edde2cd')
expect(stateFingerprint(longRun('bell-seed-1').state)).toBe('d07ebe85')
expect(stateFingerprint(longRun('bell-seed-3').state)).toBe('ecdc62da')
})
})
+52
View File
@@ -0,0 +1,52 @@
import { describe, expect, it } from 'vitest'
import { World } from '../src/renderer/game/engine/runtime/World'
import { resolveBreakthrough } from '../src/renderer/game/engine/runtime/Systems/cultivation'
import { resolveRaid } from '../src/renderer/game/engine/runtime/Systems/combat'
import { MAJORS } from '../src/renderer/game/data/realms'
function busOf(w: World): string[] {
const got: string[] = []
w.out.push({
onLog: () => undefined,
onChronicle: () => undefined,
onBattle: () => undefined,
onPendingEvent: () => undefined,
onGameOver: () => undefined,
onFx: (em) => got.push(em.kind)
})
return got
}
describe('特效语义发射(引擎侧唯一源)', () => {
it('突破成功 → spark(语义点,非文本正则)', () => {
const w = World.create({ seed: 'fx-1', surname: '叶', familyName: '叶家', motto: 'm', difficulty: 'normal' })
const got = busOf(w)
const c = Object.values(w.state.members)[0]!
c.realm = { major: 'qi', minor: MAJORS.qi.minorLayers - 1 }
c.realmProgress = 100
c.health = 100
resolveBreakthrough(w, c, 99) // 必成
expect(got).toContain('spark')
})
it('劫掠大胜 → blade;劫掠失利 → pulse', () => {
const w = World.create({ seed: 'fx-2', surname: '柳', familyName: '柳家', motto: 'm', difficulty: 'normal' })
const got = busOf(w)
const npcId = Object.keys(w.state.npcFamilies)[0]!
const team = [w.state.members['x1']!, w.state.members['x2']!, w.state.members['x3']!, w.state.members['x4']!]
for (const c of team) {
c.realm = { major: 'spirit', minor: 0 }
c.health = 100
}
resolveRaid(w, npcId, team)
expect(got).toContain('blade')
})
it('灾年 → 世界脉冲(tick 触发但有节奏)', () => {
const w = World.create({ seed: 'fx-3', surname: '陆', familyName: '陆家', motto: 'm', difficulty: 'normal' })
const got = busOf(w)
// 直接冒烟:任意 tick 不应抛错;特效只当事件发生才发
for (let i = 0; i < 12; i++) w.advanceMonth()
expect(got.filter((k) => k === 'pulse').length).toBeGreaterThanOrEqual(0)
})
})
+3 -3
View File
@@ -80,9 +80,9 @@ describe('PluginCore 插件协议', () => {
})
it('默认管线金钟罩不受插件层影响', () => {
expect(stateFingerprint(longRun('bell-seed-1').state)).toBe('c923fdd1')
expect(stateFingerprint(longRun('bell-seed-2').state)).toBe('e98eb9fa')
expect(stateFingerprint(longRun('bell-seed-3').state)).toBe('5edde2cd')
expect(stateFingerprint(longRun('bell-seed-1').state)).toBe('d07ebe85')
expect(stateFingerprint(longRun('bell-seed-2').state)).toBe('3fcec396')
expect(stateFingerprint(longRun('bell-seed-3').state)).toBe('ecdc62da')
})
it('facade 插件查询与 about.plugins', () => {