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

Farming Fixes - Don't use Invention unless harvesting, correct check for Mysterious trees. #5666

Merged
merged 2 commits into from
Feb 7, 2024
Merged
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
20 changes: 11 additions & 9 deletions src/tasks/minions/farmingActivity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@

const plopperBoostPercent = 100;

async function farmingLootBoosts(user: MUser, plant: Plant, loot: Bank, messages: string[]) {
async function farmingLootBoosts(
user: MUser,
method: 'harvest' | 'plant',
plant: Plant,
loot: Bank,
messages: string[]
) {
let bonusPercentage = 0;
if (user.allItemsOwned.has('Plopper')) {
bonusPercentage += plopperBoostPercent;
Expand All @@ -41,7 +47,7 @@
bonusPercentage += 100;
messages.push('100% for Farming master cape');
}
if (user.hasEquippedOrInBank(['Arcane harvester']) && plant.name !== 'Mysterious tree') {
if (method === 'harvest' && user.hasEquippedOrInBank(['Arcane harvester']) && plant.name !== 'Mysterious tree') {
const boostRes = await inventionItemBoost({
user,
inventionID: InventionID.ArcaneHarvester,
Expand Down Expand Up @@ -139,7 +145,7 @@

const hasPlopper = user.allItemsOwned.has('Plopper');

const plant = Farming.Plants.find(plant => plant.name === plantsName)!;

Check warning on line 148 in src/tasks/minions/farmingActivity.ts

View workflow job for this annotation

GitHub Actions / ESLint

'plant' is already declared in the upper scope on line 148 column 9
assert(Boolean(plant));

if (user.hasEquippedOrInBank('Magic secateurs')) {
Expand Down Expand Up @@ -211,21 +217,17 @@
duration: data.duration
})}`;

await farmingLootBoosts(user, plant, loot, infoStr);
await farmingLootBoosts(user, 'plant', plant, loot, infoStr);

if (loot.has('Plopper')) {
loot.bank[itemID('Plopper')] = 1;
}

if (loot.has('Tormented skull')) {
loot.bank[itemID('Tormented skull')] = 1;
}

if (loot.length > 0) {
str += `\n\nYou received: ${loot}.`;
}

updateBankSetting('farming_loot_bank', loot);

Check warning on line 230 in src/tasks/minions/farmingActivity.ts

View workflow job for this annotation

GitHub Actions / ESLint

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
await transactItems({
userID: user.id,
collectionLog: true,
Expand All @@ -248,10 +250,10 @@

str += `\n\n${user.minionName} tells you to come back after your plants have finished growing!`;

handleTripFinish(user, channelID, str, undefined, data, null);

Check warning on line 253 in src/tasks/minions/farmingActivity.ts

View workflow job for this annotation

GitHub Actions / ESLint

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
} else if (patchType.patchPlanted) {
// If they do have something planted here, harvest it and possibly replant.
const plantToHarvest = Farming.Plants.find(plant => plant.name === patchType.lastPlanted)!;

Check warning on line 256 in src/tasks/minions/farmingActivity.ts

View workflow job for this annotation

GitHub Actions / ESLint

'plant' is already declared in the upper scope on line 148 column 9

let quantityDead = 0;
if (!hasPlopper) {
Expand Down Expand Up @@ -476,12 +478,12 @@
if (roll(plopperDroprate)) loot.add('Plopper');
} else if (
patchType.patchPlanted &&
plantToHarvest.petChance &&

Check warning on line 481 in src/tasks/minions/farmingActivity.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected number value in conditional. An explicit zero/NaN check is required
alivePlants > 0 &&
roll(petDropRate / alivePlants)
) {
loot.add('Tangleroot');
} else if (patchType.patchPlanted && plantToHarvest.petChance && alivePlants > 0) {

Check warning on line 486 in src/tasks/minions/farmingActivity.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected number value in conditional. An explicit zero/NaN check is required
const plopperDroprate = clAdjustedDroprate(
user,
'Plopper',
Expand Down Expand Up @@ -566,9 +568,9 @@
infoStr.push(`\n${user.minionName} tells you to come back after your plants have finished growing!`);
}

await farmingLootBoosts(user, plant, loot, infoStr);
await farmingLootBoosts(user, 'harvest', plantToHarvest, loot, infoStr);

if (plant.name === 'Mysterious tree') {
if (plantToHarvest.name === 'Mysterious tree') {
if (loot.has('Seed Pack')) {
loot.add('Seed Pack', 1);
infoStr.push('+1 Seed Pack for Mysterious tree farming contract');
Expand Down Expand Up @@ -599,7 +601,7 @@
}
}
// Give the boxes for harvesting during a harvest
if (alivePlants && plantToHarvest.name === 'Mysterious tree') {

Check warning on line 604 in src/tasks/minions/farmingActivity.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected number value in conditional. An explicit zero/NaN check is required
for (let j = 0; j < alivePlants; j++) {
let upper = randInt(1, 3);
for (let i = 0; i < upper; i++) {
Expand All @@ -609,7 +611,7 @@
}

for (const mut of mutations) {
if (alivePlants && plantToHarvest.name === mut.plantName && roll(mut.chance)) {

Check warning on line 614 in src/tasks/minions/farmingActivity.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected number value in conditional. An explicit zero/NaN check is required
loot.add(mut.output);
infoStr.push(`One of your crops mutated into a ${itemNameFromID(mut.output)}.`);
}
Expand All @@ -619,7 +621,7 @@
infoStr.push(`\nYou received: ${loot}.`);
}

updateBankSetting('farming_loot_bank', loot);

Check warning on line 624 in src/tasks/minions/farmingActivity.ts

View workflow job for this annotation

GitHub Actions / ESLint

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
await transactItems({
userID: user.id,
collectionLog: true,
Expand Down
Loading