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

Clean up BSO wintertodt messages #5905

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
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
54 changes: 20 additions & 34 deletions src/mahoji/lib/abstracted_commands/wintertodtCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,21 @@ export async function wintertodtCommand(user: MUser, channelID: string) {
return 'You need 50 Firemaking to have a chance at defeating the Wintertodt.';
}

const messages = [];

let durationPerTodt = Time.Minute * 7.3;

// Up to a 10% boost for 99 WC
const wcBoost = (wcLevel + 1) / 10;

const boosts: string[] = [];
const foodStr: string[] = [];

if (wcBoost > 1) {
messages.push(`**Boosts:** ${wcBoost.toFixed(2)}% for Woodcutting level\n`);
boosts.push(`**Boosts:** ${wcBoost.toFixed(2)}% for Woodcutting level`);
}

if (user.hasEquippedOrInBank('Dwarven greataxe')) {
durationPerTodt /= 2;
boosts.push('2x faster for Dwarven greataxe.');
}

durationPerTodt = reduceNumByPercent(durationPerTodt, wcBoost);
Expand All @@ -45,22 +51,6 @@ export async function wintertodtCommand(user: MUser, channelID: string) {
healAmountNeeded -= warmGearAmount * 15;
durationPerTodt = reduceNumByPercent(durationPerTodt, 5 * warmGearAmount);

const boosts: string[] = [];

if (user.hasEquippedOrInBank('Dwarven greataxe')) {
durationPerTodt /= 2;
boosts.push('2x faster for Dwarven greataxe.');
}

if (healAmountNeeded !== baseHealAmountNeeded) {
messages.push(
`${calcWhatPercent(
baseHealAmountNeeded - healAmountNeeded,
baseHealAmountNeeded
)}% less food for wearing warm gear`
);
}

const quantity = Math.floor(calcMaxTripLength(user, 'Wintertodt') / durationPerTodt);

for (const food of Eatables) {
Expand All @@ -75,20 +65,18 @@ export async function wintertodtCommand(user: MUser, channelID: string) {
continue;
}

let foodStr: string = `**Food:** ${healAmountNeeded} HP/kill`;
foodStr.push(`**Food:** ${healAmountNeeded} HP/kill`);

if (healAmountNeeded !== baseHealAmountNeeded) {
foodStr += `. Reduced from ${baseHealAmountNeeded}, -${calcWhatPercent(
baseHealAmountNeeded - healAmountNeeded,
baseHealAmountNeeded
)}% for wearing warm gear. `;
} else {
foodStr += '. ';
foodStr.push(
`Reduced from ${baseHealAmountNeeded}, -${calcWhatPercent(
baseHealAmountNeeded - healAmountNeeded,
baseHealAmountNeeded
)}% for wearing warm gear`
);
}

foodStr += ` **Removed ${amountNeeded}x ${food.name}**`;

messages.push(foodStr);
foodStr.push(`**Removed ${amountNeeded}x ${food.name}**`);

const cost = new Bank().add(food.id, amountNeeded);

Expand Down Expand Up @@ -129,11 +117,9 @@ export async function wintertodtCommand(user: MUser, channelID: string) {
user.minionName
} is now off to kill Wintertodt ${quantity}x times, their trip will take ${formatDuration(
durationPerTodt * quantity
)}. (${formatDuration(durationPerTodt)} per todt)\n\n${messages.join(', ')}.`;

if (boosts.length > 0) {
str += `**Boosts:** ${boosts.join(', ')}`;
}
)}. (${formatDuration(durationPerTodt)} per todt)\n\n${boosts.length > 0 ? `${boosts.join(', ')}\n` : ''}${
foodStr.length > 0 ? foodStr.join(', ') : ''
}.`;
nwjgit marked this conversation as resolved.
Show resolved Hide resolved

return str;
}
13 changes: 9 additions & 4 deletions src/tasks/minions/minigames/wintertodtActivity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const wintertodtTask: MinionTask = {
async run(data: ActivityTaskOptionsWithQuantity) {
const { userID, channelID, quantity, duration } = data;
const user = await mUserFetch(userID);
const hasMasterCape = user.hasEquippedOrInBank('Firemaking master cape');

let loot = new Bank();

Expand Down Expand Up @@ -105,7 +106,7 @@ export const wintertodtTask: MinionTask = {
if (flappyRes.shouldGiveBoost) {
loot.multiply(2);
}
if (user.hasEquippedOrInBank('Firemaking master cape')) {
if (hasMasterCape) {
loot.multiply(2);
}

Expand All @@ -114,15 +115,19 @@ export const wintertodtTask: MinionTask = {
collectionLog: true,
itemsToAdd: loot
});
incrementMinigameScore(user.id, 'wintertodt', quantity);
await incrementMinigameScore(user.id, 'wintertodt', quantity);

const image = await makeBankImage({
bank: itemsAdded,
user,
previousCL
});

let output = `${user}, ${user.minionName} finished subduing Wintertodt ${quantity}x times. ${xpStr}, you cut ${numberOfRoots}x Bruma roots.`;
let output = `${user}, ${
user.minionName
} finished subduing Wintertodt ${quantity}x times. ${xpStr}, you cut ${numberOfRoots}x Bruma roots${
hasMasterCape ? ', 2x loot for Firemaking master cape.' : '.'
}`;

if (fmBonusXP > 0) {
output += `\n\n**Firemaking Bonus XP:** ${fmBonusXP.toLocaleString()}`;
Expand All @@ -149,6 +154,6 @@ export const wintertodtTask: MinionTask = {
]
});

handleTripFinish(user, channelID, output, image.file.attachment, data, itemsAdded);
return handleTripFinish(user, channelID, output, image.file.attachment, data, itemsAdded);
}
};
Loading