equipment data

This commit is contained in:
tresabhi committed 2026-05-17 12:56:23 -05:00
1 parent f95a6e3495
commit c45af8e156
8 files changed
+70 -34

No files matched your search

@@ -7,6 +7,7 @@ const TARGET = "../../packages/closed/src/unreal/catalogItemAccessor.ts";
const componentPattern = /^export interface (\w+Component) {/gm; const componentPattern = /^export interface (\w+Component) {/gm;
const componentSuffixPattern = /Component$/; const componentSuffixPattern = /Component$/;
const tsSuffixPattern = /\.ts$/; const tsSuffixPattern = /\.ts$/;
const blitzStaticPrefixPattern = /^BlitzStatic/;
let imports = ""; let imports = "";
let methods = ""; let methods = "";
@@ -23,10 +24,9 @@ for (const file of files) {
for (const match of matches) { for (const match of matches) {
const interfaceName = match[1]; const interfaceName = match[1];
const componentName = interfaceName.split("_").at(-1)!; const componentName = interfaceName.split("_").at(-1)!;
const fieldName = lowerFirst(
if (componentName.startsWith("BlitzStatic")) continue; componentName.replace(blitzStaticPrefixPattern, ""),
);
const fieldName = lowerFirst(componentName);
const methodName = componentName.replace(componentSuffixPattern, ""); const methodName = componentName.replace(componentSuffixPattern, "");
const importName = file.replace(tsSuffixPattern, ""); const importName = file.replace(tsSuffixPattern, "");
+2
View File
@@ -7,6 +7,7 @@ import type { Avatars } from "@protos/avatars";
import type { Background } from "@protos/background"; import type { Background } from "@protos/background";
import type { Backgrounds } from "@protos/backgrounds"; import type { Backgrounds } from "@protos/backgrounds";
import type { TankUpgradePricePresetComponent } from "@protos/blitz_static_tank_upgrade_price_preset_component"; import type { TankUpgradePricePresetComponent } from "@protos/blitz_static_tank_upgrade_price_preset_component";
import type { Equipment } from "@protos/equipment";
import type { PopularTanks } from "@protos/popular_tanks"; import type { PopularTanks } from "@protos/popular_tanks";
import type { Tank } from "@protos/tank"; import type { Tank } from "@protos/tank";
import type { TankList } from "@protos/tank_list"; import type { TankList } from "@protos/tank_list";
@@ -25,6 +26,7 @@ export abstract class AbstractAPI {
): Promise<TankUpgradePricePresetComponent>; ): Promise<TankUpgradePricePresetComponent>;
abstract tiers(): Promise<Tiers>; abstract tiers(): Promise<Tiers>;
abstract equipment(): Promise<Equipment>;
abstract strings(locale: string): Promise<Strings>; abstract strings(locale: string): Promise<Strings>;
abstract gameStrings(locale: string): Promise<Record<string, string>>; abstract gameStrings(locale: string): Promise<Record<string, string>>;
+20 -7
View File
@@ -2,13 +2,16 @@ import { fetchPB } from "@blitzkit/core";
import type { Strings } from "@blitzkit/i18n"; import type { Strings } from "@blitzkit/i18n";
import { Avatars } from "@protos/avatars"; import { Avatars } from "@protos/avatars";
import { TankUpgradePricePresetComponent } from "@protos/blitz_static_tank_upgrade_price_preset_component"; import { TankUpgradePricePresetComponent } from "@protos/blitz_static_tank_upgrade_price_preset_component";
import { Equipment } from "@protos/equipment";
import { PopularTanks } from "@protos/popular_tanks"; import { PopularTanks } from "@protos/popular_tanks";
import { TankList } from "@protos/tank_list"; import { TankList } from "@protos/tank_list";
import { Tanks } from "@protos/tanks"; import { Tanks } from "@protos/tanks";
import { Tiers } from "@protos/tiers"; import { Tiers } from "@protos/tiers";
import { AbstractAPI, Cache } from "./abstract"; import { AbstractAPI, Cache } from "./abstract";
const rejected = Promise.reject("Not implemented on client"); function rejected() {
return Promise.reject("Not implemented on client");
}
export class ClientAPI extends AbstractAPI { export class ClientAPI extends AbstractAPI {
get metadata(): never { get metadata(): never {
@@ -49,6 +52,11 @@ export class ClientAPI extends AbstractAPI {
return fetchPB("/api/tiers.pb", Tiers); return fetchPB("/api/tiers.pb", Tiers);
} }
@Cache()
equipment() {
return fetchPB("/api/equipment.pb", Equipment);
}
@Cache() @Cache()
async strings(locale: string) { async strings(locale: string) {
const response = await fetch(`/api/strings/${locale}.json`); const response = await fetch(`/api/strings/${locale}.json`);
@@ -59,7 +67,7 @@ export class ClientAPI extends AbstractAPI {
@UnimplementedOnClient @UnimplementedOnClient
gameStrings() { gameStrings() {
return rejected; return rejected();
} }
@Cache() @Cache()
@@ -72,12 +80,12 @@ export class ClientAPI extends AbstractAPI {
@UnimplementedOnClient @UnimplementedOnClient
gameStringGroups() { gameStringGroups() {
return rejected; return rejected();
} }
@UnimplementedOnClient @UnimplementedOnClient
avatar() { avatar() {
return rejected; return rejected();
} }
avatars() { avatars() {
@@ -86,17 +94,22 @@ export class ClientAPI extends AbstractAPI {
@UnimplementedOnClient @UnimplementedOnClient
avatarList() { avatarList() {
return rejected; return rejected();
} }
@UnimplementedOnClient @UnimplementedOnClient
background() { background() {
return rejected; return rejected();
} }
@UnimplementedOnClient @UnimplementedOnClient
backgrounds() { backgrounds() {
return rejected; return rejected();
}
@UnimplementedOnClient
currencyIcon() {
return rejected();
} }
} }
+20
View File
@@ -5,6 +5,7 @@ import locales from "@blitzkit/i18n/locales.json";
import type { Avatar, DeepPartial } from "@protos/avatar"; import type { Avatar, DeepPartial } from "@protos/avatar";
import type { Background } from "@protos/background"; import type { Background } from "@protos/background";
import type { RemoteStorageComponent } from "@protos/blitz_static_remote_storage_component"; import type { RemoteStorageComponent } from "@protos/blitz_static_remote_storage_component";
import { Equipment } from "@protos/equipment";
import type { PopularTanks } from "@protos/popular_tanks"; import type { PopularTanks } from "@protos/popular_tanks";
import type { Tank } from "@protos/tank"; import type { Tank } from "@protos/tank";
import type { TankListEntry } from "@protos/tank_list"; import type { TankListEntry } from "@protos/tank_list";
@@ -226,6 +227,25 @@ export class ServerAPI extends AbstractAPI {
return tiers; return tiers;
} }
@Cache()
async equipment() {
const equipment = Equipment.create();
for (const item of this.metadata.group("EquipmentPresetEntity")) {
equipment.presets[item.name] = item.EquipmentPreset();
}
for (const item of this.metadata.group("EquipmentPricePresetEntity")) {
equipment.prices[item.name] = item.EquipmentPricePreset();
}
for (const item of this.metadata.group("EquipmentEntity")) {
equipment.equipments[item.name] = item.BlitzStaticEquipment();
}
return equipment;
}
@Cache(true) @Cache(true)
async strings(locale: string) { async strings(locale: string) {
const localized = (await globbedStrings[ const localized = (await globbedStrings[
@@ -10,6 +10,7 @@ import {
isAlternativeLine, isAlternativeLine,
originalLineName, originalLineName,
} from "../../config/alternativeLines"; } from "../../config/alternativeLines";
import { useEquipment } from "../../hooks/useEquipment";
import { useProtagonist } from "../../hooks/useProtagonist"; import { useProtagonist } from "../../hooks/useProtagonist";
import { useStrings } from "../../hooks/useStrings"; import { useStrings } from "../../hooks/useStrings";
import { useUpgradePreset } from "../../hooks/useUpgradePreset"; import { useUpgradePreset } from "../../hooks/useUpgradePreset";
@@ -34,19 +35,16 @@ export function TankopediaLoadout() {
function Equipment() { function Equipment() {
const strings = useStrings(); const strings = useStrings();
const tank = useProtagonist(); const tank = useProtagonist();
// const equipment = useEquipment( const equipment = useEquipment(
// tank.tank!.equipment_preset_catalog_id, tank.tank!.equipment_preset_catalog_id,
// tank.tank!.equipment_price_preset_catalog_id, tank.tank!.equipment_price_preset_catalog_id,
// ); );
return ( return (
<div className={styles.section}> <div className={styles.section}>
<div className={styles.header}> <div className={styles.header}>
<Heading size="4">{strings.tanks.loadout.equipment}</Heading> <Heading size="4">{strings.tanks.loadout.equipment}</Heading>
</div> </div>
preset: {tank.tank!.equipment_preset_catalog_id}
<br />
price: {tank.tank!.equipment_price_preset_catalog_id}
</div> </div>
); );
} }
+11 -15
View File
@@ -1,17 +1,13 @@
import { api } from "../api/dynamic";
import { useAwait } from "./useAwait";
export function useEquipment(presetId: string, priceId: string) { export function useEquipment(presetId: string, priceId: string) {
const [, presetName] = presetId.split("."); // const [, presetName] = presetId.split(".");
const [, priceName] = priceId.split("."); // const [, priceName] = priceId.split(".");
const preset = useAwait( // const preset = useAwait(
() => api.equipmentPreset(presetId), // () => api.equipmentPreset(presetName),
`equipment-preset-${presetName}`, // `equipment-preset-${presetName}`,
); // );
const price = useAwait( // const price = useAwait(
() => api.equipmentPricePreset(priceId), // () => api.equipmentPrice(priceName),
`equipment-price-${priceName}`, // `equipment-price-${priceName}`,
); // );
// return { preset, price };
return { preset, price };
} }
@@ -0,0 +1,7 @@
import { Equipment } from "@protos/equipment";
import { api } from "../../api/dynamic";
export async function GET() {
const equipment = await api.equipment();
return new Response(Equipment.encode(equipment).finish());
}