mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-08-08 06:22:31 -05:00
* Initial * wip * AnyWeapon * del * wip * import stuff * gearselect * brand images * wip * wip * art * Remove old * Fix tournament map pool link * Simplify GearSelect * convert to todo
38 lines
975 B
TypeScript
38 lines
975 B
TypeScript
import type { AnyWeapon } from "~/features/build-analyzer";
|
|
import {
|
|
allWeaponAltNames,
|
|
weaponAltNames,
|
|
} from "~/modules/in-game-lists/weapon-alt-names";
|
|
import { abilities } from "./abilities";
|
|
import type { Ability } from "./types";
|
|
|
|
export function isAbility(value: string): value is Ability {
|
|
return Boolean(abilities.some((a) => a.name === value));
|
|
}
|
|
|
|
const normalizeTerm = (term: string): string => {
|
|
return term.trim().toLocaleLowerCase();
|
|
};
|
|
|
|
export function filterWeapon({
|
|
weapon,
|
|
weaponName,
|
|
searchTerm,
|
|
}: {
|
|
weapon: AnyWeapon;
|
|
weaponName: string;
|
|
searchTerm: string;
|
|
}): boolean {
|
|
const normalizedSearchTerm = normalizeTerm(searchTerm);
|
|
const normalizedWeaponName = normalizeTerm(weaponName);
|
|
|
|
const isAlt = allWeaponAltNames.has(normalizedSearchTerm);
|
|
if (weapon.type === "MAIN" && isAlt) {
|
|
return (
|
|
weaponAltNames.get(weapon.id)?.includes(normalizedSearchTerm) ?? false
|
|
);
|
|
}
|
|
|
|
return normalizedWeaponName.includes(normalizedSearchTerm);
|
|
}
|