mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
feat: legendary camo names in search
This commit is contained in:
1 parent
3058756346
commit
ea7d822420
5 files changed
+33
-24
No files matched your search
@@ -17,9 +17,9 @@ import { resolveReload } from '../../../../../core/blitzkit/resolveReload';
|
||||
import {
|
||||
TankDefinition,
|
||||
tankDefinitions,
|
||||
tankNames,
|
||||
tanksDefinitionsArray,
|
||||
} from '../../../../../core/blitzkit/tankDefinitions';
|
||||
import { tankNames } from '../../../../../core/blitzkit/tankDefinitions/tankNames';
|
||||
import { unionBoundingBox } from '../../../../../core/blitzkit/unionBoundingBox';
|
||||
import { useAdExempt } from '../../../../../hooks/useAdExempt';
|
||||
import * as TankFilters from '../../../../../stores/tankFilters';
|
||||
@@ -375,7 +375,7 @@ export const TankSearch = memo<TankSearchProps>(
|
||||
return sort.direction === 'ascending' ? sorted : sorted.reverse();
|
||||
} else {
|
||||
const searchedRaw = go(filters.search, awaitedTankNames, {
|
||||
keys: ['searchableName', 'searchableNameDeburr'],
|
||||
keys: ['searchableName', 'searchableNameDeburr', 'camouflages'],
|
||||
});
|
||||
const searchedTanks = searchedRaw.map(
|
||||
(result) => awaitedTankDefinitions[result.obj.id],
|
||||
|
||||
@@ -2,7 +2,8 @@ import { Locale } from 'discord.js';
|
||||
import { go } from 'fuzzysort';
|
||||
import markdownEscape from 'markdown-escape';
|
||||
import { UserError } from '../../hooks/userError';
|
||||
import { tankDefinitions, tankNames } from '../blitzkit/tankDefinitions';
|
||||
import { tankDefinitions } from '../blitzkit/tankDefinitions';
|
||||
import { tankNames } from '../blitzkit/tankDefinitions/tankNames';
|
||||
import { tankNamesTechTreeOnly } from '../discord/autocompleteTanks';
|
||||
import { translator } from '../localization/translator';
|
||||
|
||||
@@ -19,7 +20,7 @@ export default async function resolveTankId(
|
||||
`${tank}`,
|
||||
await (techTreeOnly ? tankNamesTechTreeOnly : tankNames),
|
||||
{
|
||||
keys: ['searchableName', 'searchableNameDeburr'],
|
||||
keys: ['searchableName', 'searchableNameDeburr', 'camouflages'],
|
||||
limit: 1,
|
||||
},
|
||||
);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { deburr } from 'lodash';
|
||||
import { Vector2Tuple } from 'three';
|
||||
import { TankClass, TreeType } from '../../../components/Tanks';
|
||||
import { asset } from '../asset';
|
||||
@@ -181,23 +180,6 @@ export const tanksDefinitionsArray = new Promise<TankDefinition[]>(
|
||||
resolve((await entries).map((entry) => entry)); // TODO: wtf?
|
||||
},
|
||||
);
|
||||
export const tankNames = tanksDefinitionsArray.then((tanks) =>
|
||||
Promise.all(
|
||||
tanks.map(async (tank, index) => {
|
||||
const { id } = (await tanksDefinitionsArray)[index];
|
||||
|
||||
return {
|
||||
id,
|
||||
name: tank.name,
|
||||
nameFull: tank.nameFull,
|
||||
searchableName: tank.nameFull ?? tank.name,
|
||||
searchableNameDeburr: deburr(tank.nameFull ?? tank.name),
|
||||
treeType: tank.treeType,
|
||||
};
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
export type Tier = (typeof TIERS)[number];
|
||||
|
||||
export const flags: Record<string, string> = {
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import { deburr } from 'lodash';
|
||||
import { tanksDefinitionsArray } from '.';
|
||||
import { camouflageDefinitions } from '../camouflageDefinitions';
|
||||
|
||||
export const tankNames = Promise.all([
|
||||
tanksDefinitionsArray,
|
||||
camouflageDefinitions,
|
||||
]).then(([tanks, camouflages]) =>
|
||||
Promise.all(
|
||||
tanks.map(async (tank, index) => {
|
||||
const { id } = (await tanksDefinitionsArray)[index];
|
||||
|
||||
return {
|
||||
id,
|
||||
name: tank.name,
|
||||
nameFull: tank.nameFull,
|
||||
searchableName: tank.nameFull ?? tank.name,
|
||||
searchableNameDeburr: deburr(tank.nameFull ?? tank.name),
|
||||
camouflages: tank.camouflages
|
||||
?.map((id) => camouflages[id].name)
|
||||
.join(' '),
|
||||
treeType: tank.treeType,
|
||||
};
|
||||
}),
|
||||
),
|
||||
);
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
CacheType,
|
||||
} from 'discord.js';
|
||||
import { go } from 'fuzzysort';
|
||||
import { tankNames } from '../blitzkit/tankDefinitions';
|
||||
import { tankNames } from '../blitzkit/tankDefinitions/tankNames';
|
||||
import {
|
||||
DISCORD_CHOICES_MAX_NAME_SIZE,
|
||||
OVERFLOW_SUFFIX,
|
||||
@@ -29,7 +29,7 @@ export default async function autocompleteTanks(
|
||||
focusedOption.value,
|
||||
await (techTreeOnly ? tankNamesTechTreeOnly : tankNames),
|
||||
{
|
||||
keys: ['searchableName', 'searchableNameDeburr'],
|
||||
keys: ['searchableName', 'searchableNameDeburr', 'camouflages'],
|
||||
limit: 10,
|
||||
},
|
||||
).map(async (item) => {
|
||||
|
||||
Reference in new issue
Block a user