【引擎审计修复】 - P0:大比 once(原整年刷 12 场、奖励通胀);flag 年份键 3 年剪枝(长线膨胀) - P1:飞升离世累加 feishengCount(飞升之资称号可达);圣者护族接消费(原死代码); 大比/传薪挂能力卡门控;pending 抢渡劫时不再重设 - P2:version 硬编码统一 0.1.11;yearaxis 飞升归类;MonumentList 挂载 【UI 审计修复】 - P0:已故成员卡显示「已殁」(原秀活动 status);空队迎战禁用+提示(原静默失效) - P1:指婚候选去截断(滚动列表);终局出口(回卷/主菜单按钮);saveNow 反馈; 事件来临写入 feed(k-event 使用);遣队「最强 N 人/清空」一键;寻衅确认+联姻原因提示; 未建建筑视觉 uc 类 - P2:speed 死代码;Modal 分层 z-index;FamilyPanel 在世/先人分隔 【UX 三件套】 - 警讯徽章(瓶颈/重伤/在外/媒缘/孤嗣之忧)顶栏一屏秒答「我该干嘛」 - 首启引导任务条(四步目标 + 完成推进,可跳不强制) - 顶栏丹药瘦身(4 资源);数字千/万化;瓶颈卡红框高亮 【测试】905→923(urgency/guide/format 三模块 + 审计修复回归 6 项) 金钟罩三档重固化(0.1.11),typecheck/build 通过
123 lines
4.4 KiB
TypeScript
123 lines
4.4 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { World } from '../src/renderer/game/engine/world'
|
|
import { GameFacade } from '../src/renderer/game/engine/api'
|
|
import { installCoreSystems, buildClock } from '../src/renderer/game/engine/clocks'
|
|
import { emptyClock } from '../src/renderer/game/engine/clocks'
|
|
import { CORE_PLUGINS } from '../src/renderer/game/engine/plugin-bootstrap'
|
|
import { examplePlugin, brokenPlugin } from './helpers/examplePlugin'
|
|
import { stateFingerprint, longRun } from './fingerprint.helper'
|
|
import { resetSaveBus, attachLogSink } from './world.helpers'
|
|
|
|
function baseWorld(seed: string): World {
|
|
const w = World.create({ seed, surname: '夏', familyName: '夏家', motto: 'm', difficulty: 'normal' })
|
|
resetSaveBus()
|
|
attachLogSink(w)
|
|
return w
|
|
}
|
|
|
|
describe('PluginCore 插件协议', () => {
|
|
it('内置三插件常驻且受保护', () => {
|
|
const w = baseWorld('pl-a')
|
|
const list = w.pluginList()
|
|
expect(list.length).toBe(3)
|
|
for (const p of list) {
|
|
expect(p.installed).toBe(true)
|
|
expect(p.enabled).toBe(true)
|
|
expect(p.protected).toBe(true)
|
|
}
|
|
const ids = list.map((p) => p.id)
|
|
expect(ids).toContain('core-systems')
|
|
expect(ids).toContain('core-data')
|
|
expect(ids).toContain('core-events')
|
|
})
|
|
|
|
it('核心插件不可卸载(保护)', () => {
|
|
const w = baseWorld('pl-b')
|
|
const r = w.removePlugin('core-systems')
|
|
expect(r.ok).toBe(false)
|
|
})
|
|
|
|
it('依赖缺失拒绝安装;依赖满足则放行', () => {
|
|
const w = baseWorld('pl-c')
|
|
expect(w.installPlugin(brokenPlugin).ok).toBe(false)
|
|
expect(w.installPlugin(examplePlugin).ok).toBe(true)
|
|
expect(w.pluginList().length).toBe(4)
|
|
})
|
|
|
|
it('示例安装后:消息池注入生效 + 山神庇佑加值;卸载后两清', () => {
|
|
const w = baseWorld('pl-d')
|
|
w.installPlugin(examplePlugin)
|
|
expect(w.eventPoolIds()).toContain('demo-peaks')
|
|
const x5 = w.state.members['x5']
|
|
x5.realm = { major: 'qi', minor: 1 }
|
|
const p0 = x5.realmProgress
|
|
// 推进到跨年触发年首庇佑
|
|
for (let i = 0; i < 13; i++) w.advanceMonth()
|
|
expect(x5.realmProgress).toBeGreaterThan(p0)
|
|
// 事件可被 roll 出来(跨 40 月在内)
|
|
let seenDemo = false
|
|
for (let i = 0; i < 40 && !seenDemo; i++) {
|
|
w.advanceMonth()
|
|
if (w.state.pendingEvent === 'ev-demo-guardian') seenDemo = true
|
|
w.state.pendingEvent = undefined
|
|
}
|
|
expect(seenDemo).toBe(true)
|
|
// 卸载
|
|
expect(w.removePlugin('demo-peaks').ok).toBe(true)
|
|
expect(w.eventPoolIds()).not.toContain('demo-peaks')
|
|
expect(w.pluginList().length).toBe(3)
|
|
})
|
|
|
|
it('remove 后时钟钩子计数恢复(真摘钩)', () => {
|
|
const w = baseWorld('pl-e')
|
|
const before = w.clock.subscriptionCount()
|
|
w.installPlugin(examplePlugin)
|
|
const mounted = w.clock.subscriptionCount()
|
|
expect(mounted).toBe(before + 1)
|
|
w.removePlugin('demo-peaks')
|
|
expect(w.clock.subscriptionCount()).toBe(before)
|
|
})
|
|
|
|
it('安装序确定性:同版本两次世界插件列表一致', () => {
|
|
const a = baseWorld('pl-f')
|
|
const b = baseWorld('pl-f')
|
|
expect(JSON.stringify(a.pluginList())).toBe(JSON.stringify(b.pluginList()))
|
|
})
|
|
|
|
it('默认管线金钟罩不受插件层影响', () => {
|
|
expect(stateFingerprint(longRun('bell-seed-1').state)).toBe('ffdd3fb1')
|
|
expect(stateFingerprint(longRun('bell-seed-2').state)).toBe('1dd432bb')
|
|
expect(stateFingerprint(longRun('bell-seed-3').state)).toBe('195b8aaa')
|
|
})
|
|
|
|
it('facade 插件查询与 about.plugins', () => {
|
|
const w = baseWorld('pl-g')
|
|
const f = new GameFacade(w, 1)
|
|
const pl = f.query('plugins') as { list: { id: string }[] }
|
|
expect(pl.list.length).toBe(3)
|
|
expect(f.about().plugins).toBe(3)
|
|
})
|
|
|
|
it('订阅可捕获 plugin 生命周期事件', () => {
|
|
const w = baseWorld('pl-h')
|
|
const f = new GameFacade(w, 1)
|
|
const events: string[] = []
|
|
const unsub = f.subscribe((e) => {
|
|
if (e.type === 'plugin') events.push((e as { action: string }).action)
|
|
})
|
|
w.installPlugin(examplePlugin)
|
|
w.removePlugin('demo-peaks')
|
|
expect(events).toContain('install')
|
|
expect(events).toContain('remove')
|
|
unsub()
|
|
})
|
|
|
|
it('buildClock 兼容路径仍完整注册(测试/工具用)', () => {
|
|
const clock = buildClock()
|
|
expect(clock.subscriptionCount()).toBeGreaterThanOrEqual(10)
|
|
const empty = emptyClock()
|
|
expect(empty.subscriptionCount()).toBe(0)
|
|
void installCoreSystems
|
|
})
|
|
})
|