Skip to content

Commit

Permalink
Update mine.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
TastyPumPum committed May 13, 2024
1 parent 239bd14 commit 4177ead
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/mahoji/commands/mine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { miningCapeOreEffect, miningGloves, pickaxes, varrockArmours } from '../
import { sinsOfTheFatherSkillRequirements } from '../../lib/skilling/functions/questRequirements';
import Mining from '../../lib/skilling/skills/mining';
import { MiningActivityTaskOptions } from '../../lib/types/minions';
import { formatDuration, formatSkillRequirements, itemNameFromID, randomVariation } from '../../lib/util';
import { formatDuration, formatSkillRequirements, itemID, itemNameFromID, randomVariation } from '../../lib/util';
import addSubTaskToActivityTask from '../../lib/util/addSubTaskToActivityTask';
import { calcMaxTripLength } from '../../lib/util/calcMaxTripLength';
import { minionName } from '../../lib/util/minionUtils';
Expand All @@ -25,7 +25,8 @@ export function calculateMiningInput({
miningLevel,
craftingLevel,
strengthLevel,
maxTripLength
maxTripLength,
user
}: {
nameInput: string;
quantityInput: number | undefined;
Expand All @@ -37,6 +38,7 @@ export function calculateMiningInput({
craftingLevel: number;
strengthLevel: number;
maxTripLength: number;
user: MUser;
}) {
const ore = Mining.Ores.find(
ore =>
Expand Down Expand Up @@ -105,9 +107,9 @@ export function calculateMiningInput({
let glovesRate = 0;
if (miningLevel >= 60) {
for (const glove of miningGloves) {
if (!gearValues.some(g => g.hasEquipped(glove.id)) || !glove.Percentages.has(ore.id)) continue;
glovesRate = glove.Percentages.amount(ore.id);
if (glovesRate !== 0) {
if (!user.hasEquipped(glove.id) || !glove.Percentages[ore.name]) continue;
glovesRate = glove.Percentages[ore.name];
if (glovesRate) {
messages.push(`Lowered rock depletion rate by **${glovesRate}%** for ${itemNameFromID(glove.id)}`);
break;
}
Expand All @@ -116,9 +118,9 @@ export function calculateMiningInput({

let armourEffect = 0;
for (const armour of varrockArmours) {
if (!gearValues.some(g => g.hasEquipped(armour.id)) || !armour.Percentages.has(ore.id)) continue;
armourEffect = armour.Percentages.amount(ore.id);
if (armourEffect !== 0) {
if (!user.hasEquippedOrInBank(armour.id) || !armour.Percentages[ore.name]) continue;
armourEffect = armour.Percentages[ore.name];
if (armourEffect) {
messages.push(`**${armourEffect}%** chance to mine an extra ore using ${itemNameFromID(armour.id)}`);
break;
}
Expand All @@ -131,9 +133,9 @@ export function calculateMiningInput({
}

let miningCapeEffect = 0;
if (gearValues.some(g => g.hasEquipped('Mining cape')) && miningCapeOreEffect.has(ore.id)) {
miningCapeEffect = miningCapeOreEffect.amount(ore.id);
if (miningCapeEffect !== 0) {
if (user.hasEquippedOrInBank([itemID('Mining cape')]) && miningCapeOreEffect[ore.name]) {
miningCapeEffect = miningCapeOreEffect[ore.name];
if (miningCapeEffect) {
messages.push(`**${miningCapeEffect}%** chance to mine an extra ore using Mining cape`);
}
}
Expand Down Expand Up @@ -250,7 +252,8 @@ export const mineCommand: OSBMahojiCommand = {
miningLevel: user.skillLevel('mining'),
craftingLevel: user.skillLevel('crafting'),
strengthLevel: user.skillLevel('strength'),
maxTripLength: calcMaxTripLength(user, 'Mining')
maxTripLength: calcMaxTripLength(user, 'Mining'),
user
});

if (typeof result === 'string') {
Expand Down

0 comments on commit 4177ead

Please sign in to comment.