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

Add loot pictures to impling clues #6155

Merged
merged 3 commits into from
Oct 31, 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
29 changes: 24 additions & 5 deletions src/mahoji/commands/clue.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import type { CommandRunOptions } from '@oldschoolgg/toolkit/util';
import type { CommandResponse, CommandRunOptions } from '@oldschoolgg/toolkit/util';
import { ApplicationCommandOptionType } from 'discord.js';
import { Time, notEmpty, randInt } from 'e';
import { Bank } from 'oldschooljs';
import type { Item, ItemBank } from 'oldschooljs/dist/meta/types';

import type { ClueTier } from '../../lib/clues/clueTiers';
import { ClueTiers } from '../../lib/clues/clueTiers';
import { BitField } from '../../lib/constants';
import { allOpenables, getOpenableLoot } from '../../lib/openables';
import { getPOHObject } from '../../lib/poh';
import type { ClueActivityTaskOptions } from '../../lib/types/minions';
import { formatDuration, isWeekend, stringMatches } from '../../lib/util';
import addSubTaskToActivityTask from '../../lib/util/addSubTaskToActivityTask';
import { calcMaxTripLength } from '../../lib/util/calcMaxTripLength';
import getOSItem, { getItem } from '../../lib/util/getOSItem';
import { makeBankImage } from '../../lib/util/makeBankImage';
import { getPOH } from '../lib/abstracted_commands/pohCommand';
import type { OSBMahojiCommand } from '../lib/util';
import { addToOpenablesScores, getMahojiBank, mahojiUsersSettingsFetch } from '../mahojiSettings';
Expand Down Expand Up @@ -323,6 +325,8 @@ export const clueCommand: OSBMahojiCommand = {

timeToFinish = result.duration;

const response: Awaited<CommandResponse> = {};

let implingLootString = '';
let implingClues = 0;
if (!clueImpling) {
Expand Down Expand Up @@ -350,18 +354,31 @@ export const clueCommand: OSBMahojiCommand = {
}

await addToOpenablesScores(user, new Bank().add(implingJarOpenable.id, openedImplings));
await user.transactItems({

const { previousCL } = await user.transactItems({
itemsToAdd: implingLoot,
itemsToRemove: new Bank().add(clueImpling, openedImplings).add(clueTier.scrollID, bankedClues),
collectionLog: true
});

const image = await makeBankImage({
bank: implingLoot,
title: `Loot from ${openedImplings}x ${implingJarOpenable.name}`,
user,
previousCL,
mahojiFlags: user.bitfield.includes(BitField.DisableOpenableNames) ? undefined : ['show_names']
});

response.files = [image.file];

if (bankedClues + implingClues === 0) {
return `You don't have any clues, and didn't find any in ${openedImplings}x ${clueImpling.name}s. At least you received the following loot: ${implingLoot}.`;
response.content = `You don't have any clues, and didn't find any in ${openedImplings}x ${clueImpling.name}s.`;
return response;
}
quantity = bankedClues + implingClues;
implingLootString = `\n\nYou will find ${implingClues} clue${
implingClues === 0 || implingClues > 1 ? 's' : ''
} from ${openedImplings}x ${clueImpling.name}s, and receive the following loot: ${implingLoot}.`;
} from ${openedImplings}x ${clueImpling.name}s.`;
}

duration = timeToFinish * quantity;
Expand All @@ -376,10 +393,12 @@ export const clueCommand: OSBMahojiCommand = {
duration,
type: 'ClueCompletion'
});
return `${user.minionName} is now completing ${quantity}x ${

response.content = `${user.minionName} is now completing ${quantity}x ${
clueTier.name
} clues, it'll take around ${formatDuration(duration)} to finish.${
boosts.length > 0 ? `\n\n**Boosts:** ${boosts.join(', ')}.` : ''
}${implingLootString}`;
return response;
}
};