【主线一:世界自演进深化《八方风雨》】 - NPC 战略姿态 stance:守成/扩张/隐忍/结盟四态,年首评估(era>景气>power>relation) 全行为调制:raid 概率×2/×0.4/×0、互攻阈值 -40/-70/不攻、贸量 ×1.3/×0.7、 赠礼收益 ally×1.3、结盟门槛 ally 放宽至30——NPC 从统计物理到行为战略 - 超卖潮(谷贱伤农):池>1.8×base 世界产能回调×0.7 + 年度播报(防玩家玩崩市场) - 盟约连坐:结盟令世仇(rel<-50)对玩家-20;盟者世仇 raid 概率×2 - 盟友求援:互攻失利盟友告急(distress 旗标)——WorldPanel 响应(出资200/见死不救) - 干预天下:调停(50灵石令世仇-60→-25、声望+2)/ 资助盟友;恩怨网情报视图(各家关系展开+调停钮) 【主线二:孤立系统归并引擎】 - P0 兜底修复:empty() 收敛 makeWorldSimState 单源 + normalize 补 tideTicks/calamityLeft/ era/eraStartYear/prosperity/distress/overfluxYear(旧档 NaN 级联防死) - FxGate 从 engine/kernel/fxqueue.ts 并入 ui/fx.ts(kernel 清纯引擎;deltas 顶层导出, 3 处引用 10 行改动);engine 侧零 UI 依赖再下一城 - 音效语义补充:onFx→blade/pulse/spark→sWar/sGong/sBell;onLog kind 兜底保留(不静音) - store.advance drift/season 段左移 fx.ts(fxSeason 复活接管 season 检测) - 死码清除:timesense.tideOf/tintLabel、tideDir 全链(类型/初始/写入/domain) - domain.ts worldSim 局部类型补全 0.1.18/0.1.19 全部新字段(断言类型安全) 【测试】1002 全绿(41 套件):stance-world 7 例(兜底/姿态/raid/超卖/连坐/调停/求援)
89 lines
3.7 KiB
TypeScript
89 lines
3.7 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { World } from '../src/renderer/game/engine/runtime/World'
|
|
import { newCharacter } from '../src/renderer/game/engine/runtime/pcgen'
|
|
import { Rng, seedToRng } from '../src/renderer/game/engine/kernel/rng'
|
|
import { PACK } from '../src/renderer/game/data/registry'
|
|
import { buildApprentice } from '../src/renderer/game/engine/runtime/Systems/tournament'
|
|
import { sendMission } from '../src/renderer/game/engine/runtime/Systems/missions'
|
|
import { buyItem, marketPrice } from '../src/renderer/game/engine/sim/Market'
|
|
import { findEvent } from '../src/renderer/game/engine/runtime/Systems/events'
|
|
import { runTournament } from '../src/renderer/game/engine/runtime/Systems/tournament'
|
|
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('审计回归:P0 修复固化', () => {
|
|
it('单亲 rollRoots 不再崩溃(pcgen TypeError 修复)', () => {
|
|
const r = new Rng(seedToRng('single'))
|
|
const dad = newCharacter(r, { name: '父', gender: 'male', generation: 1, bornYear: -30, age: 30, realm: { major: 'qi', minor: 1 } })
|
|
dad.roots = { grade: 3, primary: '火', secondary: [] }
|
|
const child = newCharacter(r, { name: '子', gender: 'male', generation: 2, bornYear: 0, age: 0, father: dad })
|
|
expect(child.roots.grade).toBeGreaterThanOrEqual(0)
|
|
})
|
|
|
|
it('插件事件池事件可被 findEvent 解析(软锁修复)', () => {
|
|
const w = baseWorld('aud-find')
|
|
w.installPlugin({
|
|
id: 'aud-event-plugin',
|
|
name: '审计事件',
|
|
version: '1',
|
|
kind: 'events',
|
|
install(ctx) {
|
|
ctx.addEventPool('aud', [
|
|
{ id: 'id-evt-aud', name: '试炼', category: 'daily', weight: 1, text: '审计副本。', options: [{ label: '收下', eff: { rep: 1 } }] }
|
|
])
|
|
}
|
|
})
|
|
// 直接模拟抽到该事件后 UI 路径解析
|
|
const def = findEvent('id-evt-aud', w)
|
|
expect(def).toBeTruthy()
|
|
})
|
|
|
|
it('packOverride 经插件上下文真实生效(死实现修复)', () => {
|
|
const w = baseWorld('aud-pack')
|
|
w.installPlugin({
|
|
id: 'aud-data-plugin',
|
|
name: '货币更替',
|
|
version: '1',
|
|
kind: 'data',
|
|
install(ctx) {
|
|
ctx.overridePack({ items: { ...PACK.current().items, lingcao: { ...PACK.current().items['lingcao'], basePrice: 500 } } })
|
|
}
|
|
})
|
|
expect(marketPrice(w, 'lingcao')).toBeGreaterThan(100)
|
|
expect(buyItem(w, 'lingcao', 2)).toBe(false) // 1000 > 800,双份买不起
|
|
})
|
|
|
|
it('buildApprentice 空候选不再抛错(守卫修复)', () => {
|
|
const w = baseWorld('aud-appr')
|
|
for (const c of Object.values(w.state.members)) c.state = 'apprentice'
|
|
buildApprentice(w) // 此前 Rng.pick([]) 抛错
|
|
expect(w.state.family.stones).toBe(800)
|
|
})
|
|
|
|
it('sendMission 无效 id(回档残留)不再抛错', () => {
|
|
const w = baseWorld('aud-squad')
|
|
const ok = sendMission(w, 'm-anmoku', ['x-not-exist'])
|
|
expect(ok).toBe(false)
|
|
})
|
|
|
|
it('tournament 越过能力开关后休赛(未启时无副作用)', () => {
|
|
const w = baseWorld('aud-tourney')
|
|
w.toggleSystem('tournament')
|
|
const before = w.state.battles.length
|
|
runTournament(w, ['x3'])
|
|
expect(w.state.battles.length).toBe(before)
|
|
})
|
|
|
|
it('防御性修补后金钟罩不变(行为等价确认)', () => {
|
|
expect(stateFingerprint(longRun('bell-seed-1').state)).toBe('aeed3b65')
|
|
expect(stateFingerprint(longRun('bell-seed-3').state)).toBe('39892725')
|
|
})
|
|
})
|