From 308e537393df94f4b69cd0da889ea7d546c34bfc Mon Sep 17 00:00:00 2001 From: TastyPumPum <79149170+TastyPumPum@users.noreply.github.com> Date: Thu, 12 Oct 2023 15:50:29 +0100 Subject: [PATCH] Add a way to check gear lost in Wildy (#5394) --- src/mahoji/commands/gear.ts | 5 +- .../lib/abstracted_commands/gearCommands.ts | 51 +++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/src/mahoji/commands/gear.ts b/src/mahoji/commands/gear.ts index 921e6642c8..a657bbcf5a 100644 --- a/src/mahoji/commands/gear.ts +++ b/src/mahoji/commands/gear.ts @@ -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, diff --git a/src/mahoji/lib/abstracted_commands/gearCommands.ts b/src/mahoji/lib/abstracted_commands/gearCommands.ts index e662a31cf6..01474873e0 100644 --- a/src/mahoji/lib/abstracted_commands/gearCommands.ts +++ b/src/mahoji/lib/abstracted_commands/gearCommands.ts @@ -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'; @@ -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) {