mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
use prefixed ids
This commit is contained in:
1 parent
b81d9985ee
commit
676601b06e
9 files changed
+38
-37
No files matched your search
+1
-1
Submodule packages/closed updated: c2175a1520...58840ed37f.
@@ -6,11 +6,11 @@ import type { AvatarList } from "@protos/avatar_list";
|
||||
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";
|
||||
import type { TankUpgradePresets } from "@protos/tank_upgrade_presets";
|
||||
import type { Tanks } from "@protos/tanks";
|
||||
import type { Tiers } from "@protos/tiers";
|
||||
|
||||
@@ -23,9 +23,7 @@ export abstract class AbstractAPI {
|
||||
abstract tank(id: string): Promise<Tank>;
|
||||
abstract tanks(): Promise<Tanks>;
|
||||
abstract popularTanks(): Promise<PopularTanks>;
|
||||
abstract tankUpgradePreset(
|
||||
name: string,
|
||||
): Promise<TankUpgradePricePresetComponent>;
|
||||
abstract tankUpgradePresets(): Promise<TankUpgradePresets>;
|
||||
|
||||
abstract tiers(): Promise<Tiers>;
|
||||
abstract equipment(): Promise<Equipment>;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
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 { TankUpgradePresets } from "@protos/tank_upgrade_presets";
|
||||
import { Tanks } from "@protos/tanks";
|
||||
import { Tiers } from "@protos/tiers";
|
||||
import { AbstractAPI, Cache } from "./abstract";
|
||||
@@ -45,11 +45,8 @@ export class ClientAPI extends AbstractAPI {
|
||||
}
|
||||
|
||||
@Cache()
|
||||
tankUpgradePreset(name: string) {
|
||||
return fetchPB(
|
||||
`/api/tanks/presets/upgrade/${name}.pb`,
|
||||
TankUpgradePricePresetComponent,
|
||||
);
|
||||
tankUpgradePresets() {
|
||||
return fetchPB(`/api/tanks/upgrades.pb`, TankUpgradePresets);
|
||||
}
|
||||
|
||||
@Cache()
|
||||
|
||||
@@ -9,6 +9,7 @@ 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";
|
||||
import { TankUpgradePresets } from "@protos/tank_upgrade_presets";
|
||||
import type { Tanks } from "@protos/tanks";
|
||||
import type { Tiers } from "@protos/tiers";
|
||||
import { existsSync } from "fs";
|
||||
@@ -95,10 +96,9 @@ export class ServerAPI extends AbstractAPI {
|
||||
|
||||
if (!name) continue;
|
||||
|
||||
const id = item.name;
|
||||
const slug = sluggify(name);
|
||||
|
||||
list.push({ id, slug });
|
||||
list.push({ id: item.id, slug });
|
||||
}
|
||||
|
||||
return { list };
|
||||
@@ -114,7 +114,7 @@ export class ServerAPI extends AbstractAPI {
|
||||
}
|
||||
|
||||
const { slug } = tankListEntry;
|
||||
const item = this.metadata.item(`TankEntity.${id}`);
|
||||
const item = this.metadata.item(id);
|
||||
const tank = item.TankCatalog();
|
||||
const compensation = item.Compensation();
|
||||
|
||||
@@ -220,9 +220,15 @@ export class ServerAPI extends AbstractAPI {
|
||||
}
|
||||
|
||||
@Cache()
|
||||
async tankUpgradePreset(id: string) {
|
||||
const item = this.metadata.item(`TankUpgradePricePresetEntity.${id}`);
|
||||
return item.TankUpgradePricePreset();
|
||||
async tankUpgradePresets() {
|
||||
const group = this.metadata.group("TankUpgradePricePresetEntity");
|
||||
const presets = TankUpgradePresets.create();
|
||||
|
||||
for (const item of group) {
|
||||
presets.presets[item.id] = item.TankUpgradePricePreset();
|
||||
}
|
||||
|
||||
return presets;
|
||||
}
|
||||
|
||||
@Cache()
|
||||
@@ -231,7 +237,7 @@ export class ServerAPI extends AbstractAPI {
|
||||
const tiers: Tiers = { tiers: {} };
|
||||
|
||||
for (const item of group) {
|
||||
tiers.tiers[item.name] = item.TankTier();
|
||||
tiers.tiers[item.id] = item.TankTier();
|
||||
}
|
||||
|
||||
return tiers;
|
||||
@@ -332,7 +338,7 @@ export class ServerAPI extends AbstractAPI {
|
||||
|
||||
@Cache()
|
||||
async avatar(id: string) {
|
||||
const avatar = this.metadata.item(`ProfileAvatarEntity.${id}`);
|
||||
const avatar = this.metadata.item(id);
|
||||
const name = avatar.name;
|
||||
const stuff_ui = avatar.StuffUI("UIComponent");
|
||||
const profile_avatar = avatar.ProfileAvatar();
|
||||
@@ -348,7 +354,7 @@ export class ServerAPI extends AbstractAPI {
|
||||
const avatars: Avatar[] = [];
|
||||
|
||||
for (const item of this.metadata.group("ProfileAvatarEntity")) {
|
||||
avatars.push(await this.avatar(item.name));
|
||||
avatars.push(await this.avatar(item.id));
|
||||
}
|
||||
|
||||
return { avatars };
|
||||
@@ -364,7 +370,7 @@ export class ServerAPI extends AbstractAPI {
|
||||
|
||||
@Cache()
|
||||
async background(id: string) {
|
||||
const background = this.metadata.item(`ProfileBackgroundEntity.${id}`);
|
||||
const background = this.metadata.item(id);
|
||||
const name = background.name;
|
||||
const stuff_ui = background.StuffUI("UIComponent");
|
||||
const profile_background = background.ProfileBackground();
|
||||
|
||||
@@ -5,11 +5,8 @@ export function useTierCompare() {
|
||||
const tiers = useAwait(() => api.tiers(), "tiers");
|
||||
|
||||
function compare(a: string, b: string) {
|
||||
const [, tierNameA] = a.split(".");
|
||||
const [, tierNameB] = b.split(".");
|
||||
const tierA = tiers.tiers[tierNameA];
|
||||
const tierB = tiers.tiers[tierNameB];
|
||||
|
||||
const tierA = tiers.tiers[a];
|
||||
const tierB = tiers.tiers[b];
|
||||
return tierB.carousel_level - tierA.carousel_level;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,10 @@ import { api } from "../api/dynamic";
|
||||
import { useAwait } from "./useAwait";
|
||||
|
||||
export function useUpgradePreset(name: string) {
|
||||
const [, discriminator] = name.split(".");
|
||||
const preset = useAwait(
|
||||
() => api.tankUpgradePreset(discriminator),
|
||||
`tank-upgrade-preset-${discriminator}`,
|
||||
const presets = useAwait(
|
||||
() => api.tankUpgradePresets(),
|
||||
"tank-upgrade-presets",
|
||||
);
|
||||
|
||||
return preset;
|
||||
return presets.presets[name];
|
||||
}
|
||||
@@ -9,8 +9,3 @@ export const getStaticPaths = mixStaticPaths(_getStaticPaths, async () => {
|
||||
.group("TankUpgradePricePresetEntity")
|
||||
.map(({ name }) => ({ params: { id: name } }));
|
||||
});
|
||||
|
||||
export async function GET({ params }: APIContext<never, { id: string }>) {
|
||||
const preset = await api.tankUpgradePreset(params.id);
|
||||
return new Response(TankUpgradePricePresetComponent.encode(preset).finish());
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { TankUpgradePresets } from "@protos/tank_upgrade_presets";
|
||||
import { api } from "../../../api/dynamic";
|
||||
|
||||
export { getStaticPaths } from "../_index";
|
||||
|
||||
export async function GET() {
|
||||
const preset = await api.tankUpgradePresets();
|
||||
return new Response(TankUpgradePresets.encode(preset).finish());
|
||||
}
|
||||
@@ -71,7 +71,7 @@ export const characteristicsOrder: CharacteristicsOrder = [
|
||||
{
|
||||
name: "tier",
|
||||
render({ output, strings }) {
|
||||
const [, name] = (output as string).split(".");
|
||||
const name = output as string;
|
||||
|
||||
if (name == "vintage") {
|
||||
return <VintageIcon />;
|
||||
|
||||
Reference in new issue
Block a user