136 lines
3.3 KiB
TypeScript
136 lines
3.3 KiB
TypeScript
import type { JsonObject } from './common';
|
|
import type { SavedGameSnapshotInput } from './runtime';
|
|
|
|
/**
|
|
* story session 主链共享契约。
|
|
* 字段命名与 server-rs/shared-contracts/src/story.rs 的 camelCase 回包保持一致。
|
|
*/
|
|
|
|
export type BeginStorySessionRequest = {
|
|
runtimeSessionId: string;
|
|
worldProfileId: string;
|
|
initialPrompt: string;
|
|
openingSummary?: string | null;
|
|
};
|
|
|
|
export type BeginStoryRuntimeSessionRequest<
|
|
TProfile = JsonObject,
|
|
TCharacter = JsonObject,
|
|
> = {
|
|
worldType: string;
|
|
customWorldProfile?: TProfile | null;
|
|
character: TCharacter;
|
|
runtimeMode?: 'play' | 'preview' | 'test';
|
|
disablePersistence?: boolean;
|
|
};
|
|
|
|
export type ContinueStoryRequest = {
|
|
storySessionId: string;
|
|
narrativeText: string;
|
|
choiceFunctionId?: string | null;
|
|
};
|
|
|
|
export type ResolveStoryRuntimeActionRequest = {
|
|
storySessionId: string;
|
|
clientVersion?: number;
|
|
functionId: string;
|
|
actionText: string;
|
|
targetId?: string | null;
|
|
payload?: JsonObject | null;
|
|
};
|
|
|
|
export type StorySessionPayload = {
|
|
storySessionId: string;
|
|
runtimeSessionId: string;
|
|
actorUserId: string;
|
|
worldProfileId: string;
|
|
initialPrompt: string;
|
|
openingSummary?: string | null;
|
|
latestNarrativeText: string;
|
|
latestChoiceFunctionId?: string | null;
|
|
status: string;
|
|
version: number;
|
|
createdAt: string;
|
|
updatedAt: string;
|
|
};
|
|
|
|
export type StoryEventPayload = {
|
|
eventId: string;
|
|
storySessionId: string;
|
|
eventKind: string;
|
|
narrativeText: string;
|
|
choiceFunctionId?: string | null;
|
|
createdAt: string;
|
|
};
|
|
|
|
export type StorySessionMutationResponse = {
|
|
storySession: StorySessionPayload;
|
|
storyEvent: StoryEventPayload;
|
|
};
|
|
|
|
export type StorySessionStateResponse = {
|
|
storySession: StorySessionPayload;
|
|
storyEvents: StoryEventPayload[];
|
|
};
|
|
|
|
export type StoryRuntimeSnapshotPayload<
|
|
TGameState = JsonObject,
|
|
TCurrentStory = JsonObject,
|
|
> = SavedGameSnapshotInput<TGameState, string, TCurrentStory>;
|
|
|
|
export type StoryRuntimeProjectionRequest = {
|
|
storySessionId: string;
|
|
clientVersion?: number;
|
|
};
|
|
|
|
export type StoryRuntimeActorProjection = {
|
|
hp: number;
|
|
maxHp: number;
|
|
mana: number;
|
|
maxMana: number;
|
|
currency: number;
|
|
currencyText: string;
|
|
};
|
|
|
|
export type StoryRuntimeInventoryProjection = {
|
|
backpackItems: JsonObject[];
|
|
equipmentSlots: JsonObject[];
|
|
forgeRecipes: JsonObject[];
|
|
};
|
|
|
|
export type StoryRuntimeOptionProjection = {
|
|
functionId: string;
|
|
actionText: string;
|
|
detailText?: string | null;
|
|
scope: string;
|
|
payload?: JsonObject | null;
|
|
enabled: boolean;
|
|
reason?: string | null;
|
|
};
|
|
|
|
export type StoryRuntimeStatusProjection = {
|
|
inBattle: boolean;
|
|
npcInteractionActive: boolean;
|
|
currentEncounterId?: string | null;
|
|
currentNpcBattleMode?: string | null;
|
|
currentNpcBattleOutcome?: string | null;
|
|
};
|
|
|
|
export type StoryRuntimeProjectionResponse = {
|
|
storySession: StorySessionPayload;
|
|
storyEvents: StoryEventPayload[];
|
|
serverVersion: number;
|
|
gameState: JsonObject;
|
|
actor: StoryRuntimeActorProjection;
|
|
inventory: StoryRuntimeInventoryProjection;
|
|
options: StoryRuntimeOptionProjection[];
|
|
status: StoryRuntimeStatusProjection;
|
|
currentNarrativeText?: string | null;
|
|
actionResultText?: string | null;
|
|
toast?: string | null;
|
|
};
|
|
|
|
export type StoryRuntimeMutationResponse = {
|
|
projection: StoryRuntimeProjectionResponse;
|
|
};
|