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

Managing Miscellania #5960

Closed
wants to merge 5,457 commits into from

Conversation

TastyPumPum
Copy link
Contributor

@TastyPumPum TastyPumPum commented Jul 18, 2024

Adds the ability to collect from the Kingdom of Miscellania.

For simplicity in the bot, we assume:

  • The coffer is always topped up.
  • The approval rating is always at 100%. (However the trip time scales with the amount of days since you last claimed, to reflect getting the approval)
  • The requirements for Royal Trouble are met, allowing the maximum number of workers.

Key Points:

  • The GP is not stored in the coffer. Instead, the relevant amount is taken directly from your bank when you send the trip.
  • The storage cap is set at 100 days, costing 75,000 GP per day. Therefore, the maximum cost for a trip is 7.5m GP.
  • Use the /activities managing_miscellania command to start the activity. You will need to specify your main collect area (where the 10 workers are) and the secondary collect area (where the additional 5 workers are).

Testing Tool:

  • A new /testpotato setcooldown command has been added to modify the date you last performed Managing Miscellania. (Also tears of guthix and dailies)

  • I have tested all my changes thoroughly.
    closes: Managing Miscellania #1609


🚀 This description was created by Ellipsis for commit f7b3b51

Summary:

Added functionality to manage and collect resources from the Kingdom of Miscellania, including new commands, tasks, and database fields.

Key points:

  • Added managing_miscellania_cost and managing_miscellania_loot fields to prisma/schema.prisma.
  • Introduced ManagingMiscellaniaActivityTaskOptions in src/lib/types/minions.ts.
  • Added managingMiscellaniaTask to src/lib/Task.ts.
  • Updated cooldownTimers in src/lib/events.ts to include Managing Miscellania.
  • Added ManagingMiscellania case in minionStatus function in src/lib/util/minionStatus.ts.
  • Updated taskCanBeRepeated and tripHandlers in src/lib/util/repeatStoredTrip.ts.
  • Added managing_miscellania_cost and managing_miscellania_loot to ClientBankKey in src/lib/util/updateBankSetting.ts.
  • Introduced managingMiscellaniaCommand in src/mahoji/commands/activities.ts.
  • Created managingMiscellaniaCommand in src/mahoji/lib/abstracted_commands/managingMiscellaniaCommand.ts.
  • Added managingMiscellaniaTask in src/tasks/managingMiscellaniaActivity.ts.
  • Updated tests/globalSetup.ts to include last_managing_miscellania_timestamp.

Generated with ❤️ by ellipsis.dev

gc and others added 30 commits February 26, 2024 22:59
* Add price abuse check to packaged buyables.
@TastyPumPum TastyPumPum changed the title (WIP) Managing Miscellania Managing Miscellania Jul 21, 2024
@TastyPumPum TastyPumPum marked this pull request as ready for review July 21, 2024 09:32
@TastyPumPum
Copy link
Contributor Author

@ellipsis-dev review this pr

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Reviewed everything up to f7b3b51 in 46.953906 seconds

More details
  • Looked at 791 lines of code in 12 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_QpI0DAU4V6q3oB38


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me! Reviewed everything up to f7b3b51 in 45.054875 seconds

More details
  • Looked at 791 lines of code in 12 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. src/mahoji/lib/abstracted_commands/managingMiscellaniaCommand.ts:123
  • Draft comment:
    The conflict check for the main and secondary collection areas in managingMiscellaniaCommand is redundant if the main and secondary areas are the same. Consider reordering the checks to avoid unnecessary operations:
if (mainPair === secondaryPair) {
    return 'You are unable to allocate workers to the same area.';
}
if (conflictPairs[mainPair]?.includes(secondaryPair)) {
    return conflictString;
}
  • Reason this comment was not posted:
    Based on historical feedback, this comment is too similar to comments previously marked by users as bad.

Workflow ID: wflow_wo8bLL0KlPTEA35f


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Comment on lines 163 to 246
export const managingMiscellaniaTask: MinionTask = {
type: 'ManagingMiscellania',
async run(data: ManagingMiscellaniaActivityTaskOptions) {
const { userID, channelID, main_collect, secondary_collect, cofferCost } = data;
const user = await mUserFetch(userID);
const loot = new Bank();

const main = main_collect;
const secondary = secondary_collect;
const cofferMax = 75000;

const daysDifference = Math.round(cofferCost / 75_000);

const workerEffectiveness = (cofferMax * 100) / 8333;

const dailyResourcePoints = Math.floor((workerEffectiveness * 127) / 100);

const totalResourcePoints = Math.min(262143, daysDifference * dailyResourcePoints);

const mainQty = getBaseQuantity(main, 10, totalResourcePoints);
const secondaryQty = getBaseQuantity(secondary, 5, totalResourcePoints);

await userStatsUpdate(user.id, { last_managing_miscellania_timestamp: new Date().getTime() }, {});

function addLoot(category: string, quantity: number) {
switch (category) {
case 'Wood':
loot.add('Maple logs', quantity);
loot.add(nestTable.roll(Math.min(999, Math.floor(quantity / 100))));
break;
case 'Mining':
loot.add('Coal', quantity);
loot.add(miningGems.roll(Math.floor(quantity / 200 + 0.5)));
break;
case 'Fishing':
loot.add('Raw tuna', Math.floor(0.5 * quantity));
loot.add('Raw swordfish', Math.floor(0.15 * quantity));
loot.add(fishingLoot.roll(Math.floor(quantity / 200)));
break;
case 'Cooked Fish':
loot.add('Tuna', Math.floor(0.5 * quantity));
loot.add('Swordfish', Math.floor(0.15 * quantity));
loot.add(fishingLoot.roll(Math.floor(quantity / 200)));
break;
case 'Herbs':
loot.add(herbsLoot.roll(quantity));
loot.add(herbSeedsLoot.roll(Math.floor(quantity / 100)));
break;
case 'Flax':
loot.add('Flax', quantity);
loot.add(flaxSeedsLoot.roll(Math.floor(quantity / 600)));
break;
case 'Mahogany':
loot.add('Mahogany logs', quantity);
loot.add(nestTable.roll(Math.floor(quantity / 350)));
break;
case 'Teak':
loot.add('Teak logs', quantity);
loot.add(nestTable.roll(Math.floor(quantity / 350)));
break;
case 'Hardwood (Mahogany and Teak)':
loot.add('Mahogany logs', Math.floor(quantity * 0.5));
loot.add('Teak logs', Math.floor(quantity * 0.5));
loot.add(nestTable.roll(Math.floor(quantity / 350)));
break;
case 'Farm':
loot.add(seedsLoot.roll(quantity));
loot.add(treeSeedsLoot.roll(Math.floor(quantity / 200)));
break;
}
}

addLoot(main, mainQty);
addLoot(secondary, secondaryQty);

const str = `${user}, ${user.minionName} finished collecting from the kingdom, you received ${loot}.`;

await user.addItemsToBank({ items: loot, collectionLog: true });
await updateBankSetting('managing_miscellania_loot', loot);

const image = await makeBankImage({ bank: loot, title: 'Managing Miscellania Loot', user });

handleTripFinish(user, channelID, str, image.file.attachment, data, loot);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be abstracted outside this task, so that we can test/run it without a minion trip. It might be something like function determineManagingMiscLoot(inputsNeeded). This gives several big benefits: we can add simulating commands for it, and add tests for it.

You may want a second function which determines points/etc based on dates (not 100% sure how it works)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Managing Miscellania
8 participants