mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
module price rendering
This commit is contained in:
1 parent
6d2573ee95
commit
f0e0d849d5
12 files changed
+269
-91
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import type { MetadataAccessor } from "@blitzkit/closed";
|
||||
import type { Strings } from "@blitzkit/i18n";
|
||||
import locales from "@blitzkit/i18n/locales.json";
|
||||
import type { Avatar } from "@protos/blitzkit/avatar";
|
||||
@@ -10,12 +11,18 @@ import type { Tank } from "@protos/blitzkit/tank";
|
||||
import type { TankList } from "@protos/blitzkit/tank_list";
|
||||
import type { Tanks } from "@protos/blitzkit/tanks";
|
||||
import type { Tiers } from "@protos/blitzkit/tiers";
|
||||
import type { TankUpgradePricePresetComponent } from "@protos/game/proto/legacy/blitz_static_tank_upgrade_price_preset_component";
|
||||
|
||||
export abstract class AbstractAPI {
|
||||
abstract metadata: MetadataAccessor;
|
||||
|
||||
abstract tankList(): Promise<TankList>;
|
||||
abstract tank(id: string): Promise<Tank>;
|
||||
abstract tanks(): Promise<Tanks>;
|
||||
abstract popularTanks(): Promise<PopularTanks>;
|
||||
abstract tankUpgradePreset(
|
||||
name: string,
|
||||
): Promise<TankUpgradePricePresetComponent>;
|
||||
|
||||
abstract tiers(): Promise<Tiers>;
|
||||
|
||||
|
||||
@@ -5,11 +5,16 @@ import { PopularTanks } from "@protos/blitzkit/popular_tanks";
|
||||
import { TankList } from "@protos/blitzkit/tank_list";
|
||||
import { Tanks } from "@protos/blitzkit/tanks";
|
||||
import { Tiers } from "@protos/blitzkit/tiers";
|
||||
import { TankUpgradePricePresetComponent } from "@protos/game/proto/legacy/blitz_static_tank_upgrade_price_preset_component";
|
||||
import { AbstractAPI, Cache } from "./abstract";
|
||||
|
||||
const rejected = Promise.reject("Not implemented on client");
|
||||
|
||||
export class ClientAPI extends AbstractAPI {
|
||||
get metadata(): never {
|
||||
throw new Error("MetadataAccessor is inaccessible on the client");
|
||||
}
|
||||
|
||||
@Cache()
|
||||
tankList() {
|
||||
return fetchPB("/api/tanks/list.pb", TankList);
|
||||
@@ -31,6 +36,14 @@ export class ClientAPI extends AbstractAPI {
|
||||
return fetchPB("/api/tanks/popular.pb", PopularTanks);
|
||||
}
|
||||
|
||||
@Cache()
|
||||
tankUpgradePreset(name: string) {
|
||||
return fetchPB(
|
||||
`/api/tanks/presets/upgrade/${name}.pb`,
|
||||
TankUpgradePricePresetComponent,
|
||||
);
|
||||
}
|
||||
|
||||
@Cache()
|
||||
tiers() {
|
||||
return fetchPB("/api/tiers.pb", Tiers);
|
||||
|
||||
@@ -31,7 +31,7 @@ interface LocalizationConfig {
|
||||
}
|
||||
|
||||
export class ServerAPI extends AbstractAPI {
|
||||
constructor(private metadata: MetadataAccessor) {
|
||||
constructor(public metadata: MetadataAccessor) {
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -174,6 +174,12 @@ export class ServerAPI extends AbstractAPI {
|
||||
return JSON.parse(data) as PopularTanks;
|
||||
}
|
||||
|
||||
@Cache()
|
||||
async tankUpgradePreset(id: string) {
|
||||
const item = this.metadata.item(`TankUpgradePricePresetEntity.${id}`);
|
||||
return item.TankUpgradePricePreset();
|
||||
}
|
||||
|
||||
@Cache()
|
||||
async tiers() {
|
||||
const group = this.metadata.group("TankTierEntity");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { TankCatalogComponent } from "@blitzkit/closed/protos/game/proto/legacy/blitz_static_tank_component";
|
||||
import { StandardSinglePrice } from "@protos/game/proto/legacy/blitz_static_standard_single_price";
|
||||
import type { TankCatalogComponent } from "@protos/game/proto/legacy/blitz_static_tank_component";
|
||||
import { PenetrationGroup } from "@protos/game/proto/legacy/blitz_static_tank_penetration_group";
|
||||
import {
|
||||
ModuleUpgrade,
|
||||
|
||||
Reference in new issue
Block a user