mirror of
https://github.com/Shu-Ying/noname-shuying.git
synced 2026-10-05 05:03:07 +08:00
14 lines
493 B
JavaScript
14 lines
493 B
JavaScript
export const getAvailableStoryChoices = (run, content) => {
|
|
const flags = run.storyFlags || {};
|
|
return (content?.choices || []).filter(choice => {
|
|
return (choice.requires || []).every(flag => Boolean(flags[flag]))
|
|
&& (choice.excludes || []).every(flag => !flags[flag]);
|
|
});
|
|
};
|
|
|
|
export const applyStoryOutcome = (run, outcome = {}) => {
|
|
if (!run.storyFlags) run.storyFlags = {};
|
|
Object.assign(run.storyFlags, outcome.flags || {});
|
|
return outcome;
|
|
};
|