diff --git a/scripts/buildTankopedia.ts b/scripts/buildTankopedia.ts index de83e9638..56dc51b30 100644 --- a/scripts/buildTankopedia.ts +++ b/scripts/buildTankopedia.ts @@ -166,30 +166,42 @@ Promise.all( // }), // ) // ).flat() as FileChange[]; - const flagChanges = await readdir( - `${TEMP}/${directoriesOfInterest.flags}`, - ).then((flags) => - Promise.all( - flags - .filter((flag) => flag.startsWith('flag_tutor-tank_')) - .map(async (flag) => { - const content = await readFile( - `${TEMP}/${directoriesOfInterest.flags}/${flag}`, - { encoding: 'base64' }, - ); - const name = flag.match(/flag_tutor-tank_(.+)\.packed\.webp/)![1]; + const flags = await readdir(`${TEMP}/${directoriesOfInterest.flags}`); + // const scratchedFlags = await Promise.all( + // flags + // .filter((flag) => flag.startsWith('flag_tutor-tank_')) + // .map(async (flag) => { + // const content = await readFile( + // `${TEMP}/${directoriesOfInterest.flags}/${flag}`, + // { encoding: 'base64' }, + // ); + // const name = flag.match(/flag_tutor-tank_(.+)\.packed\.webp/)![1]; - return { - content, - encoding: 'base64', - path: `flags/scratched/${name}.webp`, - } satisfies FileChange; - }), - ), + // return { + // content, + // encoding: 'base64', + // path: `flags/scratched/${name}.webp`, + // } satisfies FileChange; + // }), + // ); + const circleFlags = await Promise.all( + flags + .filter((flag) => flag.startsWith('flag_profile-stat_')) + .map(async (flag) => { + const content = await readFile( + `${TEMP}/${directoriesOfInterest.flags}/${flag}`, + { encoding: 'base64' }, + ); + const name = flag.match(/flag_profile-stat_(.+)\.packed\.webp/)![1]; + + return { + content, + encoding: 'base64', + path: `flags/circle/${name}.webp`, + } satisfies FileChange; + }), ); - console.log(flagChanges); - console.log('Writing files...'); await commitMultipleFiles( octokit, @@ -197,7 +209,7 @@ Promise.all( 'blitzkrieg-assets', 'main', new Date().toString(), - flagChanges, + circleFlags, true, ); } else { diff --git a/src/app/tools/tankopedia/components/Options.tsx b/src/app/tools/tankopedia/components/Options.tsx index 8ae5df7a6..53e91a419 100644 --- a/src/app/tools/tankopedia/components/Options.tsx +++ b/src/app/tools/tankopedia/components/Options.tsx @@ -2,6 +2,7 @@ import { CaretDownIcon } from '@radix-ui/react-icons'; import { Button, DropdownMenu, Flex } from '@radix-ui/themes'; +import { use } from 'react'; import { TANK_TYPES, TREE_TYPES, @@ -9,7 +10,9 @@ import { TREE_TYPE_IMAGES, TreeTypeEnum, } from '../../../../components/Tanks'; +import { asset } from '../../../../core/blitzkrieg/asset'; import { + NATIONS, TIERS, TIER_ROMAN_NUMERALS, } from '../../../../core/blitzkrieg/tankopedia'; @@ -20,11 +23,12 @@ import mutateTankopedia, { } from '../../../../stores/tankopedia'; export function Options() { + const nations = use(NATIONS); const tankopediaState = useTankopedia(); return ( - + + ))} + + {TREE_TYPES.map((type, index) => ( ); } diff --git a/src/app/tools/tankopedia/page.tsx b/src/app/tools/tankopedia/page.tsx index 6c3c01a4f..93c882afe 100644 --- a/src/app/tools/tankopedia/page.tsx +++ b/src/app/tools/tankopedia/page.tsx @@ -41,7 +41,10 @@ export default function Page() { : tankopediaState.filters.types.includes(tank.type)) && (tankopediaState.filters.treeTypes.length === 0 ? true - : tankopediaState.filters.treeTypes.includes(tank.tree_type)), + : tankopediaState.filters.treeTypes.includes(tank.tree_type)) && + (tankopediaState.filters.nations.length === 0 + ? true + : tankopediaState.filters.nations.includes(tank.nation)), ) .sort((a, b) => { let diff = 0; @@ -81,7 +84,7 @@ export default function Page() { return ( Loading...}> - + @@ -108,14 +111,14 @@ export default function Page() { - - + + {searchedList diff --git a/src/core/blitzkrieg/tankopedia.ts b/src/core/blitzkrieg/tankopedia.ts index 26c625710..f60049af6 100644 --- a/src/core/blitzkrieg/tankopedia.ts +++ b/src/core/blitzkrieg/tankopedia.ts @@ -98,3 +98,13 @@ export const TIER_ROMAN_NUMERALS: Record = { 9: 'IX', 10: 'X', }; + +export const NATIONS = tanks.then((tanks) => { + const nationsObject: Record = {}; + + tanks.forEach(({ nation }) => { + nationsObject[nation] = true; + }); + + return Object.keys(nationsObject); +}); diff --git a/src/stores/tankopedia.ts b/src/stores/tankopedia.ts index 4a1ffe742..0dc2ccbeb 100644 --- a/src/stores/tankopedia.ts +++ b/src/stores/tankopedia.ts @@ -16,6 +16,7 @@ type Tankopedia = { tiers: Tier[]; types: TankType[]; treeTypes: TreeTypeString[]; + nations: string[]; }; }; @@ -31,6 +32,7 @@ export const useTankopedia = create()( tiers: [], types: [], treeTypes: [], + nations: [], }, }), { name: 'tankopedia' },