feat: correct flags

This commit is contained in:
TrèsAbhi committed 2023-12-04 10:13:14 -06:00
1 parent c51abc1c64
commit 3e952faad3
2 files changed
+37 -21

No files matched your search

+32 -12
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 { config } from 'dotenv';
import { writeFileSync } from 'fs'; 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';
@@ -8,6 +9,9 @@ import { ElementCompact, xml2js } from 'xml-js';
import { parse } from 'yaml'; import { parse } from 'yaml';
import { NATION_IDS } from '../src/constants/nations'; import { NATION_IDS } from '../src/constants/nations';
import { BlitzkriegTankopedia, Tier } from '../src/core/blitzkrieg/tankopedia'; import { BlitzkriegTankopedia, Tier } from '../src/core/blitzkrieg/tankopedia';
import commitMultipleFiles, { FileChange } from './commitMultipleFiles';
config();
const LANGUAGE = 'en'; const LANGUAGE = 'en';
const TEMP = 'temp/blitz'; const TEMP = 'temp/blitz';
@@ -86,7 +90,7 @@ Promise.all(
const type = tags[0]; const type = tags[0];
if ((name ?? name_short) === undefined) { if ((name ?? name_short) === undefined) {
console.log(vehicleData.userString._text); console.warn(`Missing name for ${vehicle}`);
} }
tankIds.push(id); tankIds.push(id);
@@ -165,21 +169,37 @@ Promise.all(
const flagChanges = await readdir( const flagChanges = await readdir(
`${TEMP}/${directoriesOfInterest.flags}`, `${TEMP}/${directoriesOfInterest.flags}`,
).then((flags) => ).then((flags) =>
flags.filter((flag) => flag.startsWith('flag_tutor-tank_')), 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/${name}.webp`,
} satisfies FileChange;
}),
),
); );
console.log(flagChanges); console.log(flagChanges);
// console.log('Writing files...'); console.log('Writing files...');
// await commitMultipleFiles( await commitMultipleFiles(
// octokit, octokit,
// 'tresabhi', 'tresabhi',
// 'blitzkrieg-assets', 'blitzkrieg-assets',
// 'main', 'main',
// new Date().toString(), new Date().toString(),
// [tankopediaChange, ...iconsChange], flagChanges,
// true, true,
// ); );
} else { } else {
writeFile( writeFile(
'dist/tankopedia/tankopedia.json', 'dist/tankopedia/tankopedia.json',
+5 -9
View File
@@ -10,6 +10,7 @@ import { Button, Card, Flex, Inset, Text, TextField } from '@radix-ui/themes';
import { go } from 'fuzzysort'; import { go } from 'fuzzysort';
import { Suspense, use, useEffect, useMemo, useRef, useState } from 'react'; import { Suspense, use, useEffect, useMemo, useRef, useState } from 'react';
import PageWrapper from '../../../components/PageWrapper'; import PageWrapper from '../../../components/PageWrapper';
import { asset } from '../../../core/blitzkrieg/asset';
import { tankIcon } from '../../../core/blitzkrieg/tankIcon'; import { tankIcon } from '../../../core/blitzkrieg/tankIcon';
import { import {
BlitzkriegTankopediaEntry, BlitzkriegTankopediaEntry,
@@ -23,12 +24,6 @@ import { useTankopedia } from '../../../stores/tankopedia';
import { Options } from './components/Options'; import { Options } from './components/Options';
import * as styles from './page.css'; import * as styles from './page.css';
const flags = [
'https://i.imgur.com/Iho9ATV.png',
'https://i.imgur.com/uKWdnOn.png',
'https://i.imgur.com/kf4GwjJ.png',
];
const TANKS_PER_PAGE = 30; const TANKS_PER_PAGE = 30;
export default function Page() { export default function Page() {
@@ -170,17 +165,18 @@ export default function Page() {
display: 'flex', display: 'flex',
}} }}
> >
{tank.nation !== 'other' && (
<img <img
className={styles.flag} className={styles.flag}
// pick a random flag src={asset(`flags/${tank.nation}.webp`)}
src={flags[Math.floor(Math.random() * flags.length)]}
style={{ style={{
width: '100%', width: '100%',
height: '100%', height: '100%',
objectFit: 'contain', objectFit: 'contain',
position: 'absolute', position: 'absolute',
}} }}
></img> />
)}
<div <div
style={{ style={{