91 lines
2.5 KiB
TypeScript
91 lines
2.5 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { AnimationState, type ChapterState, type GameState } from '../../types';
|
|
import { buildJourneyBeatQueue, resolveCurrentJourneyBeat } from './journeyBeatPlanner';
|
|
|
|
const state = {
|
|
worldType: null,
|
|
customWorldProfile: null,
|
|
playerCharacter: null,
|
|
runtimeStats: {
|
|
playTimeMs: 0,
|
|
lastPlayTickAt: null,
|
|
hostileNpcsDefeated: 0,
|
|
questsAccepted: 0,
|
|
itemsUsed: 0,
|
|
scenesTraveled: 0,
|
|
},
|
|
currentScene: 'Story',
|
|
storyHistory: [],
|
|
storyEngineMemory: {
|
|
discoveredFactIds: [],
|
|
inferredFactIds: [],
|
|
activeThreadIds: ['thread-1'],
|
|
resolvedScarIds: [],
|
|
recentCarrierIds: [],
|
|
recentSignalIds: [],
|
|
recentCompanionReactions: [],
|
|
currentChapter: null,
|
|
currentJourneyBeatId: null,
|
|
companionArcStates: [],
|
|
worldMutations: [],
|
|
chronicle: [],
|
|
factionTensionStates: [],
|
|
currentCampEvent: null,
|
|
currentSetpieceDirective: null,
|
|
continueGameDigest: null,
|
|
},
|
|
chapterState: null,
|
|
characterChats: {},
|
|
animationState: AnimationState.IDLE,
|
|
currentEncounter: null,
|
|
npcInteractionActive: false,
|
|
currentScenePreset: { id: 'scene-1', name: '断桥旧哨', description: '', imageSrc: '' },
|
|
sceneHostileNpcs: [],
|
|
playerX: 0,
|
|
playerOffsetY: 0,
|
|
playerFacing: 'right',
|
|
playerActionMode: 'idle',
|
|
scrollWorld: false,
|
|
inBattle: false,
|
|
playerHp: 0,
|
|
playerMaxHp: 0,
|
|
playerMana: 0,
|
|
playerMaxMana: 0,
|
|
playerSkillCooldowns: {},
|
|
activeBuildBuffs: [],
|
|
activeCombatEffects: [],
|
|
playerCurrency: 0,
|
|
playerInventory: [],
|
|
playerEquipment: { weapon: null, armor: null, relic: null },
|
|
npcStates: {},
|
|
quests: [],
|
|
roster: [],
|
|
companions: [],
|
|
currentBattleNpcId: null,
|
|
currentNpcBattleMode: null,
|
|
currentNpcBattleOutcome: null,
|
|
sparReturnEncounter: null,
|
|
sparPlayerHpBefore: null,
|
|
sparPlayerMaxHpBefore: null,
|
|
sparStoryHistoryBefore: null,
|
|
} satisfies GameState;
|
|
|
|
describe('journeyBeatPlanner', () => {
|
|
it('builds a beat queue and resolves the current beat', () => {
|
|
const chapterState: ChapterState = {
|
|
id: 'chapter-1',
|
|
title: '封桥旧案·展开',
|
|
theme: '封桥旧案',
|
|
primaryThreadIds: ['thread-1'],
|
|
stage: 'expansion',
|
|
chapterSummary: '旧案正在铺开。',
|
|
};
|
|
const queue = buildJourneyBeatQueue({ state, chapterState });
|
|
const beat = resolveCurrentJourneyBeat({ state, chapterState });
|
|
|
|
expect(queue).toHaveLength(3);
|
|
expect(beat?.beatType).toBe('investigation');
|
|
});
|
|
});
|