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 componentSuffixPattern = /Component$/;
const tsSuffixPattern = /\.ts$/;
const blitzStaticPrefixPattern = /^BlitzStatic/;
let imports = "";
let methods = "";
@@ -23,10 +24,9 @@ for (const file of files) {
for (const match of matches) {
const interfaceName = match[1];
const componentName = interfaceName.split("_").at(-1)!;
if (componentName.startsWith("BlitzStatic")) continue;
const fieldName = lowerFirst(componentName);
const fieldName = lowerFirst(
componentName.replace(blitzStaticPrefixPattern, ""),
);
const methodName = componentName.replace(componentSuffixPattern, "");
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 { Backgrounds } from "@protos/backgrounds";
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 { Tank } from "@protos/tank";
import type { TankList } from "@protos/tank_list";
@@ -25,6 +26,7 @@ export abstract class AbstractAPI {
): Promise<TankUpgradePricePresetComponent>;
abstract tiers(): Promise<Tiers>;
abstract equipment(): Promise<Equipment>;
abstract strings(locale: string): Promise<Strings>;
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 { Avatars } from "@protos/avatars";
import { TankUpgradePricePresetComponent } from "@protos/blitz_static_tank_upgrade_price_preset_component";
import { Equipment } from "@protos/equipment";
import { PopularTanks } from "@protos/popular_tanks";
import { TankList } from "@protos/tank_list";
import { Tanks } from "@protos/tanks";
import { Tiers } from "@protos/tiers";
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 {
get metadata(): never {
@@ -49,6 +52,11 @@ export class ClientAPI extends AbstractAPI {
return fetchPB("/api/tiers.pb", Tiers);
}
@Cache()
equipment() {
return fetchPB("/api/equipment.pb", Equipment);
}
@Cache()
async strings(locale: string) {
const response = await fetch(`/api/strings/${locale}.json`);
@@ -59,7 +67,7 @@ export class ClientAPI extends AbstractAPI {
@UnimplementedOnClient
gameStrings() {
return rejected;
return rejected();
}
@Cache()
@@ -72,12 +80,12 @@ export class ClientAPI extends AbstractAPI {
@UnimplementedOnClient
gameStringGroups() {
return rejected;
return rejected();
}
@UnimplementedOnClient
avatar() {
return rejected;
return rejected();
}
avatars() {
@@ -86,17 +94,22 @@ export class ClientAPI extends AbstractAPI {
@UnimplementedOnClient
avatarList() {
return rejected;
return rejected();
}
@UnimplementedOnClient
background() {
return rejected;
return rejected();
}
@UnimplementedOnClient
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 { Background } from "@protos/background";
import type { RemoteStorageComponent } from "@protos/blitz_static_remote_storage_component";
import { Equipment } from "@protos/equipment";
import type { PopularTanks } from "@protos/popular_tanks";
import type { Tank } from "@protos/tank";
import type { TankListEntry } from "@protos/tank_list";
@@ -226,6 +227,25 @@ export class ServerAPI extends AbstractAPI {
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)
async strings(locale: string) {
const localized = (await globbedStrings[
@@ -10,6 +10,7 @@ import {
isAlternativeLine,
originalLineName,
} from "../../config/alternativeLines";
import { useEquipment } from "../../hooks/useEquipment";
import { useProtagonist } from "../../hooks/useProtagonist";
import { useStrings } from "../../hooks/useStrings";
import { useUpgradePreset } from "../../hooks/useUpgradePreset";
@@ -34,19 +35,16 @@ export function TankopediaLoadout() {
function Equipment() {
const strings = useStrings();
const tank = useProtagonist();
// const equipment = useEquipment(
// tank.tank!.equipment_preset_catalog_id,
// tank.tank!.equipment_price_preset_catalog_id,
// );
const equipment = useEquipment(
tank.tank!.equipment_preset_catalog_id,
tank.tank!.equipment_price_preset_catalog_id,
);
return (
<div className={styles.section}>
<div className={styles.header}>
<Heading size="4">{strings.tanks.loadout.equipment}</Heading>
</div>
preset: {tank.tank!.equipment_preset_catalog_id}
<br />
price: {tank.tank!.equipment_price_preset_catalog_id}
</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) {
const [, presetName] = presetId.split(".");
const [, priceName] = priceId.split(".");
const preset = useAwait(
() => api.equipmentPreset(presetId),
`equipment-preset-${presetName}`,
);
const price = useAwait(
() => api.equipmentPricePreset(priceId),
`equipment-price-${priceName}`,
);
return { preset, price };
// const [, presetName] = presetId.split(".");
// const [, priceName] = priceId.split(".");
// const preset = useAwait(
// () => api.equipmentPreset(presetName),
// `equipment-preset-${presetName}`,
// );
// const price = useAwait(
// () => api.equipmentPrice(priceName),
// `equipment-price-${priceName}`,
// );
// 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());
}