feat: descs

This commit is contained in:
TrèsAbhi committed 2024-05-03 12:02:56 -05:00
1 parent d3e3d6d7b6
commit 468308ad22
2 files changed
+9

No files matched your search

+8
View File
@@ -3,6 +3,7 @@ import { parse as parsePath } from 'path';
import { Vector3Tuple } from 'three'; import { Vector3Tuple } from 'three';
import { parse as parseYaml } from 'yaml'; import { parse as parseYaml } from 'yaml';
import { TankClass } from '../../src/components/Tanks'; import { TankClass } from '../../src/components/Tanks';
import { WARGAMING_APPLICATION_ID } from '../../src/constants/wargamingApplicationID';
import { readStringDVPL } from '../../src/core/blitz/readStringDVPL'; import { readStringDVPL } from '../../src/core/blitz/readStringDVPL';
import { readXMLDVPL } from '../../src/core/blitz/readXMLDVPL'; import { readXMLDVPL } from '../../src/core/blitz/readXMLDVPL';
import { readYAMLDVPL } from '../../src/core/blitz/readYAMLDVPL'; import { readYAMLDVPL } from '../../src/core/blitz/readYAMLDVPL';
@@ -365,6 +366,11 @@ export const botPattern = /^.+((tutorial_bot(\d+)?)|(TU(R?)))$/;
export async function definitions(production: boolean) { export async function definitions(production: boolean) {
console.log('Building definitions...'); console.log('Building definitions...');
const wargamingTankopedia = (await fetch(
`https://api.wotblitz.com/wotb/encyclopedia/vehicles/?application_id=${WARGAMING_APPLICATION_ID}&fields=description`,
).then((response) => response.json())) as {
data: { [key: number]: { description: null | string } };
};
const gameDefinitions: GameDefinitions = { const gameDefinitions: GameDefinitions = {
version: (await readStringDVPL(`${DATA}/version.txt.dvpl`)) version: (await readStringDVPL(`${DATA}/version.txt.dvpl`))
.split(' ')[0] .split(' ')[0]
@@ -535,6 +541,8 @@ export async function definitions(production: boolean) {
tankDefinitions[tankId] = { tankDefinitions[tankId] = {
id: tankId, id: tankId,
description:
wargamingTankopedia.data[tank.id]?.description ?? undefined,
fixedCamouflage: fixedCamouflage ? true : undefined, fixedCamouflage: fixedCamouflage ? true : undefined,
crew, crew,
weight: tankDefinition.root.hull.weight, weight: tankDefinition.root.hull.weight,
@@ -21,6 +21,7 @@ export interface Crew {
} }
export interface TankDefinition { export interface TankDefinition {
id: number; id: number;
description?: string;
fixedCamouflage?: boolean; fixedCamouflage?: boolean;
ancestors?: number[]; ancestors?: number[];
successors?: number[]; successors?: number[];