mirror of
https://github.com/Shu-Ying/noname-shuying.git
synced 2026-10-05 05:03:07 +08:00
18 lines
820 B
JavaScript
18 lines
820 B
JavaScript
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);
|
|
}
|
|
};
|