PlotModel.ts 2.59 KB
import { RichTextNode } from "./RichTextModel";
import { ConditionExpression } from "./ConditionModel";
import { DeepReadonly, DeepReadonlyArray } from "simba-utils";
import { Actions } from "./ActionModel";

export const enum SentenceType {
    TEXT = 1,
    AUDIO = 2,
    VIDEO = 3,
    IMAGE = 4,
    SELECT = 5,
    EMPTY = 6
}

export interface SentenceEmptyContent {
    type: SentenceType.EMPTY;
}

export interface SentenceTextContent {
    type: SentenceType.TEXT;
    value: RichTextNode[];
}

export interface SentenceMediaContent {
    type: SentenceType.AUDIO | SentenceType.VIDEO | SentenceType.IMAGE;
    value: string;
}

export interface SentenceSelectContent {
    type: SentenceType.SELECT;
    value: SentenceOption[];
}

export interface SentenceOption {
    summary: string;
    content?: SentenceEmptyContent | SentenceTextContent | SentenceMediaContent;
    enableCondition?: ConditionExpression;
}

export type SentenceContent = SentenceEmptyContent | SentenceTextContent | SentenceMediaContent | SentenceSelectContent;

export interface Sentence {
    content?: SentenceContent;
    roleId: number;
    actions: Actions;
}

export const enum PlotJumpType {
    Condition = 0,
    Select = 1
}

interface ConditionPlotJump {
    type: PlotJumpType.Condition;
    conditionBranches?: { condition?: ConditionExpression, toPlot: number }[];
    toPlot: number;
}

interface SelectPlotJump {
    type: PlotJumpType.Select;
    jumps: { id: string, toPlot: number }[];
}

export interface Plot {
    id: number;
    chapterId: number;
    jump: ConditionPlotJump | SelectPlotJump;
    plotSceneType: number;
    plotSceneTypeId: number;
    sentences: Sentence[];
    customData?: any;
}

export type ReadonlyPlots = DeepReadonlyArray<Plot>;
export type ReadonlyPlot = DeepReadonly<Plot>

export interface Chapter {
    id: number;
    title: string;
    children: number[];
}

export const enum SpecialPlotId {
    End = -1,
    ToBeContinued = -2,
    CustomPlotStart = -100
}

export interface Props {
    id: number,    //道具id
    type: number,  //道具类型
    name: string,  //道具名称
    icon: string,  //道具路径
    des: string,   //道具描述
    time: number, //恢复时间(秒)
    nummax: number,//最大上限
    value: number
}

export interface Language {
    id: number,
    value: string
}

export interface FontAssetBmp {
    id: number,
    value: string
}

export interface MemoCardModel {
    id: number,
    date: string,
    firstPlot: number,
    endPlot: number
}

// export function isChapter(v: Plot | Chapter): v is Chapter {
//     return (v as Chapter).title !== undefined;
// }