From f88b20a5f58e7580fb33351a89b285a3bcc65fb0 Mon Sep 17 00:00:00 2001 From: Turbo Date: Wed, 1 May 2024 19:12:34 -0500 Subject: [PATCH] Updated Fishing contest to attempt both locations by default (#5765) --- .../fishingContestCommand.ts | 47 +++++++++++-------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/src/mahoji/lib/abstracted_commands/fishingContestCommand.ts b/src/mahoji/lib/abstracted_commands/fishingContestCommand.ts index b622943acd..f07ee2247c 100644 --- a/src/mahoji/lib/abstracted_commands/fishingContestCommand.ts +++ b/src/mahoji/lib/abstracted_commands/fishingContestCommand.ts @@ -18,26 +18,6 @@ import { updateBankSetting } from '../../../lib/util/updateBankSetting'; export async function fishingContestStartCommand(user: MUser, channelID: string, loc: string | undefined) { const currentFishType = getCurrentFishType(); const validLocs = getValidLocationsForFishType(currentFishType); - if (!loc) loc = validLocs[0].name; - const fishingLocation = fishingLocations.find(i => stringMatches(i.name, loc!)); - if (!fishingLocation) { - return `That's not a valid location to fish at, you can fish at these locations: ${fishingLocations - .map(i => `${i.name}(${i.temperature} ${i.water})`) - .join(', ')}.`; - } - - if (!validLocs.includes(fishingLocation)) { - return `This Fishing Location isn't valid for todays catch! These ones are: ${validLocs - .map(i => i.name) - .join(', ')}`; - } - - if (!['Contest rod', "Beginner's tackle box"].every(i => user.hasEquippedOrInBank(i))) { - return 'You need to buy a Contest rod and a tackle box to compete in the Fishing contest.'; - } - if (user.minionIsBusy) { - return 'Your minion is busy.'; - } let quantity = 1; let duration = Math.floor(quantity * Time.Minute * 1.69); let quantityBoosts = []; @@ -56,6 +36,33 @@ export async function fishingContestStartCommand(user: MUser, channelID: string, quantity++; quantityBoosts.push('1 for Crystal fishing rod'); } + if (!loc) { + for (const location of validLocs) { + if (user.bank.amount(location.bait.id) >= quantity) { + loc = location.name; + } + } + if (!loc) loc = validLocs[0].name; + } + const fishingLocation = fishingLocations.find(i => stringMatches(i.name, loc!)); + if (!fishingLocation) { + return `That's not a valid location to fish at, you can fish at these locations: ${fishingLocations + .map(i => `${i.name}(${i.temperature} ${i.water})`) + .join(', ')}.`; + } + + if (!validLocs.includes(fishingLocation)) { + return `This Fishing Location isn't valid for todays catch! These ones are: ${validLocs + .map(i => i.name) + .join(', ')}`; + } + + if (!['Contest rod', "Beginner's tackle box"].every(i => user.hasEquippedOrInBank(i))) { + return "You need to a Contest rod and a Beginner's tackle box to compete in the Fishing contest."; + } + if (user.minionIsBusy) { + return 'Your minion is busy.'; + } const result = await getUsersFishingContestDetails(user); if (result.catchesFromToday.length > 0) {