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AC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,yCAAiB,CAAC,UAAU,CAAC,CAAC,CAAC,yCAAiB,CAAC,SAAS,CAAC;QAC1G,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAC,CAAC,CAAC,CAAC;QACxB,OAAO,CAAC,CAAC;IACb,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,4BAA4B,CAAC,WAAmB;QAClD,IAAI,KAAK,GAAG,IAAI,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC;QACnD,IAAI,KAAK,IAAI,CAAC,EAAE;YACZ,MAAM,iBAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;YACnF,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;YACjC,mCAAgB,CAAC,SAAS,GAAG,CAAC,GAAG,iBAAW,CAAC,eAAe,EAAE,CAAC,CAAC;SACnE;aAAM;YACH,OAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACjD;IACL,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,cAAc;QAChB,IAAI,SAAS,GAAG,mBAAa,EAAE,CAAC,SAAS,CAAC;QAC1C,MAAM,iBAAW,CAAC,wBAAwB,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;QACzD,mCAAgB,CAAC,SAAS,GAAG,CAAC,GAAG,iBAAW,CAAC,eAAe,EAAE,CAAC,CAAC;QAChE,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC;IACtC,CAAC;CAEJ;AAEU,QAAA,sBAAsB,GAAG,IAAI,uBAAuB,EAAE,CAAC","file":"","sourceRoot":"/","sourcesContent":["import { GameRecord, getPlot, getPlotsIndex, PlotManager, SpecialPlotId } from \"../../avg/AVG\";\nimport { DatingEventStatus } from \"./DatingEventSceneModel\";\nimport { GameModelManager } from \"./GameModelManager\";\n\n/**\n * 番外剧情管理类\n */\nclass ExtraStoryModelManager1 {\n /**是否正在创建 */\n creating: boolean = false;\n /**\n * 全局存档(g值)中开过分支的数据\n */\n itemArr: {\n /**开始剧情id */\n startPlot: number;\n /**\n * 存档中gameRecords数组索引\n */\n index: number;\n }[];\n\n /**是否在番外中 */\n private _isInExtraStoryScene:boolean = false;\n\n \n public get isInExtraStoryScene() : boolean {\n return this._isInExtraStoryScene;\n }\n\n /**开启分支剧情,\n * plots:如果需要同时开启多个分支剧情,则数组中存储这些分支中对应的起始剧情id\n */\n async startBranches(plots: number[],callback?:Function) {\n if (this.creating) return;\n this.creating = true;\n if (!plots.length) {\n console.warn(\"no plots to mark as branch start plot id\");\n return;\n }\n for (let i = 0; i < plots.length; i++) {\n let pid = plots[i];\n if (SpecialPlotId.ToBeContinued === pid || SpecialPlotId.End === pid) {\n console.error(\"you can not start a branch with SpecialPlotId, id is = \", pid);\n continue;\n }\n let p = await getPlot(pid);\n if (!p) {\n console.warn(\"no plot which plot id is = \", pid);\n }\n let itemArrIndex: number = this.checkIsBranchStarted(pid);\n let recordsLength = GameRecord.getRecords().length;\n let index = recordsLength;\n if (itemArrIndex != -1) {\n index = this.itemArr[itemArrIndex].index;\n }\n await PlotManager.startGameWithRecordIndex(index, pid);\n this._isInExtraStoryScene = true;\n this.pushBranchToRecord(pid, index);\n callback && callback(i,pid);\n console.log(\"getCurrentPlots: \", PlotManager.getCurrentPlots());\n\n }\n this.creating = false;\n }\n\n /**\n * \n * @param plotId 检测指定剧情下的分支是否已经开启\n * @returns \n */\n private checkIsBranchStarted(plotId: number): number {\n const branchRecordKey: string = \"BRANCH_INDEX_ENTRY\";\n let ret: number = -1;\n let itemArr: { startPlot: number, index: number }[] = [];\n let recordStr: string = GameRecord.globalVariables[branchRecordKey] as string;\n if (recordStr && \"\" !== recordStr.trim()) {\n itemArr = JSON.parse(recordStr) as { startPlot: number, index: number }[];\n }\n ret = itemArr.findIndex((v) => v.startPlot === plotId);\n this.itemArr = itemArr;\n return ret;\n }\n\n /**\n * \n * @param plotId 将分支计入存档\n * @param index \n */\n private pushBranchToRecord(plotId: number, index: number) {\n const branchRecordKey: string = \"BRANCH_INDEX_ENTRY\";\n let exist: boolean = false;\n let itemArr: { startPlot: number, index: number }[] = [];\n let recordStr: string = GameRecord.globalVariables[branchRecordKey] as string;\n if (recordStr && \"\" !== recordStr.trim()) {\n itemArr = JSON.parse(recordStr) as { startPlot: number, index: number }[];\n }\n exist = itemArr.findIndex((v) => v.startPlot === plotId) >= 0;\n if (!exist) {\n itemArr.push({\n startPlot: plotId,\n index: index\n });\n GameRecord.globalVariables[branchRecordKey] = JSON.stringify(itemArr);\n GameRecord.saveRecord();\n }\n this.itemArr = itemArr;\n }\n\n\n\n\n /**\n * 获取分支剧情状态(约会状态)\n * @param plotSceneTypeId 剧情类型(DateSceneConfig的id)id\n * @param start_plot_id 起始剧情id\n * @returns 剧情状态\n */\n getBranchStatus(plotSceneTypeId: number, start_plot_id: number): DatingEventStatus {\n let s = DatingEventStatus.New;\n let curPs = PlotManager.getCurrentPlots();\n let curP = curPs[0];\n let progress = curP.plotSceneTypeId === plotSceneTypeId && (curP.id != SpecialPlotId.ToBeContinued && curP.id != SpecialPlotId.End);\n let isNew = curP.plotSceneTypeId === plotSceneTypeId && curP.id === start_plot_id;\n s = isNew ? DatingEventStatus.New : progress ? DatingEventStatus.InProgress : DatingEventStatus.Completed;\n console.log('当前剧情状态',s);\n return s;\n }\n\n /**\n * 进入番外\n * @param startPlotId 开始剧情id\n */\n async enterExtraStoryByStartPlotId(startPlotId: number) {\n let index = this.checkIsBranchStarted(startPlotId);\n if (index >= 0) {\n await PlotManager.startGameWithRecordIndex(this.itemArr[index].index, startPlotId);\n this._isInExtraStoryScene = true;\n GameModelManager.currPlots = [...PlotManager.getCurrentPlots()];\n } else {\n console.error('番外分支没有开启请先开启调用:startBranches');\n }\n }\n\n /**\n * 退出番外\n */\n async exitExtraStory() {\n let firstPlot = getPlotsIndex().firstPlot;\n await PlotManager.startGameWithRecordIndex(0, firstPlot);\n GameModelManager.currPlots = [...PlotManager.getCurrentPlots()];\n this._isInExtraStoryScene = false;\n }\n\n}\n\nexport let ExtraStoryModelManager = new ExtraStoryModelManager1();"]}