Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow clue trip to be repeated if still have clues in bank #6229

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/lib/util/repeatStoredTrip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ButtonBuilder, ButtonStyle } from 'discord.js';
import { Time } from 'e';

import { autocompleteMonsters } from '../../mahoji/commands/k';
import { ClueTiers } from '../clues/clueTiers';
import type { PvMMethod } from '../constants';
import { SlayerActivityConstants } from '../minions/data/combatConstants';
import { darkAltarRunes } from '../minions/functions/darkAltarCommand';
Expand Down Expand Up @@ -67,10 +68,13 @@ import type { NightmareZoneActivityTaskOptions, UnderwaterAgilityThievingTaskOpt
import getOSItem from './getOSItem';
import { interactionReply } from './interactionReply';

const taskCanBeRepeated = (activity: Activity) => {
const taskCanBeRepeated = (activity: Activity, user: MUser) => {
if (activity.type === activity_type_enum.ClueCompletion) {
const realActivity = convertStoredActivityToFlatActivity(activity) as ClueActivityTaskOptions;
return realActivity.implingID !== undefined;
return (
realActivity.implingID !== undefined ||
user.owns(ClueTiers.find(clue => clue.id === realActivity.ci)!.scrollID)
DayV-git marked this conversation as resolved.
Show resolved Hide resolved
);
}
return !(
[
Expand All @@ -90,7 +94,10 @@ const taskCanBeRepeated = (activity: Activity) => {
const tripHandlers = {
[activity_type_enum.ClueCompletion]: {
commandName: 'clue',
args: (data: ClueActivityTaskOptions) => ({ tier: data.ci, implings: getOSItem(data.implingID!).name })
args: (data: ClueActivityTaskOptions) => ({
tier: data.ci,
implings: data.implingID ? getOSItem(data.implingID!).name : undefined
})
},
[activity_type_enum.SpecificQuest]: {
commandName: 'm',
Expand Down Expand Up @@ -692,8 +699,9 @@ export async function fetchRepeatTrips(userID: string) {
type: activity_type_enum;
data: Prisma.JsonValue;
}[] = [];
const user = await mUserFetch(userID);
for (const trip of res) {
if (!taskCanBeRepeated(trip)) continue;
if (!taskCanBeRepeated(trip, user)) continue;
if (trip.type === activity_type_enum.Farming && !(trip.data as any as FarmingActivityTaskOptions).autoFarmed) {
continue;
}
Expand Down