Skip to content

Commit

Permalink
fix item cost message
Browse files Browse the repository at this point in the history
  • Loading branch information
DayV-git committed Jan 16, 2025
1 parent f4605ed commit 6e99fd2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export function formatItemCosts(consumable: Consumable, timeToFinish: number) {
}

if (consumables.length > 1) {
return `(${formatList(str, 'or')})`;
return `${formatList(str, 'or')}`;
}

return str.join('');
Expand Down
23 changes: 8 additions & 15 deletions src/mahoji/mahojiSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import type { ItemBank } from '../lib/types';
import {
type JsonKeys,
anglerBoosts,
formatItemCosts,
formatItemReqs,
formatList,
hasSkillReqs,
itemNameFromID,
readableStatName,
Expand Down Expand Up @@ -326,24 +326,17 @@ export async function hasMonsterRequirements(user: MUser, monster: KillableMonst
const messages: string[] = [];
for (const group of items) {
if (group.optional) continue;
if (user.owns(group.itemCost)) {
if (user.owns(consumablesCost.itemCost.filter(i => group.itemCost.has(i)))) {
continue;
}
if (group.alternativeConsumables?.some(alt => user.owns(alt.itemCost))) {
if (
!group.alternativeConsumables?.some(alt =>
user.owns(consumablesCost.itemCost.filter(i => alt.itemCost.has(i)))
)
) {
continue;
}
messages.push(
`This monster requires: ${group.itemCost.items().map(i => i[0].name)}${
group.alternativeConsumables
? `, ${formatList(
group.alternativeConsumables
?.map(alt => alt.itemCost.items().map(i => i[0].name))
.flat(100),
'or'
)}`
: '.'
}`
);
messages.push(`This monster requires (per kill) ${formatItemCosts(group, timeToFinish)}.`);
}
return [false, `You don't have the items needed to kill this monster. ${messages.join(' ')}`];
}
Expand Down

0 comments on commit 6e99fd2

Please sign in to comment.