Skip to content

Commit

Permalink
Add a way to check gear lost in Wildy (#5394)
Browse files Browse the repository at this point in the history
  • Loading branch information
TastyPumPum authored Oct 12, 2023
1 parent a7e26c2 commit 308e537
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/mahoji/commands/gear.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ export const gearCommand: OSBMahojiCommand = {
name: 'setup',
description: 'The setup you want to view.',
required: true,
choices: ['All', ...GearSetupTypes].map(i => ({ name: toTitleCase(i), value: i }))
choices: ['All', ...GearSetupTypes, 'Lost on wildy death'].map(i => ({
name: toTitleCase(i),
value: i
}))
},
{
type: ApplicationCommandOptionType.Boolean,
Expand Down
51 changes: 51 additions & 0 deletions src/mahoji/lib/abstracted_commands/gearCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { unEquipAllCommand } from '../../../lib/minions/functions/unequipAllComm
import { prisma } from '../../../lib/settings/prisma';
import { defaultGear, Gear, globalPresets } from '../../../lib/structures/Gear';
import { assert, formatSkillRequirements, isValidGearSetup, stringMatches } from '../../../lib/util';
import calculateGearLostOnDeathWilderness from '../../../lib/util/calculateGearLostOnDeathWilderness';
import { gearEquipMultiImpl } from '../../../lib/util/equipMulti';
import { getItem } from '../../../lib/util/getOSItem';
import { handleMahojiConfirmation } from '../../../lib/util/handleMahojiConfirmation';
Expand Down Expand Up @@ -343,6 +344,56 @@ export async function gearViewCommand(user: MUser, input: string, text: boolean)
files: [file]
};
}
if (stringMatches(input, 'lost on wildy death')) {
interface GearLostOptions {
gear: GearSetup;
skulled: boolean;
after20wilderness: boolean;
smited: boolean;
protectItem: boolean;
}

function showGearLost(options: GearLostOptions) {
const results = calculateGearLostOnDeathWilderness(options);
return results; // Return the entire results object
}

function calculateAndGetString(options: GearLostOptions, smited: boolean): string {
const gearLost = showGearLost({ ...options, smited });
return gearLost.lostItems.toString();
}

const userGear = user.gear.wildy;
const scenarios = [
{ skulled: true, after20wilderness: true, smited: false, protectItem: true },
{ skulled: true, after20wilderness: true, smited: true, protectItem: true },
{ skulled: false, after20wilderness: true, smited: true, protectItem: true },
{ skulled: false, after20wilderness: true, smited: false, protectItem: true },
{ skulled: false, after20wilderness: false, smited: true, protectItem: true },
{ skulled: false, after20wilderness: false, smited: false, protectItem: true }
];

const scenarioDescriptions = [
'when skulled',
'when skulled and smited',
'in 20+ Wilderness and smited',
'in 20+ Wilderness',
'in less than 20 Wilderness and smited',
'in less than 20 Wilderness'
];

const content = scenarios
.map((scenario, index) => {
const lostItemsString = calculateAndGetString({ gear: userGear, ...scenario }, scenario.smited);
const description = scenarioDescriptions[index];
return `The gear you would lose ${description}:\n${lostItemsString}`;
})
.join('\n\n');

const updatedContent = `${content}\n\nThese assume you have atleast 25 prayer for the protect item prayer.`;

return { content: updatedContent };
}
if (!isValidGearSetup(input)) return 'Invalid setup.';
const gear = user.gear[input];
if (text) {
Expand Down

0 comments on commit 308e537

Please sign in to comment.