Skip to content

Commit

Permalink
Merge branch 'master' into fish-drop-table
Browse files Browse the repository at this point in the history
  • Loading branch information
nwjgit authored Feb 14, 2024
2 parents e8711a8 + 3267641 commit fa3a83d
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ export enum BitField {
SelfGamblingLocked = 36,
DisabledFarmingReminders = 37,
DisableClueButtons = 38,
DisableAutoSlayButton = 39
DisableAutoSlayButton = 39,
DisableHighPeakTimeWarning = 40
}

interface BitFieldData {
Expand Down Expand Up @@ -350,6 +351,11 @@ export const BitFieldData: Record<BitField, BitFieldData> = {
name: 'Disable Auto Slay Button',
protected: false,
userConfigurable: true
},
[BitField.DisableHighPeakTimeWarning]: {
name: 'Disable Wilderness High Peak Time Warning',
protected: false,
userConfigurable: true
}
} as const;

Expand Down
4 changes: 2 additions & 2 deletions src/lib/data/Collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function kcProg(mon: Monster): FormatProgressFunction {
}

function mgProg(minigameName: MinigameName): FormatProgressFunction {
return ({ minigames }) => `${minigames[minigameName]} KC`;
return ({ minigames }) => `${minigames[minigameName]} Completions`;
}

function skillProg(skillName: SkillsEnum): FormatProgressFunction {
Expand Down Expand Up @@ -807,7 +807,7 @@ export const allCollectionLogs: ICollection = {
"Shades of Mort'ton": {
items: shadesOfMorttonCL,
isActivity: true,
fmtProg: () => '0 KC'
fmtProg: mgProg('shades_of_morton')
},
'Soul Wars': {
alias: ['soul wars', 'sw'],
Expand Down
2 changes: 2 additions & 0 deletions src/lib/slayer/tasks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ export const allSlayerTasks: AssignableSlayerTask[] = [
...vannakaTasks,
...duradelTasks
];

export const allSlayerMonsters = allSlayerTasks.map(m => m.monster);
4 changes: 4 additions & 0 deletions src/mahoji/commands/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ const toggles: UserConfigToggle[] = [
{
name: 'Disable Clue Buttons',
bit: BitField.DisableClueButtons
},
{
name: 'Disable wilderness high peak time warning',
bit: BitField.DisableHighPeakTimeWarning
}
];

Expand Down
100 changes: 100 additions & 0 deletions src/mahoji/commands/testpotato.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ import { prisma } from '../../lib/settings/prisma';
import { getFarmingInfo } from '../../lib/skilling/functions/getFarmingInfo';
import Skills from '../../lib/skilling/skills';
import Farming from '../../lib/skilling/skills/farming';
import { slayerMasterChoices } from '../../lib/slayer/constants';
import { slayerMasters } from '../../lib/slayer/slayerMasters';
import { getUsersCurrentSlayerInfo } from '../../lib/slayer/slayerUtil';
import { allSlayerMonsters } from '../../lib/slayer/tasks';
import { stringMatches } from '../../lib/util';
import { calcDropRatesFromBankWithoutUniques } from '../../lib/util/calcDropRatesFromBank';
import {
Expand Down Expand Up @@ -514,6 +518,46 @@ export const testPotatoCommand: OSBMahojiCommand | null = production
}
}
]
},
{
type: ApplicationCommandOptionType.Subcommand,
name: 'setslayertask',
description: 'Set slayer task.',
options: [
{
type: ApplicationCommandOptionType.String,
name: 'master',
description: 'The master you wish to set your task.',
required: true,
choices: slayerMasterChoices
},
{
type: ApplicationCommandOptionType.String,
name: 'monster',
description: 'The monster you want to set your task as.',
required: true,
autocomplete: async value => {
const filteredMonsters = [...new Set(allSlayerMonsters)].filter(monster => {
if (!value) return true;
return [monster.name.toLowerCase(), ...monster.aliases].some(aliases =>
aliases.includes(value.toLowerCase())
);
});
return filteredMonsters.map(monster => ({
name: monster.name,
value: monster.name
}));
}
},
{
type: ApplicationCommandOptionType.Integer,
name: 'quantity',
description: 'The task quantity you want to assign.',
required: false,
min_value: 0,
max_value: 1000
}
]
}
],
run: async ({
Expand All @@ -534,6 +578,7 @@ export const testPotatoCommand: OSBMahojiCommand | null = production
set?: { qp?: number; all_ca_tasks?: boolean };
check?: { monster_droprates?: string };
bingo_tools?: { start_bingo: string };
setslayertask?: { master: string; monster: string; quantity: number };
}>) => {
if (production) {
logError('Test command ran in production', { userID: userID.toString() });
Expand Down Expand Up @@ -832,6 +877,61 @@ ${droprates.join('\n')}`),
return userGrowingProgressStr((await getFarmingInfo(userID)).patchesDetailed);
}

if (options.setslayertask) {
const user = await mUserFetch(userID);
const usersTask = await getUsersCurrentSlayerInfo(user.id);

const { monster, master } = options.setslayertask;

const selectedMonster = allSlayerMonsters.find(m => stringMatches(m.name, monster));
const selectedMaster = slayerMasters.find(
sm => stringMatches(master, sm.name) || sm.aliases.some(alias => stringMatches(master, alias))
);

// Set quantity to 50 if user doesn't assign a quantity
const quantity = options.setslayertask?.quantity ?? 50;

const assignedTask = selectedMaster!.tasks.find(m => m.monster.id === selectedMonster?.id)!;

if (!selectedMaster) return 'Invalid slayer master.';
if (!selectedMonster) return 'Invalid monster.';
if (!assignedTask) return `${selectedMaster.name} can not assign ${selectedMonster.name}.`;

// Update an existing slayer task for the user
if (usersTask.currentTask?.id) {
await prisma.slayerTask.update({
where: {
id: usersTask.currentTask?.id
},
data: {
quantity,
quantity_remaining: quantity,
slayer_master_id: selectedMaster.id,
monster_id: selectedMonster.id,
skipped: false
}
});
} else {
// Create a new slayer task for the user
await prisma.slayerTask.create({
data: {
user_id: user.id,
quantity,
quantity_remaining: quantity,
slayer_master_id: selectedMaster.id,
monster_id: selectedMonster.id,
skipped: false
}
});
}

await user.update({
slayer_last_task: selectedMonster.id
});

return `You set your slayer task to ${selectedMonster.name} using ${selectedMaster.name}.`;
}

return 'Nothin!';
}
};
4 changes: 2 additions & 2 deletions src/mahoji/lib/abstracted_commands/minionKill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Bank, Monsters } from 'oldschooljs';
import { MonsterAttribute } from 'oldschooljs/dist/meta/monsterData';
import { itemID } from 'oldschooljs/dist/util';

import { PeakTier, PvMMethod } from '../../../lib/constants';
import { BitField, PeakTier, PvMMethod } from '../../../lib/constants';
import { Eatables } from '../../../lib/data/eatables';
import { getSimilarItems } from '../../../lib/data/similarItems';
import { checkUserCanUseDegradeableItem, degradeablePvmBoostItems, degradeItem } from '../../../lib/degradeableItems';
Expand Down Expand Up @@ -689,7 +689,7 @@ export async function minionKillCommand(
break;
}
}
if (wildyPeak?.peakTier === PeakTier.High) {
if (wildyPeak?.peakTier === PeakTier.High && !user.bitfield.includes(BitField.DisableHighPeakTimeWarning)) {
if (interaction) {
await handleMahojiConfirmation(
interaction,
Expand Down

0 comments on commit fa3a83d

Please sign in to comment.