feat: equalizer parsing

This commit is contained in:
TrèsAbhi committed 2026-04-03 11:47:58 -05:00
1 parent e36823c159
commit 6835004945
5 files changed
+48 -4

No files matched your search

@@ -40,7 +40,7 @@ message TankDefinition {
required string equipment_preset = 30; required string equipment_preset = 30;
required uint32 weight = 31; required uint32 weight = 31;
required string dev_name = 32; required string dev_name = 32;
required Equalizer equalizer = 33; optional Equalizer equalizer = 33;
} }
message Equalizer { message Equalizer {
+1 -1
View File
@@ -291,7 +291,7 @@ export interface TankDefinition {
equipment_preset: string; equipment_preset: string;
weight: number; weight: number;
dev_name: string; dev_name: string;
equalizer: Equalizer | undefined; equalizer?: Equalizer | undefined;
} }
export interface TankDefinition_RolesEntry { export interface TankDefinition_RolesEntry {
@@ -8,6 +8,7 @@ import {
ConsumableTankCategoryFilterCategory, ConsumableTankCategoryFilterCategory,
Crew, Crew,
CrewType, CrewType,
Equalizer,
EquipmentDefinitions, EquipmentDefinitions,
EquipmentSlot, EquipmentSlot,
GameDefinitions, GameDefinitions,
@@ -32,6 +33,7 @@ import {
} from "@blitzkit/core"; } from "@blitzkit/core";
import { SUPPORTED_LOCALE_BLITZ_MAP } from "@blitzkit/i18n"; import { SUPPORTED_LOCALE_BLITZ_MAP } from "@blitzkit/i18n";
import locales from "@blitzkit/i18n/locales.json"; import locales from "@blitzkit/i18n/locales.json";
import { readFile } from "fs/promises";
import { deburr } from "lodash-es"; import { deburr } from "lodash-es";
import { parse as parsePath } from "path"; import { parse as parsePath } from "path";
import type { Vector3Tuple } from "three"; import type { Vector3Tuple } from "three";
@@ -688,6 +690,24 @@ export async function definitions() {
); );
const consumableNativeNames: Record<string, number> = {}; const consumableNativeNames: Record<string, number> = {};
const provisionNativeNames: Record<string, number> = {}; const provisionNativeNames: Record<string, number> = {};
let equalizerDefinitions: string[][];
if (
await vfs.resolve("Data/XML/item_defs/vehicles/common/tier_equializer.csv")
) {
equalizerDefinitions = await vfs.csv(
`Data/XML/item_defs/vehicles/common/tier_equializer.csv`,
{ delimiter: ";" },
);
} else {
const stubEqualizerDefinitions = await readFile("stub/equalizer.csv").then(
(buffer) => buffer.toString(),
);
equalizerDefinitions = await vfs._csv(stubEqualizerDefinitions, {
delimiter: ";",
});
}
for (const match of squadBattleTypeStyles.Prototypes[0].components.UIDataLocalBindingsComponent.data[1][2].matchAll( for (const match of squadBattleTypeStyles.Prototypes[0].components.UIDataLocalBindingsComponent.data[1][2].matchAll(
/"(\d+)" -> "(battleType\/([a-zA-Z]+))"/g, /"(\d+)" -> "(battleType\/([a-zA-Z]+))"/g,
@@ -998,6 +1018,18 @@ export async function definitions() {
}) })
.map(([, camo]) => camo.id); .map(([, camo]) => camo.id);
let equalizerEntry = equalizerDefinitions.find(
(line) => line[0] === `${nation}:${tankKey}`,
);
let equalizer: Equalizer | undefined;
if (equalizerEntry) {
const [health, penetration, module_health, damage, armor] =
equalizerEntry?.slice(1).map(Number);
equalizer = { health, penetration, module_health, damage, armor };
}
tankDefinitions.tanks[tankId] = { tankDefinitions.tanks[tankId] = {
ancestors: [], ancestors: [],
successors: [], successors: [],
@@ -1037,6 +1069,7 @@ export async function definitions() {
turrets: [], turrets: [],
engines: [], engines: [],
tracks: [], tracks: [],
equalizer,
}; };
if (tank.combatRole) { if (tank.combatRole) {
+13 -2
View File
@@ -1,7 +1,8 @@
import { readDVPL } from "@blitzkit/core"; import { readDVPL } from "@blitzkit/core";
import { Options, parse as parseCSV } from "csv-parse/sync";
import { XMLParser } from "fast-xml-parser"; import { XMLParser } from "fast-xml-parser";
import { normalize } from "path/posix"; import { normalize } from "path/posix";
import { parse } from "yaml"; import { parse as parseYaml } from "yaml";
export abstract class AbstractVFS { export abstract class AbstractVFS {
textDecoder = new TextDecoder(); textDecoder = new TextDecoder();
@@ -54,7 +55,7 @@ export abstract class AbstractVFS {
async yaml<Type>(path: string) { async yaml<Type>(path: string) {
const file = await this.text(path); const file = await this.text(path);
return parse(file) as Type; return parseYaml(file) as Type;
} }
async xml<Type>(path: string) { async xml<Type>(path: string) {
@@ -62,6 +63,16 @@ export abstract class AbstractVFS {
return this.xmlParser.parse(file) as Type; return this.xmlParser.parse(file) as Type;
} }
async _csv(text: string, options: Options = {}) {
const parsed = parseCSV(text, options);
return parsed;
}
async csv(path: string, options: Options = {}) {
const text = await this.text(path);
return await this._csv(text, options);
}
[Symbol.dispose]() { [Symbol.dispose]() {
this.dispose(); this.dispose();
} }
File renamed without changes.
Internal Server Error - DAVA Labs Underground
500 Internal Server Error

An error occurred:

An error occurred

Gitea Version: 28.2.0