From f9a6230c98a20c4fe504ac167efecc03d5ce7913 Mon Sep 17 00:00:00 2001 From: DayV Date: Mon, 25 Nov 2024 18:50:55 +0000 Subject: [PATCH] refactor quest req --- .../skilling/skills/thieving/stealables.ts | 6 ++---- src/mahoji/commands/steal.ts | 20 +++++++++---------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/lib/skilling/skills/thieving/stealables.ts b/src/lib/skilling/skills/thieving/stealables.ts index 34875fafbf..dbe8c5e40d 100644 --- a/src/lib/skilling/skills/thieving/stealables.ts +++ b/src/lib/skilling/skills/thieving/stealables.ts @@ -36,8 +36,7 @@ export interface Stealable { xp: number; qpRequired?: number; fireCapeRequired?: boolean; - questID?: QuestID; - questRequired?: string; + requiredQuests?: QuestID[]; table: LootTable; id: number; petChance: number; @@ -547,8 +546,7 @@ const pickpocketables: Stealable[] = [ intercept: 0, customTickRate: 10, // 2 tick thieving for 20s, downtime for ~80s petChance: 257_211, - questRequired: 'Children of the Sun', - questID: QuestID.ChildrenOfTheSun + requiredQuests: [QuestID.ChildrenOfTheSun] }, { name: 'Desert Bandit', diff --git a/src/mahoji/commands/steal.ts b/src/mahoji/commands/steal.ts index f18014b2e3..7c379d81f7 100644 --- a/src/mahoji/commands/steal.ts +++ b/src/mahoji/commands/steal.ts @@ -1,11 +1,12 @@ -import { mentionCommand, stringMatches } from '@oldschoolgg/toolkit/util'; +import { stringMatches } from '@oldschoolgg/toolkit/util'; import type { CommandRunOptions } from '@oldschoolgg/toolkit/util'; import type { User } from 'discord.js'; -import { ApplicationCommandOptionType } from 'discord.js'; +import { ApplicationCommandOptionType, bold } from 'discord.js'; import { randInt } from 'e'; import { formatDuration } from '@oldschoolgg/toolkit/util'; import { ArdougneDiary, userhasDiaryTier } from '../../lib/diaries'; +import { quests } from '../../lib/minions/data/quests'; import removeFoodFromUser from '../../lib/minions/functions/removeFoodFromUser'; import type { Stealable } from '../../lib/skilling/skills/thieving/stealables'; import { stealables } from '../../lib/skilling/skills/thieving/stealables'; @@ -75,14 +76,13 @@ export const stealCommand: OSBMahojiCommand = { } a ${stealable.name}.`; } - if (stealable.questID && !user.user.finished_quest_ids.includes(stealable.questID)) { - return `You need to complete the "${stealable.questRequired}" quest to ${ - stealable.type === 'pickpockable' ? 'pickpocket' : 'steal from' - } a ${stealable.name}. Send your minion to do the quest using: ${mentionCommand( - globalClient, - 'activities', - 'quest' - )}.`; + if (stealable.requiredQuests) { + const incompleteQuest = stealable.requiredQuests.find( + quest => !user.user.finished_quest_ids.includes(quest) + ); + return `You need to have completed the ${bold( + quests.find(i => i.id === incompleteQuest)!.name + )} quest to steal from ${stealable.name}.`; } if (stealable.fireCapeRequired) {