fixed # 重构梦三项目结构

This commit is contained in:
2026-09-30 10:23:58 +08:00
parent 3fdaf6d218
commit f2da9bce65
53 changed files with 267 additions and 175 deletions
+17
View File
@@ -0,0 +1,17 @@
export const isDialogueLineVisible = (line, run) => !line.when || run?.storyFlags?.[line.when.flag] === line.when.equals;
export const applyDialogueChoice = (run, line, choiceId) => {
const choice = line.choices?.find(item => item.id === choiceId);
if (!choice || !run || !/^story\.[\w.]+$/.test(line.flag || "")) throw new Error("梦三剧情发言选项无效");
run.storyFlags ||= {};
run.storyFlags[line.flag] = choice.id;
return choice.text;
};
export const applySkippedDialogueChoices = (lines, startIndex, run) => {
for (let index = startIndex; index < lines.length; index++) {
const line = lines[index];
if (!isDialogueLineVisible(line, run) || line.type !== "choice") continue;
applyDialogueChoice(run, line, line.defaultChoice || line.choices[0].id);
}
};