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

Fix Projectiles not checking similar weapons #5424

Merged
merged 1 commit into from
Oct 11, 2023
Merged
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
8 changes: 7 additions & 1 deletion src/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import { ClueTiers } from './clues/clueTiers';
import { badgesCache, BitField, projectiles, usernameCache } from './constants';
import { UserStatsDataNeededForCL } from './data/Collections';
import { getSimilarItems } from './data/similarItems';
import { DefenceGearStat, GearSetupType, GearSetupTypes, GearStat, OffenceGearStat } from './gear/types';
import type { Consumable } from './minions/types';
import { MUserClass } from './MUser';
Expand Down Expand Up @@ -142,7 +143,7 @@
}

export function getSupportGuild(): Guild | null {
if (!globalClient || Object.keys(globalClient).length === 0) return null;

Check warning on line 146 in src/lib/util.ts

View workflow job for this annotation

GitHub Actions / ESLint

[eslint] reported by reviewdog 🐶 Unexpected object value in conditional. The condition is always true. Raw Output: {"ruleId":"@typescript-eslint/strict-boolean-expressions","severity":1,"message":"Unexpected object value in conditional. The condition is always true.","line":146,"column":7,"nodeType":"Identifier","messageId":"conditionErrorObject","endLine":146,"endColumn":19}
const guild = globalClient.guilds.cache.get(SupportServer);
if (!guild) return null;
return guild;
Expand Down Expand Up @@ -319,7 +320,7 @@
}

export function validateBankAndThrow(bank: Bank) {
if (!bank || typeof bank !== 'object') {

Check warning on line 323 in src/lib/util.ts

View workflow job for this annotation

GitHub Actions / ESLint

[eslint] reported by reviewdog 🐶 Unexpected object value in conditional. The condition is always true. Raw Output: {"ruleId":"@typescript-eslint/strict-boolean-expressions","severity":1,"message":"Unexpected object value in conditional. The condition is always true.","line":323,"column":7,"nodeType":"Identifier","messageId":"conditionErrorObject","endLine":323,"endColumn":11}
throw new Error('Invalid bank object');
}
for (const [key, value] of Object.entries(bank.bank)) {
Expand Down Expand Up @@ -356,7 +357,7 @@
}

function normalizeMahojiResponse(one: Awaited<CommandResponse>): BaseMessageOptions {
if (!one) return {};

Check warning on line 360 in src/lib/util.ts

View workflow job for this annotation

GitHub Actions / ESLint

[eslint] reported by reviewdog 🐶 Unexpected value in conditional. A boolean expression is required. Raw Output: {"ruleId":"@typescript-eslint/strict-boolean-expressions","severity":1,"message":"Unexpected value in conditional. A boolean expression is required.","line":360,"column":7,"nodeType":"Identifier","messageId":"conditionErrorOther","endLine":360,"endColumn":10}
if (typeof one === 'string') return { content: one };
const response: BaseMessageOptions = {};
if (one.content) response.content = one.content;
Expand Down Expand Up @@ -515,7 +516,12 @@
const { ammo } = gear;
if (!ammo) return 'You have no ammo equipped.';

const projectileCategory = objectEntries(projectiles).find(i => i[1].weapons.includes(weapon.id));
const projectileCategory = objectEntries(projectiles).find(i =>
i[1].weapons
.map(w => getSimilarItems(w))
.flat()
.includes(weapon.id)
);
if (!projectileCategory) return 'You have an invalid range weapon.';
if (!projectileCategory[1].items.includes(ammo.item)) {
return `You have invalid ammo for your equipped weapon. For ${
Expand Down