Split custom world generation into staged lightweight batches
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
2026-04-05 22:20:30 +08:00
parent 89cecda7da
commit fcd8d727b0
57 changed files with 7646 additions and 1425 deletions

View File

@@ -41,6 +41,7 @@ import {
resolveFunctionOption,
sortStoryOptionsByPriority,
} from '../data/stateFunctions';
import { applyStoryReasoningRecovery } from '../data/storyRecovery';
import { generateInitialStory, generateNextStep } from '../services/ai';
import {
Character,
@@ -475,7 +476,9 @@ function getStoryGenerationHostileNpcs(state: GameState) {
}
function getResolvedSceneHostileNpcs(state: GameState) {
return state.sceneHostileNpcs ?? state.sceneMonsters;
return state.sceneMonsters.length > 0
? state.sceneMonsters
: (state.sceneHostileNpcs ?? []);
}
function sanitizeOptions(
@@ -1439,6 +1442,7 @@ export function useStoryGeneration({
buildStoryContextFromState,
buildFallbackStoryForState,
buildDialogueStoryMoment,
generateStoryForState,
getStoryGenerationHostileNpcs,
getTypewriterDelay,
getAvailableOptionsForState,
@@ -1482,6 +1486,7 @@ export function useStoryGeneration({
character: gameState.playerCharacter,
history: [],
});
setGameState(applyStoryReasoningRecovery(gameState));
setCurrentStory(nextStory);
} catch (error) {
console.error('Failed to start story:', error);
@@ -1508,6 +1513,7 @@ export function useStoryGeneration({
gameState.sceneHostileNpcs,
gameState.worldType,
isLoading,
setGameState,
startOpeningAdventure,
]);