Files
Genarrative/src/services/storyEngine/setpieceDirector.ts
高物 ddcb5d5c8c
Some checks failed
CI / verify (push) Has been cancelled
Rework story engine flow and reorganize project docs
2026-04-06 23:19:00 +08:00

51 lines
1.7 KiB
TypeScript

import type { ChapterState, GameState, JourneyBeat, SetpieceDirective } from '../../types';
export function evaluateSetpieceOpportunity(params: {
state: GameState;
chapterState: ChapterState | null | undefined;
journeyBeat: JourneyBeat | null | undefined;
}) {
if (!params.chapterState) return false;
return (
params.chapterState.stage === 'climax'
|| params.journeyBeat?.beatType === 'boss_prelude'
|| params.state.currentScenePreset?.currentPressureLevel === 'extreme'
);
}
export function buildSetpieceDirective(params: {
state: GameState;
chapterState: ChapterState | null | undefined;
journeyBeat: JourneyBeat | null | undefined;
}) {
if (!params.chapterState) return null;
const setpieceType: SetpieceDirective['setpieceType'] =
params.chapterState.stage === 'aftermath'
? 'aftermath'
: params.chapterState.stage === 'climax'
? 'climax'
: params.journeyBeat?.beatType === 'boss_prelude'
? 'boss_prelude'
: 'showdown';
return {
id: `setpiece:${params.chapterState.id}:${setpieceType}`,
title:
setpieceType === 'climax'
? `${params.chapterState.title}·高潮`
: setpieceType === 'aftermath'
? `${params.chapterState.title}·余波`
: `${params.chapterState.title}·对峙`,
setpieceType,
relatedThreadIds: params.chapterState.primaryThreadIds,
sceneFocusId: params.state.currentScenePreset?.id ?? null,
dramaticQuestion:
setpieceType === 'climax'
? '这一轮冲突会把谁的真相和代价一起推到台前?'
: setpieceType === 'aftermath'
? '高潮过后,谁会先承受余波?'
: '这一步会把暗线逼到什么程度?',
} satisfies SetpieceDirective;
}