mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
equipment data
This commit is contained in:
1 parent
f95a6e3495
commit
c45af8e156
8 files changed
+70
-34
No files matched your search
@@ -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>>;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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[
|
||||
|
||||
Reference in new issue
Block a user