结构(旧 game/core+engine → 新 engine/ 域): - engine/kernel/ 时钟/随机/插件协议/fxqueue/timesense/format/urgency/guide/names(原 core) - engine/narrative/ legacy/报告/列传/谱系/年轴(原 core 叙事族) - engine/runtime/ World/creation/pcgen/ApiFacade/capabilities/pluginManager/boot/clocks + Systems/*(12 系统) - engine/sim/ Market(未来 WorldSim 同行) - 旧 game/core、engine/systems、engine/world.ts 等路径全部废弃(无 re-export 兼容层) 验证:35 套件/967 测试全绿(金钟罩三档零漂移=纯搬迁无行为变化) typecheck 0 error
79 lines
2.6 KiB
TypeScript
79 lines
2.6 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
||
import { World } from '../src/renderer/game/engine/runtime/World'
|
||
import { computeUrgency } from '../src/renderer/game/engine/kernel/urgency'
|
||
import { computeGuide, GUIDE_STEPS, guideAdvance } from '../src/renderer/game/engine/kernel/guide'
|
||
import { fmt } from '../src/renderer/game/engine/kernel/format'
|
||
|
||
function baseWorld(seed: string): World {
|
||
return World.create({ seed, surname: '舒', familyName: '舒家', motto: 'm', difficulty: 'normal' })
|
||
}
|
||
|
||
describe('急事徽章 derivedState(urgent)', () => {
|
||
it('可突破≥1 时 badge 出现', () => {
|
||
const w = baseWorld('urge-a')
|
||
const c = w.state.members['x3']
|
||
c.realmProgress = 100
|
||
const u = computeUrgency(w)
|
||
expect(u.blockedCount).toBeGreaterThanOrEqual(1)
|
||
})
|
||
|
||
it('重伤 count 反映', () => {
|
||
const w = baseWorld('urge-b')
|
||
const c = w.state.members['x3']
|
||
c.health = 15
|
||
const u = computeUrgency(w)
|
||
expect(u.injuredCount).toBeGreaterThanOrEqual(1)
|
||
})
|
||
|
||
it('在外队伍 count 反映', () => {
|
||
const w = baseWorld('urge-c')
|
||
w.state.missions.push({ id: 'm1', defId: 'm-anmoku', memberIds: ['x3'], startYear: 1, startMonth: 1, stage: 0, stageMonth: 0, log: [], done: false })
|
||
const u = computeUrgency(w)
|
||
expect(u.missionCount).toBeGreaterThanOrEqual(1)
|
||
})
|
||
|
||
it('无继承人次条(危险信号)', () => {
|
||
const w = baseWorld('urge-d')
|
||
w.state.members['x1'].alive = false
|
||
w.state.members['x3'].alive = false
|
||
w.state.members['x5'].alive = false
|
||
w.state.members['x4'].alive = false
|
||
const u = computeUrgency(w)
|
||
expect(u.noHeir).toBe(true)
|
||
})
|
||
})
|
||
|
||
describe('引导任务的 state machine', () => {
|
||
it('开局处于第 1 步', () => {
|
||
const w = baseWorld('guide-a')
|
||
expect(computeGuide(w).step).toBe(0)
|
||
expect(GUIDE_STEPS.length).toBe(4)
|
||
})
|
||
|
||
it('完成任务推进且可跳步(不强制)', () => {
|
||
const w = baseWorld('guide-b')
|
||
expect(guideAdvance(w, 2)).toBe(2) // 跳到第 3 步(index 2)
|
||
})
|
||
|
||
it('所有目标挂到状态', () => {
|
||
for (let i = 0; i < 4; i++) {
|
||
expect(GUIDE_STEPS[i].title.length).toBeGreaterThan(1)
|
||
expect(GUIDE_STEPS[i].hint.length).toBeGreaterThan(1)
|
||
}
|
||
})
|
||
})
|
||
|
||
describe('数字格式化', () => {
|
||
it.each([[1234, '1.2千'], [56789, '5.7万'], [123456, '12.3万'], [7890123, '789.0万']])('%i → %s', (n, s) => {
|
||
expect(fmt(n)).toBe(s)
|
||
})
|
||
})
|
||
|
||
describe('0.1.11 编译 smoke', () => {
|
||
it('engine 加载并推进数月无异常', () => {
|
||
const w = baseWorld('smoke-011')
|
||
for (let i = 0; i < 24; i++) w.advanceMonth()
|
||
expect(w.state.year).toBeGreaterThan(1)
|
||
})
|
||
})
|