From ad863cd423b5356327b2eb27bdf54c560f844124 Mon Sep 17 00:00:00 2001 From: Patrick Stalcup Date: Sun, 22 Oct 2023 17:10:15 -0400 Subject: [PATCH] Add support for a quest level ready --- src/route.ts | 7 +++++++ src/task.ts | 1 + 2 files changed, 8 insertions(+) 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[]; };