Persist custom world asset configs in runtime snapshots
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import { rehydrateSavedSnapshot } from '../../persistence/runtimeSnapshot';
|
||||
import type { HydratedSavedGameSnapshot } from '../../persistence/runtimeSnapshotTypes';
|
||||
import {
|
||||
buildStoryMomentFromRuntimeOptions,
|
||||
getRuntimeClientVersion,
|
||||
getRuntimeSessionId,
|
||||
getRuntimeStoryState,
|
||||
resolveRuntimeStoryAction,
|
||||
resolveRuntimeStoryMoment,
|
||||
type RuntimeStoryChoicePayload,
|
||||
type RuntimeStoryResponse,
|
||||
} from '../../services/runtimeStoryService';
|
||||
@@ -38,10 +38,11 @@ export async function loadServerRuntimeOptionCatalog(params: {
|
||||
const response = await getRuntimeStoryState(
|
||||
getRuntimeSessionId(params.gameState),
|
||||
);
|
||||
const options = buildStoryMomentFromRuntimeOptions({
|
||||
storyText: response.presentation.storyText,
|
||||
options: getRuntimeResponseOptions(response),
|
||||
gameState: params.gameState,
|
||||
const options = resolveRuntimeStoryMoment({
|
||||
response,
|
||||
hydratedSnapshot: response.snapshot,
|
||||
fallbackGameState: params.gameState,
|
||||
fallbackStoryText: response.presentation.storyText,
|
||||
}).options;
|
||||
|
||||
return options.length > 0 ? options : null;
|
||||
@@ -70,14 +71,15 @@ export async function resumeServerRuntimeStory(
|
||||
const runtimeOptions = getRuntimeResponseOptions(response);
|
||||
const nextStory =
|
||||
response.presentation.storyText || runtimeOptions.length > 0
|
||||
? buildStoryMomentFromRuntimeOptions({
|
||||
storyText:
|
||||
? resolveRuntimeStoryMoment({
|
||||
response,
|
||||
hydratedSnapshot: resumedSnapshot,
|
||||
fallbackGameState: hydratedSnapshot.gameState,
|
||||
fallbackStoryText:
|
||||
response.presentation.storyText ||
|
||||
resumedSnapshot.currentStory?.text ||
|
||||
hydratedSnapshot.currentStory?.text ||
|
||||
'',
|
||||
options: runtimeOptions,
|
||||
gameState: resumedSnapshot.gameState,
|
||||
})
|
||||
: resumedSnapshot.currentStory;
|
||||
|
||||
@@ -111,13 +113,14 @@ export async function resolveServerRuntimeChoice(params: {
|
||||
return {
|
||||
response,
|
||||
hydratedSnapshot,
|
||||
nextStory: buildStoryMomentFromRuntimeOptions({
|
||||
storyText:
|
||||
nextStory: resolveRuntimeStoryMoment({
|
||||
response,
|
||||
hydratedSnapshot,
|
||||
fallbackGameState: params.gameState,
|
||||
fallbackStoryText:
|
||||
response.presentation.storyText ||
|
||||
hydratedSnapshot.currentStory?.text ||
|
||||
params.option.actionText,
|
||||
options: getRuntimeResponseOptions(response),
|
||||
gameState: hydratedSnapshot.gameState,
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user