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

 ឵឵  #5763

Closed
wants to merge 3 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
44 changes: 26 additions & 18 deletions src/mahoji/lib/abstracted_commands/fishingContestCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,36 @@
import addSubTaskToActivityTask from '../../../lib/util/addSubTaskToActivityTask';
import { updateBankSetting } from '../../../lib/util/updateBankSetting';

export async function fishingContestStartCommand(user: MUser, channelID: string, loc: string | undefined) {

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

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

'channelID' is defined but never used

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

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

'loc' is defined but never used
const currentFishType = getCurrentFishType();
const validLocs = getValidLocationsForFishType(currentFishType);

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

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

'validLocs' is assigned a value but never used
let quantity = 1;
let duration = Math.floor(quantity * Time.Minute * 1.69);

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

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

'duration' is assigned a value but never used
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) {

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

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

Unexpected any value in conditional. An explicit comparison or type cast 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 47 in src/mahoji/lib/abstracted_commands/fishingContestCommand.ts

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

Unexpected any value in conditional. An explicit comparison or type cast is required
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
Expand All @@ -26,7 +52,7 @@
.join(', ')}.`;
}

if (!validLocs.includes(fishingLocation)) {

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

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

Unexpected any value in conditional. An explicit comparison or type cast is required
return `This Fishing Location isn't valid for todays catch! These ones are: ${validLocs
.map(i => i.name)
.join(', ')}`;
Expand All @@ -35,27 +61,9 @@
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) {

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

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

Unexpected any value in conditional. An explicit comparison or type cast is required
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 All @@ -65,7 +73,7 @@
}

const cost = new Bank().add(fishingLocation.bait.id, quantity);
if (!user.owns(cost)) {

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

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

Unexpected any value in conditional. An explicit comparison or type cast is required
return `You need ${cost} to bait fish at ${fishingLocation.name}.`;
}
await user.removeItemsFromBank(cost);
Expand Down
Loading