diff --git a/src/route.ts b/src/route.ts index 67c60a9..f4b238f 100644 --- a/src/route.ts +++ b/src/route.ts @@ -23,6 +23,7 @@ export function getTasks = Task>( const result: T[] = []; for (const quest of quests) { const questCompleted = quest.completed; + const questReady = quest.ready; for (const task of quest.tasks) { // Include quest name in task names and dependencies (unless dependency quest is given) const renamedTask = { ...task }; @@ -38,6 +39,12 @@ export function getTasks = Task>( const taskCompleted = task.completed; renamedTask.completed = () => questCompleted() || taskCompleted(); } + const taskReady = renamedTask.ready; + if (questReady !== undefined && taskReady !== undefined) { + renamedTask.ready = () => questReady() && taskReady(); + } else if (questReady !== undefined) { + renamedTask.ready = () => questReady(); + } result.push(renamedTask); } } diff --git a/src/task.ts b/src/task.ts index d300e35..6d20b7e 100644 --- a/src/task.ts +++ b/src/task.ts @@ -8,6 +8,7 @@ import { Outfit, OutfitSpec } from "./outfit"; export type Quest = { name: string; completed?: () => boolean; + ready?: () => boolean; tasks: T[]; };