feat: some type prefixes

This commit is contained in:
TrèsAbhi committed 2025-10-13 23:15:32 -05:00
1 parent dc60cffdff
commit 0d8cb5c1ae
31 files changed
+225 -222

No files matched your search

@@ -1,7 +1,7 @@
import {
Armor,
AssaultRanges,
BlitzTankClass,
type BlitzTankClass,
CamouflageDefinitions,
Consumable,
ConsumableDefinitions,
@@ -35,15 +35,15 @@ import locales from "@blitzkit/i18n/locales.json";
import { readdir } from "fs/promises";
import { deburr } from "lodash-es";
import { parse as parsePath } from "path";
import { Vector3Tuple } from "three";
import type { Vector3Tuple } from "three";
import { parse as parseYaml } from "yaml";
import { readStringDVPL } from "../core/blitz/readStringDVPL";
import { readXMLDVPL } from "../core/blitz/readXMLDVPL";
import { readYAMLDVPL } from "../core/blitz/readYAMLDVPL";
import { commitAssets } from "../core/github/commitAssets";
import { DATA } from "./constants";
import { Avatar } from "./skillIcons";
import { TankParameters } from "./tankIcons";
import type { Avatar } from "./skillIcons";
import type { TankParameters } from "./tankIcons";
const nonAlphanumericRegex = /[^a-z0-9]/g;
const multipleDashesRegex = /--+/g;
+14 -14
View File
@@ -1,10 +1,10 @@
import { TankClass } from '@blitzkit/core';
import sharp from 'sharp';
import { readDVPLFile } from '../core/blitz/readDVPLFile';
import { readXMLDVPL } from '../core/blitz/readXMLDVPL';
import { commitAssets } from '../core/github/commitAssets';
import { FileChange } from '../core/github/commitMultipleFiles';
import { DATA } from './constants';
import { TankClass } from "@blitzkit/core";
import sharp from "sharp";
import { readDVPLFile } from "../core/blitz/readDVPLFile";
import { readXMLDVPL } from "../core/blitz/readXMLDVPL";
import { commitAssets } from "../core/github/commitAssets";
import type { FileChange } from "../core/github/commitMultipleFiles";
import { DATA } from "./constants";
interface SkillIcon {
name: string;
@@ -20,22 +20,22 @@ export interface Avatar {
effectDescription: string;
tipDescription: string;
icon: SkillIcon | SkillIcon[];
type: 'continuous' | 'trigger';
type: "continuous" | "trigger";
};
};
}
export async function skillIcons() {
console.log('Building skill icons...');
console.log("Building skill icons...");
const avatar = await readXMLDVPL<{ root: Avatar }>(
`${DATA}/XML/item_defs/tankmen/avatar.xml`,
`${DATA}/XML/item_defs/tankmen/avatar.xml`
);
const changes = await Promise.all(
Object.values(avatar.root.skills).map(async (skill) => {
const icon = Array.isArray(skill.icon) ? skill.icon[0] : skill.icon;
const name = icon.name.split('/').at(-1)!.replace(/_\d$/, '');
const path = `${DATA}${icon.name.replace('~res:', '')}.packed.webp`;
const name = icon.name.split("/").at(-1)!.replace(/_\d$/, "");
const path = `${DATA}${icon.name.replace("~res:", "")}.packed.webp`;
const image = sharp(await readDVPLFile(path)).trim();
const content = await image.toBuffer();
@@ -43,8 +43,8 @@ export async function skillIcons() {
content,
path: `icons/skills/${name}.webp`,
} satisfies FileChange;
}),
})
);
commitAssets('skill icons', changes);
commitAssets("skill icons", changes);
}
+23 -23
View File
@@ -1,14 +1,14 @@
import { NATION_IDS } from '@blitzkit/core';
import { readdir } from 'fs/promises';
import sharp from 'sharp';
import { Vector3Tuple } from 'three';
import { readDVPLFile } from '../core/blitz/readDVPLFile';
import { readXMLDVPL } from '../core/blitz/readXMLDVPL';
import { readYAMLDVPL } from '../core/blitz/readYAMLDVPL';
import { commitAssets } from '../core/github/commitAssets';
import { FileChange } from '../core/github/commitMultipleFiles';
import { DATA } from './constants';
import { VehicleDefinitionList } from './definitions';
import { NATION_IDS } from "@blitzkit/core";
import { readdir } from "fs/promises";
import sharp from "sharp";
import type { Vector3Tuple } from "three";
import { readDVPLFile } from "../core/blitz/readDVPLFile";
import { readXMLDVPL } from "../core/blitz/readXMLDVPL";
import { readYAMLDVPL } from "../core/blitz/readYAMLDVPL";
import { commitAssets } from "../core/github/commitAssets";
import type { FileChange } from "../core/github/commitMultipleFiles";
import { DATA } from "./constants";
import type { VehicleDefinitionList } from "./definitions";
export interface TankParameters {
resourcesPath: {
@@ -43,35 +43,35 @@ export interface TankParameters {
}
export async function tankIcons() {
console.log('Building tank icons...');
console.log("Building tank icons...");
const changes: FileChange[] = [];
const nations = await readdir(`${DATA}/XML/item_defs/vehicles`).then(
(nations) => nations.filter((nation) => nation !== 'common'),
(nations) => nations.filter((nation) => nation !== "common")
);
await Promise.all(
nations.map(async (nation) => {
const tanks = await readXMLDVPL<{ root: VehicleDefinitionList }>(
`${DATA}/XML/item_defs/vehicles/${nation}/list.xml`,
`${DATA}/XML/item_defs/vehicles/${nation}/list.xml`
);
await Promise.all(
Object.entries(tanks.root).map(async ([tankKey, tank]) => {
if (tankKey.includes('tutorial_bot')) return;
if (tankKey.includes("tutorial_bot")) return;
const nationVehicleId = tank.id;
const id = (nationVehicleId << 8) + (NATION_IDS[nation] << 4) + 1;
const parameters = await readYAMLDVPL<TankParameters>(
`${DATA}/3d/Tanks/Parameters/${nation}/${tankKey}.yaml`,
`${DATA}/3d/Tanks/Parameters/${nation}/${tankKey}.yaml`
);
const smallPath = `${DATA}/${parameters.resourcesPath.smallIconPath
.replace(/~res:\//, '')
.replace(/\..+/, '')}.packed.webp`;
.replace(/~res:\//, "")
.replace(/\..+/, "")}.packed.webp`;
const bigPath = `${DATA}/${parameters.resourcesPath.bigIconPath
.replace(/~res:\//, '')
.replace(/\..+/, '')}.packed.webp`;
.replace(/~res:\//, "")
.replace(/\..+/, "")}.packed.webp`;
const big = await sharp(await readDVPLFile(bigPath))
.trim()
.toBuffer();
@@ -91,10 +91,10 @@ export async function tankIcons() {
path: `icons/tanks/small/${id}.webp`,
});
}
}),
})
);
}),
})
);
await commitAssets('tank icons', changes);
await commitAssets("tank icons", changes);
}