Skip to content

Commit

Permalink
Add moon key drops
Browse files Browse the repository at this point in the history
  • Loading branch information
gc committed Dec 2, 2024
1 parent 1192545 commit 6bc66da
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
14 changes: 12 additions & 2 deletions src/lib/util/minionUtils.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { toTitleCase } from '@oldschoolgg/toolkit/util';
import { perTimeUnitChance, toTitleCase } from '@oldschoolgg/toolkit/util';
import type { BaseMessageOptions } from 'discord.js';
import { escapeMarkdown, time } from 'discord.js';
import { Time } from 'e';
import { convertXPtoLVL } from 'oldschooljs/dist/util/util';
import { type Bank, convertXPtoLVL } from 'oldschooljs/dist/util/util';
import { resolveItems } from 'oldschooljs/dist/util/util';

import { MUserClass } from '../MUser';
import { Emoji } from '../constants';
import { QuestID } from '../minions/data/quests';
import type { SkillsEnum } from '../skilling/types';
import type { Peak } from './../tickers';

Expand Down Expand Up @@ -103,3 +105,11 @@ export function checkPeakTimes(): BaseMessageOptions {
content: str
};
}

export function rollForMoonKeyHalf({ user, duration, loot }: { user: MUser | boolean; duration: number; loot: Bank }) {
if (user instanceof MUserClass && !user.user.finished_quest_ids.includes(QuestID.ChildrenOfTheSun)) return;
if (!user) return;
perTimeUnitChance(duration, 1, Time.Minute * 30, () => {
loot.add('Loop half of key (moon key)');
});
}
21 changes: 18 additions & 3 deletions src/tasks/minions/miningActivity.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Time, increaseNumByPercent, randInt, roll, sumArr } from 'e';

import { Emoji, Events } from '../../lib/constants';
import { QuestID } from '../../lib/minions/data/quests';
import addSkillingClueToLoot from '../../lib/minions/functions/addSkillingClueToLoot';
import Mining, { prospectorItemsArr } from '../../lib/skilling/skills/mining';
import { type Ore, SkillsEnum } from '../../lib/skilling/types';
Expand All @@ -9,14 +10,23 @@ import { UpdateBank } from '../../lib/structures/UpdateBank';
import type { MiningActivityTaskOptions } from '../../lib/types/minions';
import { skillingPetDropRate, toKMB } from '../../lib/util';
import { handleTripFinish } from '../../lib/util/handleTripFinish';
import { rollForMoonKeyHalf } from '../../lib/util/minionUtils';

export function determineMiningResult({
ore,
quantity,
gearBank,
duration,
isPowermining
}: { ore: Ore; quantity: number; gearBank: GearBank; duration: number; isPowermining: boolean }) {
isPowermining,
hasFinishedCOTS
}: {
ore: Ore;
quantity: number;
gearBank: GearBank;
duration: number;
isPowermining: boolean;
hasFinishedCOTS: boolean;
}) {
const miningLvl = gearBank.skillsAsLevels.mining;
const messages: string[] = [];
let xpToReceive = quantity * ore.xp;
Expand Down Expand Up @@ -108,6 +118,10 @@ export function determineMiningResult({
}
}

if (ore.name === 'Runite ore') {
rollForMoonKeyHalf({ user: hasFinishedCOTS, duration, loot: updateBank.itemLootBank });
}

return {
updateBank,
messages,
Expand All @@ -128,7 +142,8 @@ export const miningTask: MinionTask = {
quantity,
gearBank: user.gearBank,
duration,
isPowermining: powermine
isPowermining: powermine,
hasFinishedCOTS: user.user.finished_quest_ids.includes(QuestID.ChildrenOfTheSun)
});

const updateResult = await updateBank.transact(user);
Expand Down
7 changes: 6 additions & 1 deletion src/tasks/minions/woodcuttingActivity.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { perTimeUnitChance } from '@oldschoolgg/toolkit/util';
import { Time, objectEntries, percentChance, randInt } from 'e';
import { Bank } from 'oldschooljs';
import { Bank, EItem } from 'oldschooljs';

import type { TwitcherGloves } from '../../lib/constants';
import { Emoji, Events } from '../../lib/constants';
Expand All @@ -14,6 +14,7 @@ import { SkillsEnum } from '../../lib/skilling/types';
import type { WoodcuttingActivityTaskOptions } from '../../lib/types/minions';
import { resolveItems, roll, skillingPetDropRate } from '../../lib/util';
import { handleTripFinish } from '../../lib/util/handleTripFinish';
import { rollForMoonKeyHalf } from '../../lib/util/minionUtils';
import { userStatsBankUpdate } from '../../mahoji/mahojiSettings';

async function handleForestry({ user, duration, loot }: { user: MUser; duration: number; loot: Bank }) {
Expand Down Expand Up @@ -334,6 +335,10 @@ export const woodcuttingTask: MinionTask = {
}
}

if ([EItem.MAGIC_LOGS, EItem.YEW_LOGS, EItem.TEAK_LOGS, EItem.MAPLE_LOGS].includes(log.id)) {
rollForMoonKeyHalf({ user, duration, loot });
}

// Loot received, items used, and logs/loot rolls lost message
str += `\nYou received ${loot}. `;
str += `${itemsToRemove.length > 0 ? `You used ${itemsToRemove}. ` : ''}`;
Expand Down

0 comments on commit 6bc66da

Please sign in to comment.