Skip to content

Commit

Permalink
refactor quest req
Browse files Browse the repository at this point in the history
  • Loading branch information
DayV-git committed Nov 25, 2024
1 parent 1e41aa7 commit f9a6230
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
6 changes: 2 additions & 4 deletions src/lib/skilling/skills/thieving/stealables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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',
Expand Down
20 changes: 10 additions & 10 deletions src/mahoji/commands/steal.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit f9a6230

Please sign in to comment.