diff --git a/src/mahoji/lib/abstracted_commands/fishingContestCommand.ts b/src/mahoji/lib/abstracted_commands/fishingContestCommand.ts index b622943acd..c7e03d21cc 100644 --- a/src/mahoji/lib/abstracted_commands/fishingContestCommand.ts +++ b/src/mahoji/lib/abstracted_commands/fishingContestCommand.ts @@ -18,8 +18,36 @@ import { updateBankSetting } from '../../../lib/util/updateBankSetting'; export async function fishingContestStartCommand(user: MUser, channelID: string, loc: string | undefined) { const currentFishType = getCurrentFishType(); const validLocs = getValidLocationsForFishType(currentFishType); + let quantity = 1; + let duration = Math.floor(quantity * Time.Minute * 1.69); + let quantityBoosts = []; + + const tackleBoxes = ["Champion's tackle box", 'Professional tackle box', 'Standard tackle box', 'Basic tackle box']; + for (let i = 0; i < tackleBoxes.length; i++) { + if (user.hasEquippedOrInBank(tackleBoxes[i])) { + let num = tackleBoxes.length - i; + quantityBoosts.push(`${num} for ${tackleBoxes[i]}`); + quantity += num; + break; + } + } + + if (user.hasEquippedOrInBank('Crystal fishing rod')) { + quantity++; + quantityBoosts.push('1 for Crystal fishing rod'); + } if (!loc) loc = validLocs[0].name; const fishingLocation = fishingLocations.find(i => stringMatches(i.name, loc!)); + + 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})`) @@ -38,24 +66,6 @@ export async function fishingContestStartCommand(user: MUser, channelID: string, if (user.minionIsBusy) { return 'Your minion is busy.'; } - let quantity = 1; - let duration = Math.floor(quantity * Time.Minute * 1.69); - let quantityBoosts = []; - - const tackleBoxes = ["Champion's tackle box", 'Professional tackle box', 'Standard tackle box', 'Basic tackle box']; - for (let i = 0; i < tackleBoxes.length; i++) { - if (user.hasEquippedOrInBank(tackleBoxes[i])) { - let num = tackleBoxes.length - i; - quantityBoosts.push(`${num} for ${tackleBoxes[i]}`); - quantity += num; - break; - } - } - - if (user.hasEquippedOrInBank('Crystal fishing rod')) { - quantity++; - quantityBoosts.push('1 for Crystal fishing rod'); - } const result = await getUsersFishingContestDetails(user); if (result.catchesFromToday.length > 0) {