Files
ChronicleOfTheImmortalClan/tests/era-world-0.1.18.test.ts
T
thzxx 8b6f2f7189 v0.1.27: 活水长流——生灭盘活 + 修为回环 + 世鉴 + MOD 生态闭环(1054 全绿)
【世界模型(180 年实测驱动的机制修复)】
- 生灭可达化:探子模拟实测证实——原覆灭/新贵 183 年零触发(力量通胀+景气自校正);
  修复:脆弱判定放宽(power<110 弱即衰 / warLosses≥2 战损衰)+ yearGrowth 按 era 调制
  (盛世 0.7/平世 1/乱世 -0.8/末法 -1.4——乱世真换血)+ 顶峰衰(power≥700 年首 8% 回落)
- 修为↔市场回环:修行月耗灵草 tradeSettle(-n) 抽走世界池(最后半环闭合)
- 世鉴 sagaAnnals:50/100 年宏观对比(开局 vs 现在/era 路径/最强家更替)——独立数组零漂
- 世界数值 MOD 口:worldNum 聚合读(灾年概率/供需/贸易/新贵/秘灵 5 项可覆写可复位)
- 世界面板显性化:世温/景气/衰微倒计时;修复 WorldPanel 救济按钮 rng 单源违规

【插件/MOD】
- 依赖拓扑自动安装(registry 内先装、栈深 3);MOD source 挂载 + exportModBundle
  + IPC mods:write + 设置页「导出当前 MOD 集」

【测试】1054 全绿(47 套件,+7:乱世压力覆灭/顶峰衰/era 负增/世鉴/数值口/导出/拓扑);
【金钟罩】0.1.27 基线重算(双基线 18 值,生灭/回环受控变更);build 通过
2026-08-23 17:02:46 +08:00

64 lines
2.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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' && r.text.includes('史官'))
expect(annals.length).toBeGreaterThanOrEqual(3)
})
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 上限
})
})