mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 03:29:51 +02:00
Merge branch 'main' into ue
This commit is contained in:
commit
c0376182f8
164 files changed
+5145
-4079
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
AverageDefinitions,
|
||||
AverageDefinitionsAllStats,
|
||||
AverageDefinitionsEntry,
|
||||
type AverageDefinitionsManifest,
|
||||
type IndividualTankStats,
|
||||
@@ -30,9 +31,6 @@ type OptionalSecondLevel<T> = {
|
||||
};
|
||||
};
|
||||
|
||||
type AverageDefinitionsEntrySubPartial =
|
||||
OptionalSecondLevel<AverageDefinitionsEntry>;
|
||||
|
||||
const MINUTE = 60 * 1000;
|
||||
const HOUR = 60 * MINUTE;
|
||||
const DAY = 24 * HOUR;
|
||||
@@ -47,15 +45,15 @@ const preDiscoveredIds = await fetchPreDiscoveredIds();
|
||||
const playerIds: Record<Region, number[][]> = {
|
||||
asia: chunk(
|
||||
preDiscoveredIds.filter((id) => idToRegion(id) === "asia"),
|
||||
PLAYER_IDS_PER_CALL
|
||||
PLAYER_IDS_PER_CALL,
|
||||
),
|
||||
com: chunk(
|
||||
preDiscoveredIds.filter((id) => idToRegion(id) === "com"),
|
||||
PLAYER_IDS_PER_CALL
|
||||
PLAYER_IDS_PER_CALL,
|
||||
),
|
||||
eu: chunk(
|
||||
preDiscoveredIds.filter((id) => idToRegion(id) === "eu"),
|
||||
PLAYER_IDS_PER_CALL
|
||||
PLAYER_IDS_PER_CALL,
|
||||
),
|
||||
};
|
||||
let regionIndex = 0;
|
||||
@@ -71,7 +69,7 @@ times(THREADS, async () => {
|
||||
const regionIds = playerIds[region];
|
||||
const [ids] = regionIds.splice(
|
||||
Math.floor(Math.random() * regionIds.length),
|
||||
1
|
||||
1,
|
||||
);
|
||||
const accountInfo = await getAccountInfo(region, ids, undefined, {
|
||||
fields: "last_battle_time,statistics.all.battles",
|
||||
@@ -104,8 +102,8 @@ times(THREADS, async () => {
|
||||
filteredIds.map((id) =>
|
||||
getTankStats(region, id, {
|
||||
fields: "last_battle_time,battle_life_time,all,tank_id",
|
||||
})
|
||||
)
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
players.forEach((tanks) => {
|
||||
@@ -114,7 +112,7 @@ times(THREADS, async () => {
|
||||
|
||||
if (!tankIds.includes(tank.tank_id)) {
|
||||
console.log(
|
||||
`Found new tank: ${tank.tank_id} (${tankIds.length + 1})`
|
||||
`Found new tank: ${tank.tank_id} (${tankIds.length + 1})`,
|
||||
);
|
||||
tankIds.push(tank.tank_id);
|
||||
tanksSorted[tank.tank_id] = [];
|
||||
@@ -140,7 +138,7 @@ async function postWork() {
|
||||
console.log(
|
||||
`Generating statistics based on ${samples.d_120.toLocaleString()} players (${samples.total.toLocaleString()} checked in total) and ${
|
||||
tankIds.length
|
||||
} tanks...`
|
||||
} tanks...`,
|
||||
);
|
||||
|
||||
using uploader = new AssetUploader("averages");
|
||||
@@ -152,7 +150,12 @@ async function postWork() {
|
||||
// (tank) => Date.now() - tank.last_battle_time * 1000 <= MAX_ACTIVITY_TIME,
|
||||
// );
|
||||
const tanks = tanksSortedEntry;
|
||||
const entry: AverageDefinitionsEntrySubPartial = {
|
||||
const entry: {
|
||||
mu: Partial<Record<keyof AverageDefinitionsAllStats, number>>;
|
||||
sigma: Partial<Record<keyof AverageDefinitionsAllStats, number>>;
|
||||
r: Partial<Record<keyof AverageDefinitionsAllStats, number>>;
|
||||
samples: Samples;
|
||||
} = {
|
||||
mu: {},
|
||||
sigma: {},
|
||||
r: {},
|
||||
@@ -162,13 +165,13 @@ async function postWork() {
|
||||
tanks.forEach((tank) => {
|
||||
const timeSinceLastActivity = Date.now() - tank.last_battle_time * 1000;
|
||||
|
||||
entry.samples.total++;
|
||||
if (timeSinceLastActivity <= 120 * DAY) entry.samples.d_120++;
|
||||
if (timeSinceLastActivity <= 90 * DAY) entry.samples.d_90++;
|
||||
if (timeSinceLastActivity <= 60 * DAY) entry.samples.d_60++;
|
||||
if (timeSinceLastActivity <= 30 * DAY) entry.samples.d_30++;
|
||||
if (timeSinceLastActivity <= 7 * DAY) entry.samples.d_7++;
|
||||
if (timeSinceLastActivity <= 1 * DAY) entry.samples.d_1++;
|
||||
entry.samples!.total++;
|
||||
if (timeSinceLastActivity <= 120 * DAY) entry.samples!.d_120++;
|
||||
if (timeSinceLastActivity <= 90 * DAY) entry.samples!.d_90++;
|
||||
if (timeSinceLastActivity <= 60 * DAY) entry.samples!.d_60++;
|
||||
if (timeSinceLastActivity <= 30 * DAY) entry.samples!.d_30++;
|
||||
if (timeSinceLastActivity <= 7 * DAY) entry.samples!.d_7++;
|
||||
if (timeSinceLastActivity <= 1 * DAY) entry.samples!.d_1++;
|
||||
});
|
||||
|
||||
const dataWY = tanks.map((tank) => ({
|
||||
@@ -191,7 +194,7 @@ async function postWork() {
|
||||
function sum(slicer: (data: DataPoint) => number) {
|
||||
return data.reduce(
|
||||
(accumulator, data) => accumulator + slicer(data),
|
||||
0
|
||||
0,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,13 +6,15 @@ export async function boosterIcons() {
|
||||
console.log("Building booster icons...");
|
||||
|
||||
const uploader = new AssetUploader("booster icons");
|
||||
const boosterFiles = vfs
|
||||
const boosterFiles = await vfs
|
||||
.dir("Data/Gfx/Shared/boosters")
|
||||
.filter(
|
||||
(file) => !file.includes("@2x.txt") && !file.startsWith("texture0")
|
||||
.then((files) =>
|
||||
files.filter(
|
||||
(file) => !file.includes("@2x.txt") && !file.startsWith("texture0"),
|
||||
),
|
||||
);
|
||||
const image = sharp(
|
||||
await vfs.file(`Data/Gfx/Shared/boosters/texture0.packed.webp`)
|
||||
await vfs.file(`Data/Gfx/Shared/boosters/texture0.packed.webp`),
|
||||
);
|
||||
|
||||
for (const file of boosterFiles) {
|
||||
|
||||
@@ -6,7 +6,7 @@ export async function camouflageIcons() {
|
||||
|
||||
using uploader = new AssetUploader("camo icons");
|
||||
const content = await vfs.file(
|
||||
`Data/Gfx/UI/Hangar/IconCamouflage.packed.webp`
|
||||
`Data/Gfx/UI/Hangar/IconCamouflage.packed.webp`,
|
||||
);
|
||||
|
||||
await uploader.add({ content, path: "icons/camo.webp" });
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { assertSecret } from "@blitzkit/core";
|
||||
import { AbstractVFS } from "../core/vfs/abstract";
|
||||
import { LocalVFS } from "../core/vfs/local";
|
||||
import { SteamVFS } from "../core/vfs/steam";
|
||||
import { ZipVFS } from "../core/vfs/zip";
|
||||
|
||||
const steamPattern = /steam:(\d+)\/(\d+)/;
|
||||
const zipPattern = /zip:(.+)/;
|
||||
const localePattern = /local:"?(.+)"?/;
|
||||
|
||||
const source = Bun.argv
|
||||
.find((arg) => arg.startsWith("--source="))
|
||||
@@ -21,11 +23,14 @@ if (!source) {
|
||||
assertSecret(import.meta.env.STEAM_USERNAME),
|
||||
assertSecret(import.meta.env.STEAM_PASSWORD),
|
||||
app,
|
||||
depot
|
||||
depot,
|
||||
).init();
|
||||
} else if (zipPattern.test(source)) {
|
||||
const [, url] = source.match(zipPattern)!;
|
||||
resolved = await new ZipVFS(url).init();
|
||||
} else if (localePattern.test(source)) {
|
||||
const [, path] = source.match(localePattern)!;
|
||||
resolved = await new LocalVFS(path).init();
|
||||
} else {
|
||||
throw new Error("No valid source specified");
|
||||
}
|
||||
|
||||
@@ -18,26 +18,20 @@ export async function consumableProvisionIcons() {
|
||||
|
||||
using uploader = new AssetUploader("consumable and provision icons");
|
||||
const styles = [
|
||||
"UI/Styles/Lobby/Inventory/InventoryNormalStyles.yaml",
|
||||
"UI/Styles/Lobby/Inventory/Event/InventoryBigStyles.yaml",
|
||||
"UI/Styles/Lobby/Inventory/Event/InventoryNormalStyles.yaml",
|
||||
"UI/Styles/Lobby/Inventory/InventoryNormalStyles.yaml",
|
||||
"UI/Screens3/Lobby/Inventory/Equipment/EquipmentItemImage.style.yaml",
|
||||
"UI/Screens/Battle/Styles/BattleEquipmentStyles.yaml",
|
||||
];
|
||||
const styleSheets = await Promise.all(
|
||||
styles.map(async (path) =>
|
||||
Object.values(
|
||||
(
|
||||
await vfs.yaml<Mappings>(`Data/${path}`)
|
||||
).StyleSheets
|
||||
)
|
||||
)
|
||||
Object.values((await vfs.yaml<Mappings>(`Data/${path}`)).StyleSheets),
|
||||
),
|
||||
).then((array) => array.flat());
|
||||
|
||||
for (const match of (
|
||||
await vfs.text(
|
||||
`Data/XML/item_defs/vehicles/common/consumables/list.xml`
|
||||
)
|
||||
await vfs.text(`Data/XML/item_defs/vehicles/common/consumables/list.xml`)
|
||||
).matchAll(listItemsPattern)) {
|
||||
const consumablesCommon = await vfs.xml<{
|
||||
root: ConsumablesCommon;
|
||||
@@ -46,13 +40,13 @@ export async function consumableProvisionIcons() {
|
||||
for (const consumable of Object.values(consumablesCommon.root)) {
|
||||
const styleSheet = styleSheets.find((styleSheet) =>
|
||||
styleSheet.selectors.some((selector) =>
|
||||
selector.includes(`${consumable.icon} `)
|
||||
)
|
||||
selector.includes(`${consumable.icon} `),
|
||||
),
|
||||
);
|
||||
|
||||
if (!styleSheet) {
|
||||
console.warn(
|
||||
`No style sheet found for consumable ${consumable.icon}; skipping...`
|
||||
`No style sheet found for consumable ${consumable.icon}; skipping...`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
@@ -62,10 +56,8 @@ export async function consumableProvisionIcons() {
|
||||
.replace(".psd", "")
|
||||
.replace(".txt", "");
|
||||
|
||||
if (vfs.resolve(`Data/${configPath}.packed.webp`)) {
|
||||
const image = sharp(
|
||||
await vfs.file(`Data/${configPath}.packed.webp`)
|
||||
);
|
||||
if (await vfs.resolve(`Data/${configPath}.packed.webp`)) {
|
||||
const image = sharp(await vfs.file(`Data/${configPath}.packed.webp`));
|
||||
const content = await image.trim({ threshold: 100 }).toBuffer();
|
||||
|
||||
await uploader.add({
|
||||
@@ -78,8 +70,8 @@ export async function consumableProvisionIcons() {
|
||||
`${`Data/${configPath}`
|
||||
.split("/")
|
||||
.slice(0, -1)
|
||||
.join("/")}/texture0.packed.webp`
|
||||
)
|
||||
.join("/")}/texture0.packed.webp`,
|
||||
),
|
||||
);
|
||||
const sizes = (await vfs.text(`Data/${configPath}.txt`))
|
||||
.split("\n")[4]
|
||||
@@ -104,9 +96,7 @@ export async function consumableProvisionIcons() {
|
||||
}
|
||||
|
||||
for (const match of (
|
||||
await vfs.text(
|
||||
`Data/XML/item_defs/vehicles/common/provisions/list.xml`
|
||||
)
|
||||
await vfs.text(`Data/XML/item_defs/vehicles/common/provisions/list.xml`)
|
||||
).matchAll(listItemsPattern)) {
|
||||
const provisionsCommon = await vfs.xml<{
|
||||
root: ProvisionsCommon;
|
||||
@@ -115,13 +105,13 @@ export async function consumableProvisionIcons() {
|
||||
for (const provision of Object.values(provisionsCommon.root)) {
|
||||
const styleSheet = styleSheets.find((styleSheet) =>
|
||||
styleSheet.selectors.some((selector) =>
|
||||
selector.includes(`${provision.icon} `)
|
||||
)
|
||||
selector.includes(`${provision.icon} `),
|
||||
),
|
||||
);
|
||||
|
||||
if (!styleSheet) {
|
||||
console.warn(
|
||||
`No style sheet found for provision ${provision.icon}; skipping...`
|
||||
`No style sheet found for provision ${provision.icon}; skipping...`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
@@ -131,10 +121,8 @@ export async function consumableProvisionIcons() {
|
||||
.replace(".psd", "")
|
||||
.replace(".txt", "");
|
||||
|
||||
if (vfs.resolve(`Data/${configPath}.packed.webp`)) {
|
||||
const image = sharp(
|
||||
await vfs.file(`Data/${configPath}.packed.webp`)
|
||||
);
|
||||
if (await vfs.resolve(`Data/${configPath}.packed.webp`)) {
|
||||
const image = sharp(await vfs.file(`Data/${configPath}.packed.webp`));
|
||||
const content = await image.trim({ threshold: 100 }).toBuffer();
|
||||
|
||||
await uploader.add({
|
||||
@@ -147,8 +135,8 @@ export async function consumableProvisionIcons() {
|
||||
`${`Data/${configPath}`
|
||||
.split("/")
|
||||
.slice(0, -1)
|
||||
.join("/")}/texture0.packed.webp`
|
||||
)
|
||||
.join("/")}/texture0.packed.webp`,
|
||||
),
|
||||
);
|
||||
const sizes = (await vfs.text(`Data/${configPath}.txt`))
|
||||
.split("\n")[4]
|
||||
|
||||
@@ -20,7 +20,7 @@ export async function currencies() {
|
||||
|
||||
for (const [file, name] of ICONS) {
|
||||
const content = await sharp(
|
||||
await vfs.file(`Data/Gfx/Lobby/currency/${file}`)
|
||||
await vfs.file(`Data/Gfx/Lobby/currency/${file}`),
|
||||
)
|
||||
.trim()
|
||||
.toBuffer();
|
||||
@@ -36,14 +36,14 @@ export async function currencies() {
|
||||
.then((glossary) =>
|
||||
Object.values(glossary)
|
||||
.entries()
|
||||
.filter(([key]) => /^prx_season_\d+$/.test(`${key}`))
|
||||
.filter(([key]) => /^prx_season_\d+$/.test(`${key}`)),
|
||||
);
|
||||
|
||||
for (const [key, item] of glossary) {
|
||||
if (item.image_url === null) throw new Error(`No image_url for ${key}`);
|
||||
|
||||
const imageRaw = await fetch(item.image_url).then((response) =>
|
||||
response.arrayBuffer()
|
||||
response.arrayBuffer(),
|
||||
);
|
||||
const content = await sharp(imageRaw)
|
||||
.trim({
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
ConsumableTankCategoryFilterCategory,
|
||||
Crew,
|
||||
CrewType,
|
||||
Equalizer,
|
||||
EquipmentDefinitions,
|
||||
EquipmentSlot,
|
||||
GameDefinitions,
|
||||
@@ -32,6 +33,7 @@ import {
|
||||
} from "@blitzkit/core";
|
||||
import { SUPPORTED_LOCALE_BLITZ_MAP } from "@blitzkit/i18n";
|
||||
import locales from "@blitzkit/i18n/locales.json";
|
||||
import { readFile } from "fs/promises";
|
||||
import { deburr } from "lodash-es";
|
||||
import { parse as parsePath } from "path";
|
||||
import type { Vector3Tuple } from "three";
|
||||
@@ -81,16 +83,16 @@ const blitzTankFilterDefinitionCategoryToBlitzkit: Record<
|
||||
BlitzTankFilterDefinitionCategory,
|
||||
ConsumableTankCategoryFilterCategory
|
||||
> = {
|
||||
clip: ConsumableTankCategoryFilterCategory.CLIP,
|
||||
clip: ConsumableTankCategoryFilterCategory.CONSUMABLE_TANK_CATEGORY_FILTER_CATEGORY_CLIP,
|
||||
};
|
||||
function vector3TupleToBlitzkit(tuple: Vector3Tuple) {
|
||||
return { x: tuple[0], y: tuple[1], z: tuple[2] } satisfies Vector3;
|
||||
}
|
||||
const blitzTankClassToBlitzkit: Record<BlitzTankClass, TankClass> = {
|
||||
lightTank: TankClass.LIGHT,
|
||||
"AT-SPG": TankClass.TANK_DESTROYER,
|
||||
heavyTank: TankClass.HEAVY,
|
||||
mediumTank: TankClass.MEDIUM,
|
||||
lightTank: TankClass.TANK_CLASS_LIGHT,
|
||||
"AT-SPG": TankClass.TANK_CLASS_TANK_DESTROYER,
|
||||
heavyTank: TankClass.TANK_CLASS_HEAVY,
|
||||
mediumTank: TankClass.TANK_CLASS_MEDIUM,
|
||||
};
|
||||
export interface BlitzStrings {
|
||||
[key: string]: string;
|
||||
@@ -135,7 +137,7 @@ export interface ChassisDefinitionsList {
|
||||
}
|
||||
type VehicleDefinitionArmor = Record<
|
||||
string,
|
||||
number | { vehicleDamageFactor: 0; "#text": number }
|
||||
number | { vehicleDamageFactor: 0; "#text": number } | number[]
|
||||
>;
|
||||
interface UnlocksInner {
|
||||
cost: number | string;
|
||||
@@ -149,18 +151,18 @@ type BlitzModuleType = {
|
||||
type UnlocksListing = BlitzModuleType | undefined;
|
||||
type BlitzCrewType = "commander" | "radioman" | "gunner" | "driver" | "loader";
|
||||
const blitzCrewTypeToBlitzkit: Record<BlitzCrewType, CrewType> = {
|
||||
commander: CrewType.COMMANDER,
|
||||
driver: CrewType.DRIVER,
|
||||
gunner: CrewType.GUNNER,
|
||||
loader: CrewType.LOADER,
|
||||
radioman: CrewType.RADIOMAN,
|
||||
commander: CrewType.CREW_TYPE_COMMANDER,
|
||||
driver: CrewType.CREW_TYPE_DRIVER,
|
||||
gunner: CrewType.CREW_TYPE_GUNNER,
|
||||
loader: CrewType.CREW_TYPE_LOADER,
|
||||
radioman: CrewType.CREW_TYPE_RADIOMAN,
|
||||
};
|
||||
const blitzkitCrewTypeToBlitz: Record<CrewType, BlitzCrewType> = {
|
||||
[CrewType.COMMANDER]: "commander",
|
||||
[CrewType.DRIVER]: "driver",
|
||||
[CrewType.GUNNER]: "gunner",
|
||||
[CrewType.LOADER]: "loader",
|
||||
[CrewType.RADIOMAN]: "radioman",
|
||||
[CrewType.CREW_TYPE_COMMANDER]: "commander",
|
||||
[CrewType.CREW_TYPE_DRIVER]: "driver",
|
||||
[CrewType.CREW_TYPE_GUNNER]: "gunner",
|
||||
[CrewType.CREW_TYPE_LOADER]: "loader",
|
||||
[CrewType.CREW_TYPE_RADIOMAN]: "radioman",
|
||||
};
|
||||
interface VehicleDefinitions {
|
||||
invisibility: {
|
||||
@@ -298,7 +300,7 @@ interface VehicleDefinitions {
|
||||
type: "default";
|
||||
enabled: false;
|
||||
factorsModifiers: "";
|
||||
}
|
||||
},
|
||||
];
|
||||
};
|
||||
};
|
||||
@@ -517,20 +519,36 @@ type CombatRolesYaml = Record<
|
||||
>;
|
||||
|
||||
const blitzShellKindToBlitzkit: Record<ShellKind, ShellType> = {
|
||||
ARMOR_PIERCING: ShellType.AP,
|
||||
ARMOR_PIERCING_CR: ShellType.APCR,
|
||||
HIGH_EXPLOSIVE: ShellType.HE,
|
||||
HOLLOW_CHARGE: ShellType.HEAT,
|
||||
ARMOR_PIERCING: ShellType.SHELL_TYPE_AP,
|
||||
ARMOR_PIERCING_CR: ShellType.SHELL_TYPE_APCR,
|
||||
HIGH_EXPLOSIVE: ShellType.SHELL_TYPE_HE,
|
||||
HOLLOW_CHARGE: ShellType.SHELL_TYPE_HEAT,
|
||||
};
|
||||
export const botPattern = /^.+((tutorial_bot(\d+)?)|(TU))$/;
|
||||
const blitzModuleTypeToBlitzkit: Record<keyof BlitzModuleType, ModuleType> = {
|
||||
chassis: ModuleType.TRACKS,
|
||||
engine: ModuleType.ENGINE,
|
||||
gun: ModuleType.GUN,
|
||||
turret: ModuleType.TURRET,
|
||||
vehicle: ModuleType.VEHICLE,
|
||||
chassis: ModuleType.MODULE_TYPE_TRACKS,
|
||||
engine: ModuleType.MODULE_TYPE_ENGINE,
|
||||
gun: ModuleType.MODULE_TYPE_GUN,
|
||||
turret: ModuleType.MODULE_TYPE_TURRET,
|
||||
vehicle: ModuleType.MODULE_TYPE_VEHICLE,
|
||||
};
|
||||
|
||||
function assignArmor(
|
||||
raw: VehicleDefinitionArmor[string],
|
||||
id: number,
|
||||
armor: Armor,
|
||||
) {
|
||||
if (typeof raw === "number") {
|
||||
armor.thickness[id] = raw;
|
||||
} else if (Array.isArray(raw)) {
|
||||
armor.thickness[id] = raw.at(-1)!;
|
||||
} else {
|
||||
if (!armor.spaced) armor.spaced = [];
|
||||
armor.thickness[id] = raw["#text"];
|
||||
armor.spaced.push(id);
|
||||
}
|
||||
}
|
||||
|
||||
export async function definitions() {
|
||||
console.log("Building definitions...");
|
||||
|
||||
@@ -555,18 +573,18 @@ export async function definitions() {
|
||||
const provisionDefinitions: ProvisionDefinitions = { provisions: {} };
|
||||
const skillDefinitions: SkillDefinitions = {
|
||||
classes: {
|
||||
[TankClass.LIGHT]: { skills: [] },
|
||||
[TankClass.MEDIUM]: { skills: [] },
|
||||
[TankClass.HEAVY]: { skills: [] },
|
||||
[TankClass.TANK_DESTROYER]: { skills: [] },
|
||||
[TankClass.TANK_CLASS_LIGHT]: { skills: [] },
|
||||
[TankClass.TANK_CLASS_MEDIUM]: { skills: [] },
|
||||
[TankClass.TANK_CLASS_HEAVY]: { skills: [] },
|
||||
[TankClass.TANK_CLASS_TANK_DESTROYER]: { skills: [] },
|
||||
},
|
||||
};
|
||||
const nations = vfs
|
||||
const nations = await vfs
|
||||
.dir("Data/XML/item_defs/vehicles")
|
||||
.filter((nation) => nation !== "common");
|
||||
.then((files) => files.filter((nation) => nation !== "common"));
|
||||
const tankStringIdMap: Record<string, number> = {};
|
||||
const optionalDevices = await vfs.xml<{ root: OptionalDevices }>(
|
||||
"Data/XML/item_defs/vehicles/common/optional_devices.xml"
|
||||
"Data/XML/item_defs/vehicles/common/optional_devices.xml",
|
||||
);
|
||||
const stringsI18n: Record<string, Record<string, string>> = {};
|
||||
|
||||
@@ -574,12 +592,12 @@ export async function definitions() {
|
||||
locales.supported.map(async ({ locale }) => {
|
||||
const blitzLocale = SUPPORTED_LOCALE_BLITZ_MAP[locale];
|
||||
const cache = await fetch(
|
||||
`https://stufficons.wgcdn.co/localizations/${blitzLocale}.yaml`
|
||||
`https://stufficons.wgcdn.co/localizations/${blitzLocale}.yaml`,
|
||||
)
|
||||
.then((response) => response.text())
|
||||
.then((string) => parseYaml(string) as BlitzStrings);
|
||||
const preInstalled = await vfs.yaml<BlitzStrings>(
|
||||
`Data/Strings/${blitzLocale}.yaml`
|
||||
`Data/Strings/${blitzLocale}.yaml`,
|
||||
);
|
||||
|
||||
stringsI18n[locale] = {
|
||||
@@ -588,7 +606,7 @@ export async function definitions() {
|
||||
};
|
||||
|
||||
console.log(`Loaded strings for ${locale}`);
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
function getString(name: string) {
|
||||
@@ -627,9 +645,9 @@ export async function definitions() {
|
||||
consumables,
|
||||
(
|
||||
await vfs.xml<{ root: ConsumablesCommon }>(
|
||||
`Data/XML/item_defs/vehicles/common/consumables/${match[1]}.xml`
|
||||
`Data/XML/item_defs/vehicles/common/consumables/${match[1]}.xml`,
|
||||
)
|
||||
).root
|
||||
).root,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -642,39 +660,57 @@ export async function definitions() {
|
||||
provisions,
|
||||
(
|
||||
await vfs.xml<{ root: ConsumablesCommon }>(
|
||||
`Data/XML/item_defs/vehicles/common/provisions/${match[1]}.xml`
|
||||
`Data/XML/item_defs/vehicles/common/provisions/${match[1]}.xml`,
|
||||
)
|
||||
).root
|
||||
).root,
|
||||
);
|
||||
}
|
||||
|
||||
const avatar = await vfs.xml<{ root: Avatar }>(
|
||||
`Data/XML/item_defs/tankmen/avatar.xml`
|
||||
`Data/XML/item_defs/tankmen/avatar.xml`,
|
||||
);
|
||||
const maps = await vfs.yaml<Maps>(`Data/maps.yaml`);
|
||||
const tankXps = new Map<number, ResearchCost>();
|
||||
const camouflagesXml = await vfs.xml<{ root: CamouflagesXML }>(
|
||||
`Data/XML/item_defs/vehicles/common/camouflages.xml`
|
||||
`Data/XML/item_defs/vehicles/common/camouflages.xml`,
|
||||
);
|
||||
const camouflagesYaml = await vfs.yaml<CamouflagesYaml>(
|
||||
`Data/camouflages.yaml`
|
||||
`Data/camouflages.yaml`,
|
||||
);
|
||||
const camouflagesXmlEntries = Object.entries(camouflagesXml.root.camouflages);
|
||||
const squadBattleTypeStyles = await vfs.yaml<SquadBattleTypeStyles>(
|
||||
`Data/UI/Screens3/Lobby/Hangar/Squad/SquadBattleType.yaml`
|
||||
`Data/UI/Screens3/Lobby/Hangar/Squad/SquadBattleType.yaml`,
|
||||
);
|
||||
const gameTypeSelectorStyles = await vfs.yaml<SquadBattleTypeStyles>(
|
||||
`Data/UI/Screens/Lobby/Hangar/GameTypeSelector.yaml`
|
||||
`Data/UI/Screens/Lobby/Hangar/GameTypeSelector.yaml`,
|
||||
);
|
||||
const gameModeNativeNames: Record<string, number> = {};
|
||||
const combatRoles = await vfs.yaml<CombatRolesYaml>(
|
||||
`Data/XML/item_defs/vehicles/common/combat_roles.yaml`
|
||||
`Data/XML/item_defs/vehicles/common/combat_roles.yaml`,
|
||||
);
|
||||
const consumableNativeNames: 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(
|
||||
/"(\d+)" -> "(battleType\/([a-zA-Z]+))"/g
|
||||
/"(\d+)" -> "(battleType\/([a-zA-Z]+))"/g,
|
||||
)) {
|
||||
const id = Number(match[1]);
|
||||
const name = getString(match[2]);
|
||||
@@ -686,7 +722,7 @@ export async function definitions() {
|
||||
}
|
||||
|
||||
for (const match of gameTypeSelectorStyles.Prototypes[0].components.UIDataLocalBindingsComponent.data[1][2].matchAll(
|
||||
/eGameMode\.([a-zA-Z]+) -> "~res:\/Gfx\/UI\/Hangar\/GameTypes\/battle-type_([^"]+)"/g
|
||||
/eGameMode\.([a-zA-Z]+) -> "~res:\/Gfx\/UI\/Hangar\/GameTypes\/battle-type_([^"]+)"/g,
|
||||
)) {
|
||||
Object.entries(gameModeNativeNames).forEach(([key, value]) => {
|
||||
if (key.toLowerCase() === match[2].toLowerCase()) {
|
||||
@@ -720,7 +756,7 @@ export async function definitions() {
|
||||
|
||||
for (const nation of nations) {
|
||||
const tankList = await vfs.xml<{ root: VehicleDefinitionList }>(
|
||||
`Data/XML/item_defs/vehicles/${nation}/list.xml`
|
||||
`Data/XML/item_defs/vehicles/${nation}/list.xml`,
|
||||
);
|
||||
|
||||
for (const tankKey in tankList.root) {
|
||||
@@ -761,7 +797,7 @@ export async function definitions() {
|
||||
console.warn(
|
||||
`Multiple tanks share slug ${slug}: ${requesters
|
||||
.map(({ key }) => key)
|
||||
.join(", ")}`
|
||||
.join(", ")}`,
|
||||
);
|
||||
|
||||
if (requesters.length !== 2) {
|
||||
@@ -791,7 +827,7 @@ export async function definitions() {
|
||||
|
||||
if (canonical === undefined) {
|
||||
throw new Error(
|
||||
"Two tutorial bots share the same slug? The world is truly broken."
|
||||
"Two tutorial bots share the same slug? The world is truly broken.",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -804,7 +840,7 @@ export async function definitions() {
|
||||
|
||||
for (const nation of nations) {
|
||||
const tankList = await vfs.xml<{ root: VehicleDefinitionList }>(
|
||||
`Data/XML/item_defs/vehicles/${nation}/list.xml`
|
||||
`Data/XML/item_defs/vehicles/${nation}/list.xml`,
|
||||
);
|
||||
const turretList = await vfs.xml<{
|
||||
root: TurretDefinitionsList;
|
||||
@@ -857,7 +893,7 @@ export async function definitions() {
|
||||
: Number(item.cost.split(":")[1]),
|
||||
},
|
||||
} satisfies Unlock;
|
||||
})
|
||||
}),
|
||||
)
|
||||
.flat();
|
||||
}
|
||||
@@ -872,10 +908,10 @@ export async function definitions() {
|
||||
const tank = tankList.root[tankKey];
|
||||
let tankPrice: TankPrice;
|
||||
const tankDefinition = await vfs.xml<{ root: VehicleDefinitions }>(
|
||||
`Data/XML/item_defs/vehicles/${nation}/${tankKey}.xml`
|
||||
`Data/XML/item_defs/vehicles/${nation}/${tankKey}.xml`,
|
||||
);
|
||||
const tankParameters = await vfs.yaml<TankParameters>(
|
||||
`Data/3d/Tanks/Parameters/${nation}/${tankKey}.yaml`
|
||||
`Data/3d/Tanks/Parameters/${nation}/${tankKey}.yaml`,
|
||||
);
|
||||
const turretOrigin = tankDefinition.root.hull.turretPositions.turret
|
||||
.split(" ")
|
||||
@@ -890,23 +926,23 @@ export async function definitions() {
|
||||
|
||||
if (slug === undefined) {
|
||||
throw new Error(
|
||||
`Could not find slug for ${nation}/${tankKey} (${tankId})`
|
||||
`Could not find slug for ${nation}/${tankKey} (${tankId})`,
|
||||
);
|
||||
}
|
||||
|
||||
if (tank.sellPrice) {
|
||||
tankPrice = {
|
||||
type: TankPriceType.GOLD,
|
||||
type: TankPriceType.TANK_PRICE_TYPE_GOLD,
|
||||
value: tank.sellPrice["#text"] * 2,
|
||||
};
|
||||
} else if (typeof tank.price === "number") {
|
||||
tankPrice = {
|
||||
type: TankPriceType.CREDITS,
|
||||
type: TankPriceType.TANK_PRICE_TYPE_CREDITS,
|
||||
value: tank.price,
|
||||
};
|
||||
} else {
|
||||
tankPrice = {
|
||||
type: TankPriceType.CREDITS,
|
||||
type: TankPriceType.TANK_PRICE_TYPE_CREDITS,
|
||||
value: tank.price["#text"] * 400,
|
||||
};
|
||||
}
|
||||
@@ -923,13 +959,7 @@ export async function definitions() {
|
||||
const armorId = parseInt(armorIdString);
|
||||
const armorRaw = tankDefinition.root.hull.armor[name];
|
||||
|
||||
if (typeof armorRaw === "number") {
|
||||
hullArmor.thickness[armorId] = armorRaw;
|
||||
} else {
|
||||
if (!hullArmor.spaced) hullArmor.spaced = [];
|
||||
hullArmor.thickness[armorId] = armorRaw["#text"];
|
||||
hullArmor.spaced.push(armorId);
|
||||
}
|
||||
assignArmor(armorRaw, armorId, hullArmor);
|
||||
});
|
||||
const crew: Crew[] = [];
|
||||
const fixedCamouflage = tankTags.includes("eventCamouflage_user");
|
||||
@@ -938,7 +968,7 @@ export async function definitions() {
|
||||
Object.entries(tankDefinition.root.crew).forEach(([crewKey, value]) => {
|
||||
let entry: Crew;
|
||||
const index = crew.findIndex(
|
||||
({ type }) => blitzkitCrewTypeToBlitz[type] === crewKey
|
||||
({ type }) => blitzkitCrewTypeToBlitz[type] === crewKey,
|
||||
);
|
||||
if (index === -1) {
|
||||
if (crewKey === "#text") return;
|
||||
@@ -988,10 +1018,23 @@ export async function definitions() {
|
||||
})
|
||||
.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] = {
|
||||
ancestors: [],
|
||||
successors: [],
|
||||
id: tankId,
|
||||
dev_name: tankKey,
|
||||
roles: {},
|
||||
camouflages: camouflages,
|
||||
fixed_camouflage: fixedCamouflage,
|
||||
@@ -1011,10 +1054,10 @@ export async function definitions() {
|
||||
slug,
|
||||
nation,
|
||||
type: tankTags.includes("collectible")
|
||||
? TankType.COLLECTOR
|
||||
? TankType.TANK_TYPE_COLLECTOR
|
||||
: (typeof tank.price === "number" ? false : "gold" in tank.price)
|
||||
? TankType.PREMIUM
|
||||
: TankType.RESEARCHABLE,
|
||||
? TankType.TANK_TYPE_PREMIUM
|
||||
: TankType.TANK_TYPE_RESEARCHABLE,
|
||||
tier: tank.level,
|
||||
class: blitzTankClassToBlitzkit[tankTags[0] as BlitzTankClass],
|
||||
testing: tankTags.includes("testTank"),
|
||||
@@ -1022,21 +1065,22 @@ export async function definitions() {
|
||||
price: tankPrice,
|
||||
camouflage_still: tankDefinition.root.invisibility.still,
|
||||
camouflage_moving: tankDefinition.root.invisibility.moving,
|
||||
camouflage_onFire: tankDefinition.root.invisibility.firePenalty,
|
||||
camouflage_on_fire: tankDefinition.root.invisibility.firePenalty,
|
||||
turrets: [],
|
||||
engines: [],
|
||||
tracks: [],
|
||||
equalizer,
|
||||
};
|
||||
|
||||
if (tank.combatRole) {
|
||||
Object.entries(tank.combatRole).forEach(([gameMode, role]) => {
|
||||
const id = Object.entries(gameModeNativeNames).find(
|
||||
([key]) => key.toLowerCase() === gameMode.toLowerCase()
|
||||
([key]) => key.toLowerCase() === gameMode.toLowerCase(),
|
||||
)?.[1];
|
||||
|
||||
if (id === undefined) {
|
||||
throw new Error(
|
||||
`Unknown game mode in tank ${tankKey}: ${gameMode}`
|
||||
`Unknown game mode in tank ${tankKey}: ${gameMode}`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1118,7 +1162,7 @@ export async function definitions() {
|
||||
(turretKey, turretIndex) => {
|
||||
const turret = tankDefinition.root.turrets0[turretKey];
|
||||
const turretModel = Number(
|
||||
parsePath(turret.models.undamaged).name.split("_")[1]
|
||||
parsePath(turret.models.undamaged).name.split("_")[1],
|
||||
);
|
||||
const turretId = toUniqueId(nation, turretList.root.ids[turretKey]);
|
||||
const turretYaw = (
|
||||
@@ -1150,13 +1194,7 @@ export async function definitions() {
|
||||
const armorId = parseInt(armorIdString);
|
||||
const armorRaw = turret.armor[name];
|
||||
|
||||
if (typeof armorRaw === "number") {
|
||||
turretArmor.thickness[armorId] = armorRaw;
|
||||
} else {
|
||||
if (!turretArmor.spaced) turretArmor.spaced = [];
|
||||
turretArmor.thickness[armorId] = armorRaw["#text"];
|
||||
turretArmor.spaced.push(armorId);
|
||||
}
|
||||
assignArmor(armorRaw, armorId, turretArmor);
|
||||
});
|
||||
|
||||
turret.userString;
|
||||
@@ -1186,12 +1224,12 @@ export async function definitions() {
|
||||
min: vector3TupleToBlitzkit(
|
||||
tankParameters.collision[
|
||||
parsePath(turret.hitTester.collisionModel).name.toLowerCase()
|
||||
].bbox.min
|
||||
].bbox.min,
|
||||
),
|
||||
max: vector3TupleToBlitzkit(
|
||||
tankParameters.collision[
|
||||
parsePath(turret.hitTester.collisionModel).name.toLowerCase()
|
||||
].bbox.max
|
||||
].bbox.max,
|
||||
),
|
||||
},
|
||||
};
|
||||
@@ -1209,7 +1247,7 @@ export async function definitions() {
|
||||
.split(" ")
|
||||
.map(Number) as [number, number];
|
||||
const gunModel = Number(
|
||||
parsePath(gun.models.undamaged).name.split("_")[1]
|
||||
parsePath(gun.models.undamaged).name.split("_")[1],
|
||||
);
|
||||
const gunName = getString(gunListEntry.userString);
|
||||
const gunType =
|
||||
@@ -1287,13 +1325,8 @@ export async function definitions() {
|
||||
}
|
||||
const armorId = parseInt(armorIdString);
|
||||
const armorRaw = gun.armor[name];
|
||||
if (typeof armorRaw === "number") {
|
||||
gunArmor.thickness[armorId] = armorRaw;
|
||||
} else {
|
||||
if (!gunArmor.spaced) gunArmor.spaced = [];
|
||||
gunArmor.thickness[armorId] = armorRaw["#text"];
|
||||
gunArmor.spaced.push(armorId);
|
||||
}
|
||||
|
||||
assignArmor(armorRaw, armorId, gunArmor);
|
||||
});
|
||||
|
||||
tankDefinitions.tanks[tankId].turrets[turretIndex].guns.push({
|
||||
@@ -1332,24 +1365,24 @@ export async function definitions() {
|
||||
},
|
||||
}
|
||||
: gunType === "autoReloader"
|
||||
? {
|
||||
$case: "auto_reloader",
|
||||
value: {
|
||||
intra_clip: 60 / gun.clip!.rate,
|
||||
shell_count: gunClipCount,
|
||||
shell_reloads: gun
|
||||
.pumpGunReloadTimes!.split(" ")
|
||||
.map(Number),
|
||||
? {
|
||||
$case: "auto_reloader",
|
||||
value: {
|
||||
intra_clip: 60 / gun.clip!.rate,
|
||||
shell_count: gunClipCount,
|
||||
shell_reloads: gun
|
||||
.pumpGunReloadTimes!.split(" ")
|
||||
.map(Number),
|
||||
},
|
||||
}
|
||||
: {
|
||||
$case: "auto_loader",
|
||||
value: {
|
||||
intra_clip: 60 / gun.clip!.rate,
|
||||
clip_reload: gun.reloadTime,
|
||||
shell_count: gunClipCount,
|
||||
},
|
||||
},
|
||||
}
|
||||
: {
|
||||
$case: "auto_loader",
|
||||
value: {
|
||||
intra_clip: 60 / gun.clip!.rate,
|
||||
clip_reload: gun.reloadTime,
|
||||
shell_count: gunClipCount,
|
||||
},
|
||||
},
|
||||
} satisfies GunDefinition);
|
||||
|
||||
modelDefinitions.models[tankId].turrets[turretId].guns[gunId] = {
|
||||
@@ -1360,8 +1393,8 @@ export async function definitions() {
|
||||
gun.armor.gun === undefined
|
||||
? 0
|
||||
: typeof gun.armor.gun === "number"
|
||||
? gun.armor.gun
|
||||
: gun.armor.gun["#text"],
|
||||
? gun.armor.gun
|
||||
: gun.armor.gun["#text"],
|
||||
pitch: {
|
||||
min: gunPitch[0],
|
||||
max: gunPitch[1],
|
||||
@@ -1408,7 +1441,7 @@ export async function definitions() {
|
||||
type: blitzShellKindToBlitzkit[shell.kind],
|
||||
explosion_radius:
|
||||
shell.kind === "HIGH_EXPLOSIVE"
|
||||
? shell.explosionRadius ?? 0
|
||||
? (shell.explosionRadius ?? 0)
|
||||
: undefined,
|
||||
icon: shell.icon,
|
||||
penetration: {
|
||||
@@ -1419,7 +1452,7 @@ export async function definitions() {
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
totalUnlocks.forEach((unlocks) => {
|
||||
@@ -1447,7 +1480,7 @@ export async function definitions() {
|
||||
case "gun": {
|
||||
gunXps.set(
|
||||
toUniqueId(nation, gunList.root.ids[vehicle["#text"]]),
|
||||
parseResearchCost(vehicle.cost)
|
||||
parseResearchCost(vehicle.cost),
|
||||
);
|
||||
break;
|
||||
}
|
||||
@@ -1455,7 +1488,7 @@ export async function definitions() {
|
||||
case "turret": {
|
||||
turretXps.set(
|
||||
toUniqueId(nation, turretList.root.ids[vehicle["#text"]]),
|
||||
parseResearchCost(vehicle.cost)
|
||||
parseResearchCost(vehicle.cost),
|
||||
);
|
||||
break;
|
||||
}
|
||||
@@ -1463,7 +1496,7 @@ export async function definitions() {
|
||||
case "engine": {
|
||||
engineXps.set(
|
||||
toUniqueId(nation, enginesList.root.ids[vehicle["#text"]]),
|
||||
parseResearchCost(vehicle.cost)
|
||||
parseResearchCost(vehicle.cost),
|
||||
);
|
||||
break;
|
||||
}
|
||||
@@ -1471,7 +1504,7 @@ export async function definitions() {
|
||||
case "chassis": {
|
||||
trackXps.set(
|
||||
toUniqueId(nation, chassisList.root.ids[vehicle["#text"]]),
|
||||
parseResearchCost(vehicle.cost)
|
||||
parseResearchCost(vehicle.cost),
|
||||
);
|
||||
break;
|
||||
}
|
||||
@@ -1518,7 +1551,7 @@ export async function definitions() {
|
||||
name: getString(optionalDeviceEntry.userString),
|
||||
description: getString(optionalDeviceEntry.description),
|
||||
};
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
Object.entries(optionalDeviceSlots.root.presets).forEach(
|
||||
@@ -1537,7 +1570,7 @@ export async function definitions() {
|
||||
})
|
||||
.flat(),
|
||||
};
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
Object.entries(consumables).forEach(([key, consumable]) => {
|
||||
@@ -1620,7 +1653,7 @@ export async function definitions() {
|
||||
(item) =>
|
||||
blitzTankFilterDefinitionCategoryToBlitzkit[
|
||||
item as BlitzTankFilterDefinitionCategory
|
||||
]
|
||||
],
|
||||
),
|
||||
},
|
||||
},
|
||||
@@ -1718,7 +1751,7 @@ export async function definitions() {
|
||||
(item) =>
|
||||
blitzTankFilterDefinitionCategoryToBlitzkit[
|
||||
item as BlitzTankFilterDefinitionCategory
|
||||
]
|
||||
],
|
||||
),
|
||||
},
|
||||
},
|
||||
@@ -1749,11 +1782,11 @@ export async function definitions() {
|
||||
value.default_abilities.forEach((ability) => {
|
||||
if (ability in consumableNativeNames) {
|
||||
gameDefinitions.roles[value.id].consumables.push(
|
||||
consumableNativeNames[ability]
|
||||
consumableNativeNames[ability],
|
||||
);
|
||||
} else if (ability in provisionNativeNames) {
|
||||
gameDefinitions.roles[value.id].provisions.push(
|
||||
provisionNativeNames[ability]
|
||||
provisionNativeNames[ability],
|
||||
);
|
||||
} else throw new Error(`Unknown ability ${ability}`);
|
||||
});
|
||||
|
||||
@@ -17,15 +17,15 @@ export async function equipmentIcons() {
|
||||
|
||||
using uploader = new AssetUploader("equipment icons");
|
||||
const optionalDevices = await vfs.xml<{ root: OptionalDevices }>(
|
||||
`Data/XML/item_defs/vehicles/common/optional_devices.xml`
|
||||
`Data/XML/item_defs/vehicles/common/optional_devices.xml`,
|
||||
);
|
||||
const mappings = await vfs.yaml<Mappings>(
|
||||
`Data/UI/Screens3/Lobby/Inventory/OptionalDevices/OptionalDevicesItemImage.style.yaml`
|
||||
`Data/UI/Screens3/Lobby/Inventory/OptionalDevices/OptionalDevicesItemImage.style.yaml`,
|
||||
);
|
||||
const image = sharp(
|
||||
await vfs.file(
|
||||
`Data/Gfx/UI/InventoryIcons/Big/OptionalDevices/texture0.packed.webp`
|
||||
)
|
||||
`Data/Gfx/UI/InventoryIcons/Big/OptionalDevices/texture0.packed.webp`,
|
||||
),
|
||||
);
|
||||
|
||||
for (const optionalDeviceKey in optionalDevices.root) {
|
||||
@@ -35,8 +35,8 @@ export async function equipmentIcons() {
|
||||
|
||||
const mapping = mappings.StyleSheets.find((mapping) =>
|
||||
mapping.selectors.includes(
|
||||
`.optional_device_item.${optionalDevice.icon} #Img`
|
||||
)
|
||||
`.optional_device_item.${optionalDevice.icon} #Img`,
|
||||
),
|
||||
);
|
||||
|
||||
if (!mapping) {
|
||||
@@ -49,9 +49,7 @@ export async function equipmentIcons() {
|
||||
|
||||
if (configPath.startsWith("Gfx/Lobby")) {
|
||||
const configPathWebp = configPath.replace(".txt", "");
|
||||
const image = sharp(
|
||||
await vfs.file(`Data/${configPathWebp}.packed.webp`)
|
||||
);
|
||||
const image = sharp(await vfs.file(`Data/${configPathWebp}.packed.webp`));
|
||||
const content = await image.trim().toBuffer();
|
||||
|
||||
await uploader.add({
|
||||
|
||||
@@ -6,20 +6,32 @@ export async function flags() {
|
||||
console.log("Building flags...");
|
||||
|
||||
using uploader = new AssetUploader("flags");
|
||||
const circleFiles = vfs.dir(`Data/Gfx/Lobby/flags`).filter(
|
||||
(flag) =>
|
||||
flag.startsWith("flag_profile-stat_") &&
|
||||
!flag.endsWith("@2x.packed.webp")
|
||||
const circleFiles = await vfs
|
||||
.dir(`Data/Gfx/Lobby/flags`)
|
||||
.then((files) =>
|
||||
files.filter(
|
||||
(flag) =>
|
||||
flag.startsWith("flag_profile-stat_") &&
|
||||
!flag.endsWith("@2x.packed.webp"),
|
||||
),
|
||||
);
|
||||
const scratchedFiles = vfs.dir(`Data/Gfx/Lobby/flags`).filter(
|
||||
const scratchedFiles = await vfs
|
||||
.dir(`Data/Gfx/Lobby/flags`)
|
||||
.then((files) =>
|
||||
files.filter(
|
||||
(flag) =>
|
||||
flag.startsWith("flag_tutor-tank_") &&
|
||||
!flag.endsWith("@2x.packed.webp")
|
||||
)
|
||||
const fadedFiles = vfs.dir(`Data/Gfx/Lobby/flags`).filter(
|
||||
(flag) =>
|
||||
flag.startsWith("flag_filter_") && flag.endsWith("@2x.packed.webp")
|
||||
)
|
||||
!flag.endsWith("@2x.packed.webp"),
|
||||
),
|
||||
);
|
||||
const fadedFiles = await vfs
|
||||
.dir(`Data/Gfx/Lobby/flags`)
|
||||
.then((files) =>
|
||||
files.filter(
|
||||
(flag) =>
|
||||
flag.startsWith("flag_filter_") && flag.endsWith("@2x.packed.webp"),
|
||||
),
|
||||
);
|
||||
|
||||
for (const flag of circleFiles) {
|
||||
const image = sharp(await vfs.file(`Data/Gfx/Lobby/flags/${flag}`));
|
||||
@@ -43,9 +55,7 @@ export async function flags() {
|
||||
}
|
||||
|
||||
for (const flag of fadedFiles) {
|
||||
const content = await sharp(
|
||||
await vfs.file(`Data/Gfx/Lobby/flags/${flag}`)
|
||||
)
|
||||
const content = await sharp(await vfs.file(`Data/Gfx/Lobby/flags/${flag}`))
|
||||
.trim({
|
||||
threshold: 100,
|
||||
background: { r: 0, g: 0, b: 0, alpha: 0 },
|
||||
|
||||
@@ -8,35 +8,33 @@ export async function gameModeBanners() {
|
||||
|
||||
using uploader = new AssetUploader("game mode banners");
|
||||
const gameTypeSelectorStyles = await vfs.yaml<SquadBattleTypeStyles>(
|
||||
`Data/UI/Screens/Lobby/Hangar/GameTypeSelector.yaml`
|
||||
`Data/UI/Screens/Lobby/Hangar/GameTypeSelector.yaml`,
|
||||
);
|
||||
const squadBattleTypeStyles = await vfs.yaml<SquadBattleTypeStyles>(
|
||||
`Data/UI/Screens3/Lobby/Hangar/Squad/SquadBattleType.yaml`
|
||||
`Data/UI/Screens3/Lobby/Hangar/Squad/SquadBattleType.yaml`,
|
||||
);
|
||||
const bannerMatches: { name: string; path: string }[] = [];
|
||||
|
||||
for (const match of gameTypeSelectorStyles.Prototypes[0].components.UIDataLocalBindingsComponent.data[1][2].matchAll(
|
||||
/eGameMode\.([a-zA-Z]+) -> "~res:([^"]+)"/g
|
||||
/eGameMode\.([a-zA-Z]+) -> "~res:([^"]+)"/g,
|
||||
)) {
|
||||
bannerMatches.push({ name: match[1], path: match[2] });
|
||||
}
|
||||
|
||||
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,
|
||||
)) {
|
||||
const id = Number(match[1]);
|
||||
const name = match[2];
|
||||
let path = bannerMatches.find(
|
||||
(bannerMatch) => bannerMatch.name.toLowerCase() === name.toLowerCase()
|
||||
(bannerMatch) => bannerMatch.name.toLowerCase() === name.toLowerCase(),
|
||||
)?.path;
|
||||
|
||||
if (path === undefined) {
|
||||
path = `/Gfx/UI/Hangar/GameTypes/battle-type_${name.toLowerCase()}`;
|
||||
}
|
||||
|
||||
const content = await sharp(
|
||||
await vfs.file(`Data${path}.packed.webp`)
|
||||
)
|
||||
const content = await sharp(await vfs.file(`Data${path}.packed.webp`))
|
||||
.trim({ background: { r: 0, g: 0, b: 0, alpha: 0 } })
|
||||
.toBuffer();
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ export async function glossary() {
|
||||
const glossary = await fetchGlossary(supported.blitz ?? supported.locale);
|
||||
|
||||
console.log(
|
||||
`Found ${Object.keys(glossary).length} things for ${supported.locale}`
|
||||
`Found ${Object.keys(glossary).length} things for ${supported.locale}`,
|
||||
);
|
||||
|
||||
for (const key in glossary) {
|
||||
@@ -30,7 +30,7 @@ export async function glossary() {
|
||||
}
|
||||
|
||||
if (key in avatars) {
|
||||
avatars[key].avatar.name.locales[supported.locale] =
|
||||
avatars[key].avatar.name!.locales[supported.locale] =
|
||||
glossaryEntry.title;
|
||||
} else {
|
||||
const extension = extname(glossaryEntry.image_url);
|
||||
@@ -45,7 +45,7 @@ export async function glossary() {
|
||||
};
|
||||
}
|
||||
}
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
const gallery: Gallery = { avatars: [] };
|
||||
@@ -53,12 +53,12 @@ export async function glossary() {
|
||||
|
||||
const bar = new ProgressBar(
|
||||
`Fetching avatars of ${totalCount} things :bar`,
|
||||
totalCount
|
||||
totalCount,
|
||||
);
|
||||
|
||||
await Promise.all(
|
||||
Object.entries(avatars).map(async ([key, { url, avatar }]) => {
|
||||
if (!(locales.default in avatars[key].avatar.name.locales)) {
|
||||
if (!(locales.default in avatars[key].avatar.name!.locales)) {
|
||||
console.warn(`Avatar ${key} has no ${locales.default} name`);
|
||||
bar.tick();
|
||||
|
||||
@@ -77,7 +77,7 @@ export async function glossary() {
|
||||
});
|
||||
|
||||
bar.tick();
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
await uploader.add({
|
||||
|
||||
@@ -8,11 +8,13 @@ export async function migration() {
|
||||
|
||||
using uploader = new AssetUploader("migration map");
|
||||
const map: Record<string, number> = {};
|
||||
const nations = vfs.dir(`Data/XML/item_defs/vehicles`).filter((nation) => nation !== "common");
|
||||
const nations = await vfs
|
||||
.dir(`Data/XML/item_defs/vehicles`)
|
||||
.then((files) => files.filter((nation) => nation !== "common"));
|
||||
|
||||
for (const nation of nations) {
|
||||
const tankList = await vfs.xml<{ root: VehicleDefinitionList }>(
|
||||
`Data/XML/item_defs/vehicles/${nation}/list.xml`
|
||||
`Data/XML/item_defs/vehicles/${nation}/list.xml`,
|
||||
);
|
||||
|
||||
for (const tankKey in tankList.root) {
|
||||
|
||||
@@ -6,15 +6,20 @@ export async function moduleIcons() {
|
||||
console.log("Building module icons...");
|
||||
|
||||
using uploader = new AssetUploader("module icons");
|
||||
const files = vfs.dir(`Data/Gfx/UI/ModulesTechTree`).filter(
|
||||
(file) => !file.endsWith("@2x.packed.webp") && file.startsWith("vehicle")
|
||||
)
|
||||
const files = await vfs
|
||||
.dir(`Data/Gfx/UI/ModulesTechTree`)
|
||||
.then((files) =>
|
||||
files.filter(
|
||||
(file) =>
|
||||
!file.endsWith("@2x.packed.webp") && file.startsWith("vehicle"),
|
||||
),
|
||||
);
|
||||
|
||||
for (const file of files) {
|
||||
const nameRaw = file.match(/vehicle(.+)\.packed\.webp/)![1];
|
||||
const name = nameRaw[0].toLowerCase() + nameRaw.slice(1);
|
||||
const content = await sharp(
|
||||
await vfs.file(`Data/Gfx/UI/ModulesTechTree/${file}`)
|
||||
await vfs.file(`Data/Gfx/UI/ModulesTechTree/${file}`),
|
||||
)
|
||||
.trim()
|
||||
.toBuffer();
|
||||
|
||||
@@ -17,7 +17,7 @@ export async function popularTanks() {
|
||||
const analytics = google.analyticsdata({ version: "v1beta", auth });
|
||||
const report = await analytics.properties.runReport({
|
||||
property: `properties/${assertSecret(
|
||||
import.meta.env.PUBLIC_GOOGLE_ANALYTICS_PROPERTY_ID
|
||||
import.meta.env.PUBLIC_GOOGLE_ANALYTICS_PROPERTY_ID,
|
||||
)}`,
|
||||
requestBody: {
|
||||
dateRanges: [{ startDate: "7daysAgo", endDate: "today" }],
|
||||
@@ -47,13 +47,13 @@ export async function popularTanks() {
|
||||
row.dimensionValues[0].value &&
|
||||
row.dimensionValues[0].value !== "/tanks/" &&
|
||||
row.metricValues &&
|
||||
row.metricValues[0].value
|
||||
row.metricValues[0].value,
|
||||
)
|
||||
.map((row) => ({
|
||||
id: Number(
|
||||
row.dimensionValues![0].value!.match(
|
||||
/\/tools\/tankopedia\/(\d+)\/?/
|
||||
)?.[1]
|
||||
/\/tools\/tankopedia\/(\d+)\/?/,
|
||||
)?.[1],
|
||||
),
|
||||
views: Number(row.metricValues![0].value!),
|
||||
}))
|
||||
|
||||
@@ -8,19 +8,17 @@ export async function shellIcons() {
|
||||
using uploader = new AssetUploader("shell icons");
|
||||
const image = sharp(
|
||||
await vfs.file(
|
||||
`Data/Gfx/Shared/tank-supply/ammunition/big/texture0.packed.webp`
|
||||
)
|
||||
`Data/Gfx/Shared/tank-supply/ammunition/big/texture0.packed.webp`,
|
||||
),
|
||||
);
|
||||
const files = vfs.dir(
|
||||
`Data/Gfx/Shared/tank-supply/ammunition/big`
|
||||
).filter((file) => file.endsWith("_l.txt"))
|
||||
const files = await vfs
|
||||
.dir(`Data/Gfx/Shared/tank-supply/ammunition/big`)
|
||||
.then((files) => files.filter((file) => file.endsWith("_l.txt")));
|
||||
|
||||
for (const file of files) {
|
||||
const name = file.match(/(.+)_l\.txt/)![1];
|
||||
const sizes = (
|
||||
await vfs.text(
|
||||
`Data/Gfx/Shared/tank-supply/ammunition/big/${file}`
|
||||
)
|
||||
await vfs.text(`Data/Gfx/Shared/tank-supply/ammunition/big/${file}`)
|
||||
)
|
||||
.split("\n")[4]
|
||||
.split(" ")
|
||||
|
||||
@@ -26,7 +26,7 @@ export async function skillIcons() {
|
||||
console.log("Building skill icons...");
|
||||
|
||||
const avatar = await vfs.xml<{ root: Avatar }>(
|
||||
`Data/XML/item_defs/tankmen/avatar.xml`
|
||||
`Data/XML/item_defs/tankmen/avatar.xml`,
|
||||
);
|
||||
const uploader = new AssetUploader("skill icons");
|
||||
|
||||
|
||||
@@ -10,11 +10,13 @@ export async function tankArmors() {
|
||||
|
||||
using uploader = new AssetUploader("tank armors");
|
||||
const nodeIO = new NodeIO();
|
||||
const nations = vfs.dir(`Data/XML/item_defs/vehicles`).filter((nation) => nation !== "common");
|
||||
const nations = await vfs
|
||||
.dir(`Data/XML/item_defs/vehicles`)
|
||||
.then((files) => files.filter((nation) => nation !== "common"));
|
||||
|
||||
for (const nation of nations) {
|
||||
const tanks = await vfs.xml<{ root: VehicleDefinitionList }>(
|
||||
`Data/XML/item_defs/vehicles/${nation}/list.xml`
|
||||
`Data/XML/item_defs/vehicles/${nation}/list.xml`,
|
||||
);
|
||||
|
||||
for (const tankKey in tanks.root) {
|
||||
|
||||
@@ -41,11 +41,13 @@ export async function tankIcons() {
|
||||
console.log("Building tank icons...");
|
||||
|
||||
using uploader = new AssetUploader("tank icons");
|
||||
const nations = vfs.dir(`Data/XML/item_defs/vehicles`).filter((nation) => nation !== "common")
|
||||
const nations = await vfs
|
||||
.dir(`Data/XML/item_defs/vehicles`)
|
||||
.then((files) => files.filter((nation) => nation !== "common"));
|
||||
|
||||
for (const nation of nations) {
|
||||
const tanks = await vfs.xml<{ root: VehicleDefinitionList }>(
|
||||
`Data/XML/item_defs/vehicles/${nation}/list.xml`
|
||||
`Data/XML/item_defs/vehicles/${nation}/list.xml`,
|
||||
);
|
||||
|
||||
for (const tankKey in tanks.root) {
|
||||
@@ -57,7 +59,7 @@ export async function tankIcons() {
|
||||
const id = (nationVehicleId << 8) + (NATION_IDS[nation] << 4) + 1;
|
||||
|
||||
const parameters = await vfs.yaml<TankParameters>(
|
||||
`Data/3d/Tanks/Parameters/${nation}/${tankKey}.yaml`
|
||||
`Data/3d/Tanks/Parameters/${nation}/${tankKey}.yaml`,
|
||||
);
|
||||
const smallPath = `Data/${parameters.resourcesPath.smallIconPath
|
||||
.replace(/~res:\//, "")
|
||||
|
||||
@@ -12,9 +12,9 @@ export async function tankModels() {
|
||||
|
||||
using uploader = new AssetUploader("tank models");
|
||||
const nodeIO = new NodeIO().registerExtensions(ALL_EXTENSIONS);
|
||||
const nations = vfs
|
||||
const nations = await vfs
|
||||
.dir(`Data/XML/item_defs/vehicles`)
|
||||
.filter((nation) => nation !== "common");
|
||||
.then((files) => files.filter((nation) => nation !== "common"));
|
||||
|
||||
for (const nationIndex in nations) {
|
||||
const nation = nations[nationIndex];
|
||||
@@ -41,4 +41,4 @@ export async function tankModels() {
|
||||
}
|
||||
|
||||
await uploader.flush();
|
||||
}
|
||||
}
|
||||
@@ -170,6 +170,7 @@ export async function extractModel(vfs: AbstractVFS, path: string) {
|
||||
break;
|
||||
|
||||
case "TransformComponent": {
|
||||
component["tc.localTranslation"] = [0, 0, 0]; // Game when is loading model resets position to [0, 0, 0], so any set value is ignored.
|
||||
node.setTranslation(component["tc.localTranslation"]);
|
||||
node.setRotation(component["tc.localRotation"]);
|
||||
node.setScale(component["tc.localScale"]);
|
||||
|
||||
@@ -3,7 +3,7 @@ import { vfs } from "../../../buildAssets/constants";
|
||||
|
||||
export async function readTexture(path: string) {
|
||||
const ddsTexturePath = path.replace(".tex", ".dx11.dds");
|
||||
const isDds = vfs.resolve(ddsTexturePath);
|
||||
const isDds = await vfs.resolve(ddsTexturePath);
|
||||
const resolvedTexturePath = isDds
|
||||
? ddsTexturePath
|
||||
: ddsTexturePath.replace(".dds", ".pvr");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { crc32 } from 'crc';
|
||||
import { compressBlock } from 'lz4js';
|
||||
import { crc32 } from "crc";
|
||||
import { compressBlock } from "lz4js";
|
||||
|
||||
/**
|
||||
* Thanks Maddoxkkm! Modernized heavily.
|
||||
@@ -14,7 +14,7 @@ export function writeDVPL(buffer: Buffer) {
|
||||
destination,
|
||||
0,
|
||||
source.length,
|
||||
0,
|
||||
[0],
|
||||
);
|
||||
let output = Buffer.from(destination);
|
||||
|
||||
@@ -58,7 +58,7 @@ function toDVPLFooter(
|
||||
result.writeUInt32LE(compressedSize, 4);
|
||||
result.writeUInt32LE(crc32, 8);
|
||||
result.writeUInt32LE(type, 12);
|
||||
result.write('DVPL', 16, 4, 'utf8');
|
||||
result.write("DVPL", 16, 4, "utf8");
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -43,7 +43,7 @@ export class AssetUploader {
|
||||
|
||||
constructor(public message: string) {
|
||||
[this.owner, this.repo] = assertSecret(
|
||||
import.meta.env.PUBLIC_ASSET_REPO
|
||||
import.meta.env.PUBLIC_ASSET_REPO,
|
||||
).split("/");
|
||||
this.branch = assertSecret(import.meta.env.PUBLIC_ASSET_BRANCH);
|
||||
}
|
||||
@@ -52,7 +52,7 @@ export class AssetUploader {
|
||||
const blobPath = `${this.owner}/${this.repo}/${this.branch}/${change.path}`;
|
||||
const response = await fetch(
|
||||
`https://raw.githubusercontent.com/${blobPath}`,
|
||||
{ headers: { "Accept-Encoding": "identity" } }
|
||||
{ headers: { "Accept-Encoding": "identity" } },
|
||||
);
|
||||
let diff: { change: number; status: DiffStatus };
|
||||
|
||||
@@ -71,7 +71,7 @@ export class AssetUploader {
|
||||
} else if (response.status === 200) {
|
||||
if (
|
||||
this.heuristicFormats.some((format) =>
|
||||
change.path.endsWith(`.${format}`)
|
||||
change.path.endsWith(`.${format}`),
|
||||
)
|
||||
) {
|
||||
/**
|
||||
@@ -94,7 +94,7 @@ export class AssetUploader {
|
||||
}
|
||||
} else {
|
||||
throw new Error(
|
||||
`Unexpected status code ${response.status} for ${change.path}`
|
||||
`Unexpected status code ${response.status} for ${change.path}`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ export class AssetUploader {
|
||||
console.log(
|
||||
`${diff.status === DiffStatus.New ? "🟢" : "🟡"} (${
|
||||
diff.change > 0 ? "+" : ""
|
||||
}${diff.change.toLocaleString()}B) ${change.path}`
|
||||
}${diff.change.toLocaleString()}B) ${change.path}`,
|
||||
);
|
||||
|
||||
// flush BEFORE going over limit
|
||||
@@ -160,8 +160,8 @@ export class AssetUploader {
|
||||
await new Promise((resolve) =>
|
||||
setTimeout(
|
||||
resolve,
|
||||
Math.max(0, this.time_between_blobs + (start - end))
|
||||
)
|
||||
Math.max(0, this.time_between_blobs + (start - end)),
|
||||
),
|
||||
);
|
||||
|
||||
blobs.push({ sha, path: change.path, mode: "100644", type: "blob" });
|
||||
@@ -170,11 +170,11 @@ export class AssetUploader {
|
||||
break;
|
||||
} catch {
|
||||
console.warn(
|
||||
` failed ${change.path}; retrying in ${this.time_per_blob}ms...`
|
||||
` failed ${change.path}; retrying in ${this.time_per_blob}ms...`,
|
||||
);
|
||||
|
||||
await new Promise((resolve) =>
|
||||
setTimeout(resolve, this.time_per_blob)
|
||||
setTimeout(resolve, this.time_per_blob),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -209,7 +209,7 @@ export class AssetUploader {
|
||||
[Symbol.dispose]() {
|
||||
if (this.changes.length > 0) {
|
||||
throw new Error(
|
||||
`${this.changes.length} uncommitted changes. Did you forget to flush?`
|
||||
`${this.changes.length} uncommitted changes. Did you forget to flush?`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { readDVPL } from "@blitzkit/core";
|
||||
import { Options, parse as parseCSV } from "csv-parse/sync";
|
||||
import { XMLParser } from "fast-xml-parser";
|
||||
import { normalize } from "path/posix";
|
||||
import { parse } from "yaml";
|
||||
import { parse as parseYaml } from "yaml";
|
||||
|
||||
export abstract class AbstractVFS {
|
||||
textDecoder = new TextDecoder();
|
||||
@@ -11,24 +12,22 @@ export abstract class AbstractVFS {
|
||||
|
||||
abstract dispose(): void;
|
||||
|
||||
abstract has(path: string): boolean;
|
||||
abstract has(path: string): Promise<boolean>;
|
||||
|
||||
abstract raw(path: string): Promise<Uint8Array>;
|
||||
|
||||
abstract paths(): string[];
|
||||
|
||||
resolve(path: string) {
|
||||
async resolve(path: string) {
|
||||
const normalized = normalize(path);
|
||||
if (this.has(normalized)) return normalized;
|
||||
if (await this.has(normalized)) return normalized;
|
||||
|
||||
const dvplPath = `${normalized}.dvpl`;
|
||||
if (this.has(dvplPath)) return dvplPath;
|
||||
if (await this.has(dvplPath)) return dvplPath;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
assert(path: string) {
|
||||
const resolved = this.resolve(path);
|
||||
async assert(path: string) {
|
||||
const resolved = await this.resolve(path);
|
||||
|
||||
if (resolved === null) throw new Error(`File not found: ${path}`);
|
||||
|
||||
@@ -36,7 +35,7 @@ export abstract class AbstractVFS {
|
||||
}
|
||||
|
||||
async file(file: string) {
|
||||
const resolved = this.assert(file);
|
||||
const resolved = await this.assert(file);
|
||||
const raw = await this.raw(resolved);
|
||||
let buffer = raw;
|
||||
|
||||
@@ -47,21 +46,7 @@ export abstract class AbstractVFS {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
dir(path: string) {
|
||||
const parentSegments = path.split("/").length;
|
||||
const children = new Set<string>();
|
||||
|
||||
for (const child of this.paths()) {
|
||||
if (!child.startsWith(path) || child === path) continue;
|
||||
|
||||
const childSegments = child.split("/");
|
||||
const nextSegment = childSegments[parentSegments];
|
||||
|
||||
children.add(nextSegment);
|
||||
}
|
||||
|
||||
return Array.from(children);
|
||||
}
|
||||
abstract dir(path: string): Promise<string[]>;
|
||||
|
||||
async text(path: string) {
|
||||
const file = await this.file(path);
|
||||
@@ -70,7 +55,7 @@ export abstract class AbstractVFS {
|
||||
|
||||
async yaml<Type>(path: string) {
|
||||
const file = await this.text(path);
|
||||
return parse(file) as Type;
|
||||
return parseYaml(file) as Type;
|
||||
}
|
||||
|
||||
async xml<Type>(path: string) {
|
||||
@@ -78,6 +63,16 @@ export abstract class AbstractVFS {
|
||||
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]() {
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import { readdir } from "node:fs/promises";
|
||||
import { AbstractVFS } from "./abstract";
|
||||
|
||||
export class LocalVFS extends AbstractVFS {
|
||||
constructor(private base: string) {
|
||||
super();
|
||||
}
|
||||
|
||||
async init() {
|
||||
return this;
|
||||
}
|
||||
|
||||
async has(path: string) {
|
||||
const file = Bun.file(`${this.base}/${path}`);
|
||||
return await file.exists();
|
||||
}
|
||||
|
||||
async raw(path: string) {
|
||||
const file = Bun.file(`${this.base}/${path}`);
|
||||
const buffer = await file.arrayBuffer();
|
||||
const array = new Uint8Array(buffer);
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
async dir(path: string) {
|
||||
return await readdir(`${this.base}/${path}`);
|
||||
}
|
||||
|
||||
dispose() {}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ export class SteamVFS extends AbstractVFS {
|
||||
private username: string,
|
||||
private password: string,
|
||||
private app: number,
|
||||
private depot: number
|
||||
private depot: number,
|
||||
) {
|
||||
super();
|
||||
}
|
||||
@@ -57,13 +57,14 @@ export class SteamVFS extends AbstractVFS {
|
||||
this.steam.getManifest(
|
||||
this.app,
|
||||
this.depot,
|
||||
// @ts-expect-error
|
||||
productInfo.apps[this.app].appinfo.depots[this.depot].manifests.public
|
||||
.gid,
|
||||
"public",
|
||||
// @ts-expect-error
|
||||
(_, response) => {
|
||||
resolve(response);
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
@@ -75,7 +76,7 @@ export class SteamVFS extends AbstractVFS {
|
||||
return this;
|
||||
}
|
||||
|
||||
has(path: string) {
|
||||
async has(path: string) {
|
||||
return this.manifest.has(path);
|
||||
}
|
||||
|
||||
@@ -88,8 +89,20 @@ export class SteamVFS extends AbstractVFS {
|
||||
return new Uint8Array(downloaded.file);
|
||||
}
|
||||
|
||||
paths() {
|
||||
return Array.from(this.manifest.keys());
|
||||
async dir(path: string) {
|
||||
const parentSegments = path.split("/").length;
|
||||
const children = new Set<string>();
|
||||
|
||||
for (const child of this.manifest.keys()) {
|
||||
if (!child.startsWith(path) || child === path) continue;
|
||||
|
||||
const childSegments = child.split("/");
|
||||
const nextSegment = childSegments[parentSegments];
|
||||
|
||||
children.add(nextSegment);
|
||||
}
|
||||
|
||||
return Array.from(children);
|
||||
}
|
||||
|
||||
dispose() {
|
||||
|
||||
@@ -5,7 +5,10 @@ import { AbstractVFS } from "./abstract";
|
||||
export class ZipVFS extends AbstractVFS {
|
||||
entries = new Map<string, ZipEntry>();
|
||||
|
||||
constructor(private url: string, private root = "app/") {
|
||||
constructor(
|
||||
private url: string,
|
||||
private root = "app/",
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -21,7 +24,7 @@ export class ZipVFS extends AbstractVFS {
|
||||
return this;
|
||||
}
|
||||
|
||||
has(path: string) {
|
||||
async has(path: string) {
|
||||
return this.entries.has(path);
|
||||
}
|
||||
|
||||
@@ -30,8 +33,20 @@ export class ZipVFS extends AbstractVFS {
|
||||
return new Uint8Array(arrayBuffer);
|
||||
}
|
||||
|
||||
paths() {
|
||||
return Array.from(this.entries.keys());
|
||||
async dir(path: string) {
|
||||
const parentSegments = path.split("/").length;
|
||||
const children = new Set<string>();
|
||||
|
||||
for (const child of this.entries.keys()) {
|
||||
if (!child.startsWith(path) || child === path) continue;
|
||||
|
||||
const childSegments = child.split("/");
|
||||
const nextSegment = childSegments[parentSegments];
|
||||
|
||||
children.add(nextSegment);
|
||||
}
|
||||
|
||||
return Array.from(children);
|
||||
}
|
||||
|
||||
dispose() {}
|
||||
|
||||
@@ -53,7 +53,7 @@ if (newTanks.length > 0) {
|
||||
notes += "## New Tanks\n\n";
|
||||
|
||||
for (const tank of newTanks) {
|
||||
notes += `### [${tank.name.locales.en}](${domain}/tanks/${tank.slug})\n`;
|
||||
notes += `### [${tank.name!.locales.en}](${domain}/tanks/${tank.slug})\n`;
|
||||
notes += `})\n\n`;
|
||||
}
|
||||
|
||||
@@ -96,49 +96,49 @@ if (changedTanks.length > 0) {
|
||||
const previewTankModel = previewModelDefinitions.models[preview.id];
|
||||
|
||||
const currentConsumables = Object.values(
|
||||
currentConsumableDefinitions.consumables
|
||||
currentConsumableDefinitions.consumables,
|
||||
).filter((consumable) =>
|
||||
checkConsumableProvisionInclusivity(consumable, current, currentGun)
|
||||
checkConsumableProvisionInclusivity(consumable, current, currentGun),
|
||||
);
|
||||
const previewConsumables = Object.values(
|
||||
previewConsumableDefinitions.consumables
|
||||
previewConsumableDefinitions.consumables,
|
||||
).filter((consumable) =>
|
||||
checkConsumableProvisionInclusivity(consumable, preview, previewGun)
|
||||
checkConsumableProvisionInclusivity(consumable, preview, previewGun),
|
||||
);
|
||||
const addedConsumables = previewConsumables.filter(
|
||||
(previewConsumable) =>
|
||||
!currentConsumables.some(
|
||||
(currentConsumable) => currentConsumable.id === previewConsumable.id
|
||||
)
|
||||
(currentConsumable) => currentConsumable.id === previewConsumable.id,
|
||||
),
|
||||
);
|
||||
const removedConsumables = currentConsumables.filter(
|
||||
(currentConsumable) =>
|
||||
!previewConsumables.some(
|
||||
(previewConsumable) => previewConsumable.id === currentConsumable.id
|
||||
)
|
||||
(previewConsumable) => previewConsumable.id === currentConsumable.id,
|
||||
),
|
||||
);
|
||||
|
||||
const currentProvisions = availableProvisions(
|
||||
current,
|
||||
currentGun,
|
||||
currentProvisionDefinitions
|
||||
currentProvisionDefinitions,
|
||||
);
|
||||
const previewProvisions = availableProvisions(
|
||||
preview,
|
||||
previewGun,
|
||||
previewProvisionDefinitions
|
||||
previewProvisionDefinitions,
|
||||
);
|
||||
const addedProvisions = previewProvisions.filter(
|
||||
(previewProvision) =>
|
||||
!currentProvisions.some(
|
||||
(currentProvision) => currentProvision.id === previewProvision.id
|
||||
)
|
||||
(currentProvision) => currentProvision.id === previewProvision.id,
|
||||
),
|
||||
);
|
||||
const removedProvisions = currentProvisions.filter(
|
||||
(currentProvision) =>
|
||||
!previewProvisions.some(
|
||||
(previewProvision) => previewProvision.id === currentProvision.id
|
||||
)
|
||||
(previewProvision) => previewProvision.id === currentProvision.id,
|
||||
),
|
||||
);
|
||||
|
||||
const currentEquipment = currentEquipmentDefinitions.presets[
|
||||
@@ -155,19 +155,20 @@ if (changedTanks.length > 0) {
|
||||
.filter(
|
||||
(previewEquipment) =>
|
||||
!currentEquipment.some(
|
||||
(currentEquipment) => currentEquipment === previewEquipment
|
||||
)
|
||||
(currentEquipment) => currentEquipment === previewEquipment,
|
||||
),
|
||||
)
|
||||
.map((id) => previewEquipmentDefinitions.equipments[id]);
|
||||
const removedEquipment = currentEquipment
|
||||
.filter(
|
||||
(currentEquipment) =>
|
||||
!previewEquipment.some(
|
||||
(previewEquipment) => previewEquipment === currentEquipment
|
||||
)
|
||||
(previewEquipment) => previewEquipment === currentEquipment,
|
||||
),
|
||||
)
|
||||
.map((id) => currentEquipmentDefinitions.equipments[id]);
|
||||
|
||||
const equalize = false;
|
||||
const currentCharacteristics = tankCharacteristics(
|
||||
{
|
||||
tank: current,
|
||||
@@ -184,7 +185,7 @@ if (changedTanks.length > 0) {
|
||||
provisions: createDefaultProvisions(
|
||||
current,
|
||||
currentGun,
|
||||
currentProvisionDefinitions
|
||||
currentProvisionDefinitions,
|
||||
),
|
||||
equipmentMatrix: genericDefaultEquipmentMatrix,
|
||||
stockEngine: current.engines[0],
|
||||
@@ -193,12 +194,13 @@ if (changedTanks.length > 0) {
|
||||
stockTurret: current.turrets[0],
|
||||
track: currentTracks,
|
||||
turret: currentTurret,
|
||||
equalize,
|
||||
},
|
||||
{
|
||||
equipmentDefinitions: currentEquipmentDefinitions,
|
||||
provisionDefinitions: currentProvisionDefinitions,
|
||||
tankModelDefinition: currentTankModel,
|
||||
}
|
||||
},
|
||||
);
|
||||
const previewCharacteristics = tankCharacteristics(
|
||||
{
|
||||
@@ -216,7 +218,7 @@ if (changedTanks.length > 0) {
|
||||
provisions: createDefaultProvisions(
|
||||
preview,
|
||||
previewGun,
|
||||
previewProvisionDefinitions
|
||||
previewProvisionDefinitions,
|
||||
),
|
||||
equipmentMatrix: genericDefaultEquipmentMatrix,
|
||||
stockEngine: preview.engines[0],
|
||||
@@ -225,12 +227,13 @@ if (changedTanks.length > 0) {
|
||||
stockTurret: preview.turrets[0],
|
||||
track: previewTracks,
|
||||
turret: previewTurret,
|
||||
equalize,
|
||||
},
|
||||
{
|
||||
equipmentDefinitions: previewEquipmentDefinitions,
|
||||
provisionDefinitions: previewProvisionDefinitions,
|
||||
tankModelDefinition: previewTankModel,
|
||||
}
|
||||
},
|
||||
);
|
||||
const changedCharacteristics: string[] = [];
|
||||
|
||||
@@ -244,17 +247,17 @@ if (changedTanks.length > 0) {
|
||||
}
|
||||
}
|
||||
|
||||
notes += `### [${preview.name.locales.en}](${domain}/tanks/${preview.slug})\n`;
|
||||
notes += `### [${preview.name!.locales.en}](${domain}/tanks/${preview.slug})\n`;
|
||||
notes += `})\n\n`;
|
||||
|
||||
if (addedConsumables.length + removedConsumables.length > 0) {
|
||||
notes += `Consumables: `;
|
||||
notes += [
|
||||
...addedConsumables.map(
|
||||
(consumable) => `🟢 ${consumable.name.locales.en}`
|
||||
(consumable) => `🟢 ${consumable.name!.locales.en}`,
|
||||
),
|
||||
...removedConsumables.map(
|
||||
(consumable) => `🔴 ${consumable.name.locales.en}`
|
||||
(consumable) => `🔴 ${consumable.name!.locales.en}`,
|
||||
),
|
||||
].join(", ");
|
||||
notes += `\n`;
|
||||
@@ -264,10 +267,10 @@ if (changedTanks.length > 0) {
|
||||
notes += `Provisions: `;
|
||||
notes += [
|
||||
...addedProvisions.map(
|
||||
(provision) => `🟢 ${provision.name.locales.en}`
|
||||
(provision) => `🟢 ${provision.name!.locales.en}`,
|
||||
),
|
||||
...removedProvisions.map(
|
||||
(provision) => `🔴 ${provision.name.locales.en}`
|
||||
(provision) => `🔴 ${provision.name!.locales.en}`,
|
||||
),
|
||||
].join(", ");
|
||||
notes += `\n`;
|
||||
@@ -276,9 +279,11 @@ if (changedTanks.length > 0) {
|
||||
if (addedEquipment.length + removedEquipment.length > 0) {
|
||||
notes += `-Equipment: `;
|
||||
notes += [
|
||||
...addedEquipment.map((equipment) => `🟢 ${equipment.name.locales.en}`),
|
||||
...addedEquipment.map(
|
||||
(equipment) => `🟢 ${equipment.name!.locales.en}`,
|
||||
),
|
||||
...removedEquipment.map(
|
||||
(equipment) => `🔴 ${equipment.name.locales.en}`
|
||||
(equipment) => `🔴 ${equipment.name!.locales.en}`,
|
||||
),
|
||||
].join(", ");
|
||||
notes += `\n`;
|
||||
|
||||
@@ -26,8 +26,8 @@ for (const location of TS_PROTO_EXECUTABLE_LOCATIONS) {
|
||||
if (!tsProtoExecutableLocation) {
|
||||
throw new Error(
|
||||
`Could not find ts-proto executable. Checked locations: ${TS_PROTO_EXECUTABLE_LOCATIONS.join(
|
||||
", "
|
||||
)}`
|
||||
", ",
|
||||
)}`,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
Video,
|
||||
youtubers,
|
||||
} from "@blitzkit/core";
|
||||
import locales from "@blitzkit/i18n/locales.json";
|
||||
import { google } from "googleapis";
|
||||
import { cloneDeep, uniqBy } from "lodash-es";
|
||||
import { AssetUploader } from "./core/github/assetUploader";
|
||||
@@ -42,9 +43,11 @@ for (const tank of tanksSanitized) {
|
||||
}
|
||||
|
||||
try {
|
||||
const q = `World of Tanks Blitz ${tank.name!.locales[locales.default]}`;
|
||||
|
||||
const results = await youtube.search.list({
|
||||
part: ["snippet"],
|
||||
q: `World of Tanks Blitz ${tank.name}`,
|
||||
q,
|
||||
});
|
||||
|
||||
if (!results.data.items || results.data.items.length === 0) continue;
|
||||
@@ -54,9 +57,9 @@ for (const tank of tanksSanitized) {
|
||||
(item) =>
|
||||
item.snippet?.channelId &&
|
||||
item.id?.videoId &&
|
||||
youtubers.some(({ id }) => id === item.snippet?.channelId)
|
||||
youtubers.some(({ id }) => id === item.snippet?.channelId),
|
||||
),
|
||||
(item) => item.snippet!.channelId
|
||||
(item) => item.snippet!.channelId,
|
||||
);
|
||||
|
||||
reviews.reviews[tank.id] = {
|
||||
@@ -66,11 +69,13 @@ for (const tank of tanksSanitized) {
|
||||
({
|
||||
id: item.id!.videoId!,
|
||||
author: item.snippet!.channelId!,
|
||||
} satisfies Video)
|
||||
}) satisfies Video,
|
||||
),
|
||||
};
|
||||
|
||||
console.log(`${++done} done; found ${items.length} for ${tank.name.locales.en}`);
|
||||
console.log(
|
||||
`${++done} done; found ${items.length} for ${tank.name!.locales.en}`,
|
||||
);
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000 / 5));
|
||||
} catch (error) {
|
||||
|
||||
Reference in new issue
Block a user