Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

will fix #5762

Closed
wants to merge 7 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 28 additions & 18 deletions src/mahoji/lib/abstracted_commands/fishingContestCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,36 @@
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) {

Check warning on line 42 in src/mahoji/lib/abstracted_commands/fishingContestCommand.ts

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

Unexpected string value in conditional. An explicit empty string check is required
for (const location of validLocs) {
if (user.bank.amount(location.bait.id) >= quantity) {
loc = location.name;
}
}
if (!loc) loc = validLocs[0].name;

Check warning on line 48 in src/mahoji/lib/abstracted_commands/fishingContestCommand.ts

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

Unexpected string value in conditional. An explicit empty string check is required
const fishingLocation = fishingLocations.find(i => stringMatches(i.name, loc!));

Check warning on line 49 in src/mahoji/lib/abstracted_commands/fishingContestCommand.ts

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

'fishingLocation' is already declared in the upper scope on line 40 column 8

Check warning on line 49 in src/mahoji/lib/abstracted_commands/fishingContestCommand.ts

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

'fishingLocation' is assigned a value but never used
}
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})`)
Expand All @@ -38,24 +66,6 @@
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) {
Expand Down
Loading