update (1)

This commit is contained in:
tresabhi committed 2026-08-01 14:44:23 -05:00
1 parent 2dc23ba09d
commit 32a7db238b
10 files changed
+81 -33

No files matched your search

+59
View File
@@ -2,6 +2,7 @@ import {
AbstractVFS,
Armor,
AssaultRanges,
AvailableNationsYaml,
BlitzCrewType,
BlitzModuleType,
BlitzStrings,
@@ -22,6 +23,7 @@ import {
Equalizer,
EquipmentDefinitions,
EquipmentSlot,
GameDefinitions,
GunDefinition,
GunDefinitionsList,
I18nString,
@@ -188,6 +190,11 @@ export class ServerBlitzKitAPI extends BlitzKitAPI {
);
console.log("Fetching game localizations...");
if (import.meta.env.DEV) {
locales.supported = [locales.supported[0]];
}
let fetchedLocalizations = 0;
await Promise.all(
locales.supported.map(async ({ locale }) => {
@@ -1589,6 +1596,58 @@ export class ServerBlitzKitAPI extends BlitzKitAPI {
return skillDefinitions;
}
@Cache()
async gameDefinitions() {
const gameDefinitions = GameDefinitions.create();
const consumableNativeNames: Record<string, number> = {};
const provisionNativeNames: Record<string, number> = {};
Object.entries(this.consumablesCommon).forEach(([key, consumable]) => {
consumableNativeNames[key] = consumable.id;
});
Object.entries(this.provisionsCommon).forEach(([key, provision]) => {
provisionNativeNames[key] = provision.id;
});
const version = (await this.vfs.text("Data/version.txt")).split(" ")[0];
gameDefinitions.version = version;
gameDefinitions.nations = (
await this.vfs.yaml<AvailableNationsYaml>("Data/available_nations.yaml")
).available_nations;
for (const match of this.squadBattleTypeStyles!.Prototypes[0].components.UIDataLocalBindingsComponent.data[1][2].matchAll(
/"(\d+)" -> "(battleType\/([a-zA-Z]+))"/g,
)) {
const id = Number(match[1]);
const name = this.getString(match[2]);
gameDefinitions.gameModes[id] = {
name,
};
}
Object.entries(this.combatRoles!).forEach(([, value]) => {
gameDefinitions.roles[value.id] = { provisions: [], consumables: [] };
value.default_abilities.forEach((ability) => {
if (ability in consumableNativeNames) {
gameDefinitions.roles[value.id].consumables.push(
consumableNativeNames[ability],
);
} else if (ability in provisionNativeNames) {
gameDefinitions.roles[value.id].provisions.push(
provisionNativeNames[ability],
);
} else throw new Error(`Unknown ability ${ability}`);
});
});
return gameDefinitions;
}
}
export function Cache(disableInDev = false) {
-5
View File
@@ -1,5 +0,0 @@
import { assertSecret } from "./assertSecret";
export function asset(path: string) {
return `${assertSecret(import.meta.env.PUBLIC_ASSET_BASE)}/${path}`;
}
@@ -1,6 +1,6 @@
import { fetchPB } from '../../protobuf';
import { AverageDefinitions } from '../../protos';
import { asset } from '../asset';
import { staticAsset } from "@blitzkit/core";
import { fetchPB } from "../../protobuf";
import { AverageDefinitions } from "../../protos";
export interface AverageDefinitionsManifest {
version: 1;
@@ -11,13 +11,7 @@ export interface AverageDefinitionsManifest {
}
export async function fetchAverageDefinitions() {
const manifestResponse = await fetch(asset('averages/manifest.json'));
const manifestJson =
(await manifestResponse.json()) as AverageDefinitionsManifest;
return await fetchPB(
asset(`averages/${manifestJson.latest}.pb`),
AverageDefinitions,
);
return await fetchPB(staticAsset("averages.pb"), AverageDefinitions);
}
export * from './constants';
export * from "./constants";
+1 -1
View File
@@ -1,5 +1,4 @@
export * from "./assertSecret";
export * from "./asset";
export * from "./availableProvisions";
export * from "./averageDefinitions";
// export * from './camouflageDefinitions';
@@ -16,6 +15,7 @@ export * from "./equipmentDefinitions";
export * from "./eventManager";
export * from "./getArchivedLatestSeasonNumber";
export * from "./sluggify";
export * from "./staticAsset";
export * from "./vfs";
// export * from './getArchivedRatingInfo';
export * from "./getArchivedRatingLeaderboard";
@@ -0,0 +1,5 @@
import { assertSecret } from "./assertSecret";
export function staticAsset(path: string) {
return `${assertSecret(import.meta.env.PUBLIC_STATIC_ASSET_BASE)}/${path}`;
}