feat: flags

This commit is contained in:
TrèsAbhi committed 2023-11-30 12:59:37 -06:00
1 parent f3144be382
commit bef362935a
3 files changed
+35 -17

No files matched your search

+7 -4
View File
@@ -1,5 +1,6 @@
import { Octokit } from '@octokit/rest'; import { Octokit } from '@octokit/rest';
import decompress from 'decompress'; import decompress from 'decompress';
import { writeFileSync } from 'fs';
import { cp, mkdir, readFile, readdir, rm, writeFile } from 'fs/promises'; import { cp, mkdir, readFile, readdir, rm, writeFile } from 'fs/promises';
import { load } from 'js-yaml'; import { load } from 'js-yaml';
import { argv, env } from 'process'; import { argv, env } from 'process';
@@ -56,6 +57,8 @@ const nations = await readdir(
`${TEMP}/${directoriesOfInterest.vehicleDefinitions}`, `${TEMP}/${directoriesOfInterest.vehicleDefinitions}`,
); );
writeFileSync('test.json', JSON.stringify(strings, null, 2));
Promise.all( Promise.all(
nations nations
.filter((nation) => nation !== 'common') .filter((nation) => nation !== 'common')
@@ -73,7 +76,7 @@ Promise.all(
const nationVehicleId = parseInt(list.root[vehicle].id._text); const nationVehicleId = parseInt(list.root[vehicle].id._text);
const id = (nationVehicleId << 8) + (NATION_IDS[nation] << 4) + 1; const id = (nationVehicleId << 8) + (NATION_IDS[nation] << 4) + 1;
const name = strings[vehicleData.userString._text]; const name = strings[vehicleData.userString._text];
const name_short = strings[vehicleData.shortUserString._text]; const name_short = strings[vehicleData.shortUserString?._text];
const isPremium = 'gold' in vehicleData.price; const isPremium = 'gold' in vehicleData.price;
const isCollector = vehicleData.sellPrice const isCollector = vehicleData.sellPrice
? 'gold' in vehicleData.sellPrice ? 'gold' in vehicleData.sellPrice
@@ -82,9 +85,9 @@ Promise.all(
const tags = vehicleData.tags._text.split(' '); const tags = vehicleData.tags._text.split(' ');
const type = tags[0]; const type = tags[0];
// if ((name ?? name_short) === undefined) { if ((name ?? name_short) === undefined) {
// console.log(vehicleData); console.log(vehicleData.userString._text);
// } }
tankIds.push(id); tankIds.push(id);
tankopedia[id] = { tankopedia[id] = {
+25 -10
View File
@@ -22,22 +22,37 @@ export default async function Page() {
}} }}
> >
<Flex justify="between" align="center"> <Flex justify="between" align="center">
<img <div
src={tankIcon(tank.id)}
style={{ style={{
backgroundColor: 'white', backgroundImage: 'url(https://i.imgur.com/biJPgpm.png)',
width: 256, // backgroundSize: 'cover',
height: 128, height: 105,
objectFit: 'contain', width: 153,
objectPosition: 'left center', position: 'relative',
}} }}
/> >
<img
src={tankIcon(tank.id)}
style={{
width: 256,
height: 128,
objectFit: 'contain',
objectPosition: 'left center',
}}
/>
<Flex direction="column" justify="center" align="end" gap="2"> <Text
<Text> style={{
position: 'absolute',
bottom: 8,
left: 8,
}}
>
{tank.name_short ?? tank.name ?? `Unknown tank ${tank.id}`} {tank.name_short ?? tank.name ?? `Unknown tank ${tank.id}`}
</Text> </Text>
</div>
<Flex direction="column" justify="center" align="end" gap="2">
<Flex justify="end" align="center" gap="1"> <Flex justify="end" align="center" gap="1">
{tank.tree_type !== 'tech-tree' && ( {tank.tree_type !== 'tech-tree' && (
<Badge <Badge
+3 -3
View File
@@ -30,9 +30,9 @@ export interface BlitzkriegTankopediaEntry {
export type BlitzkriegTankopedia = Record<number, BlitzkriegTankopediaEntry>; export type BlitzkriegTankopedia = Record<number, BlitzkriegTankopediaEntry>;
export const tankopedia = fetch(asset('tankopedia.json')).then( export const tankopedia = fetch(asset('tankopedia.json'), {
async (response) => response.json() as Promise<BlitzkriegTankopedia>, cache: 'no-store',
); }).then(async (response) => response.json() as Promise<BlitzkriegTankopedia>);
const entries = new Promise<BlitzkriegTankopediaEntry[]>(async (resolve) => { const entries = new Promise<BlitzkriegTankopediaEntry[]>(async (resolve) => {
resolve(Object.entries(await tankopedia).map(([, entry]) => entry)); resolve(Object.entries(await tankopedia).map(([, entry]) => entry));
}); });