From 50f848f1dcf2bb70a998b391cd0da79a4d7fbf5b Mon Sep 17 00:00:00 2001 From: nwjgit Date: Sat, 1 Jun 2024 13:38:15 -0500 Subject: [PATCH] clean up messages --- .../abstracted_commands/wintertodtCommand.ts | 54 +++++++------------ .../minions/minigames/wintertodtActivity.ts | 13 +++-- 2 files changed, 29 insertions(+), 38 deletions(-) diff --git a/src/mahoji/lib/abstracted_commands/wintertodtCommand.ts b/src/mahoji/lib/abstracted_commands/wintertodtCommand.ts index b229c0c1d2..fac8812a6d 100644 --- a/src/mahoji/lib/abstracted_commands/wintertodtCommand.ts +++ b/src/mahoji/lib/abstracted_commands/wintertodtCommand.ts @@ -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); @@ -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) { @@ -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); @@ -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(', ') : '' + }.`; return str; } diff --git a/src/tasks/minions/minigames/wintertodtActivity.ts b/src/tasks/minions/minigames/wintertodtActivity.ts index ed43f6ac0c..ef13f112d7 100644 --- a/src/tasks/minions/minigames/wintertodtActivity.ts +++ b/src/tasks/minions/minigames/wintertodtActivity.ts @@ -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(); @@ -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); } @@ -114,7 +115,7 @@ 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, @@ -122,7 +123,11 @@ export const wintertodtTask: MinionTask = { 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()}`; @@ -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); } };