Skip to content

Commit

Permalink
Add toggle for Clue Buttons (#5635)
Browse files Browse the repository at this point in the history
  • Loading branch information
TastyPumPum authored Feb 2, 2024
1 parent 5530682 commit 27fb5d8
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/lib/clues/clueUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ButtonBuilder, ButtonStyle } from 'discord.js';
import { Bank } from 'oldschooljs';

import { BitField } from '../constants';
import { ClueTiers } from './clueTiers';

export function getClueScoresFromOpenables(openableScores: Bank, mutate = false) {
Expand All @@ -23,9 +24,9 @@ export function deduplicateClueScrolls({ loot, currentBank }: { loot: Bank; curr
return newLoot;
}

export function buildClueButtons(loot: Bank | null, perkTier: number) {
export function buildClueButtons(loot: Bank | null, perkTier: number, user: MUser) {
const components: ButtonBuilder[] = [];
if (loot && perkTier > 1) {
if (loot && perkTier > 1 && !user.bitfield.includes(BitField.DisableClueButtons)) {
const clueReceived = ClueTiers.filter(tier => loot.amount(tier.scrollID) > 0);
components.push(
...clueReceived.map(clue =>
Expand Down
8 changes: 7 additions & 1 deletion src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ export enum BitField {
UsedFrozenTablet = 34,
CleanHerbsFarming = 35,
SelfGamblingLocked = 36,
DisabledFarmingReminders = 37
DisabledFarmingReminders = 37,
DisableClueButtons = 38
}

interface BitFieldData {
Expand Down Expand Up @@ -338,6 +339,11 @@ export const BitFieldData: Record<BitField, BitFieldData> = {
name: 'Disable Farming Reminders',
protected: false,
userConfigurable: true
},
[BitField.DisableClueButtons]: {
name: 'Disable Clue Buttons',
protected: false,
userConfigurable: true
}
} as const;

Expand Down
2 changes: 1 addition & 1 deletion src/lib/util/handleTripFinish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export async function handleTripFinish(
const casketReceived = loot ? ClueTiers.find(i => loot?.has(i.id)) : undefined;
if (casketReceived) components.push(makeOpenCasketButton(casketReceived));
if (perkTier > PerkTier.One) {
components.push(...buildClueButtons(loot, perkTier));
components.push(...buildClueButtons(loot, perkTier, user));
const birdHousedetails = await calculateBirdhouseDetails(user.id);
if (birdHousedetails.isReady && !user.bitfield.includes(BitField.DisableBirdhouseRunButton))
components.push(makeBirdHouseTripButton());
Expand Down
4 changes: 4 additions & 0 deletions src/mahoji/commands/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ const toggles: UserConfigToggle[] = [
{
name: 'Disable farming reminders',
bit: BitField.DisabledFarmingReminders
},
{
name: 'Disable Clue Buttons',
bit: BitField.DisableClueButtons
}
];

Expand Down
2 changes: 1 addition & 1 deletion src/mahoji/lib/abstracted_commands/barbAssault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export async function barbAssaultGambleCommand(
const { itemsAdded, previousCL } = await user.addItemsToBank({ items: loot, collectionLog: true });

const perkTier = user.perkTier();
const components: ButtonBuilder[] = buildClueButtons(loot, perkTier);
const components: ButtonBuilder[] = buildClueButtons(loot, perkTier, user);

let response: Awaited<CommandResponse> = {
content: `You spent ${(
Expand Down
2 changes: 1 addition & 1 deletion src/mahoji/lib/abstracted_commands/minionStatusCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export async function minionStatusCommand(user: MUser): Promise<BaseMessageOptio

const { bank } = user;

if (!minionIsBusy) {
if (!minionIsBusy && !user.bitfield.includes(BitField.DisableClueButtons)) {
for (const tier of ClueTiers.filter(t => bank.has(t.scrollID))
.reverse()
.slice(0, 3)) {
Expand Down
2 changes: 1 addition & 1 deletion src/mahoji/lib/abstracted_commands/openCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ async function finalizeOpening({
.join(', ');

const perkTier = user.perkTier();
const components: ButtonBuilder[] = buildClueButtons(loot, perkTier);
const components: ButtonBuilder[] = buildClueButtons(loot, perkTier, user);

let response: Awaited<CommandResponse> = {
files: [image.file],
Expand Down

0 comments on commit 27fb5d8

Please sign in to comment.