2026-09-30 14:33:17 +08:00
|
|
|
import { meetBond } from "../bonds/state.js";
|
|
|
|
|
|
2026-09-28 20:58:29 +08:00
|
|
|
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 || {});
|
2026-09-30 14:33:17 +08:00
|
|
|
for (const bond of outcome.bonds || []) {
|
|
|
|
|
meetBond(run, typeof bond === "string" ? bond : bond.id,
|
|
|
|
|
typeof bond === "string" ? 1 : bond.level ?? 1);
|
|
|
|
|
}
|
2026-09-28 20:58:29 +08:00
|
|
|
return outcome;
|
|
|
|
|
};
|