mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +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 { 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 { Equipment } from "@protos/equipment";
|
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";
|
||||||
|
import type { TankUpgradePresets } from "@protos/tank_upgrade_presets";
|
||||||
import type { Tanks } from "@protos/tanks";
|
import type { Tanks } from "@protos/tanks";
|
||||||
import type { Tiers } from "@protos/tiers";
|
import type { Tiers } from "@protos/tiers";
|
||||||
|
|
||||||
@@ -23,9 +23,7 @@ export abstract class AbstractAPI {
|
|||||||
abstract tank(id: string): Promise<Tank>;
|
abstract tank(id: string): Promise<Tank>;
|
||||||
abstract tanks(): Promise<Tanks>;
|
abstract tanks(): Promise<Tanks>;
|
||||||
abstract popularTanks(): Promise<PopularTanks>;
|
abstract popularTanks(): Promise<PopularTanks>;
|
||||||
abstract tankUpgradePreset(
|
abstract tankUpgradePresets(): Promise<TankUpgradePresets>;
|
||||||
name: string,
|
|
||||||
): Promise<TankUpgradePricePresetComponent>;
|
|
||||||
|
|
||||||
abstract tiers(): Promise<Tiers>;
|
abstract tiers(): Promise<Tiers>;
|
||||||
abstract equipment(): Promise<Equipment>;
|
abstract equipment(): Promise<Equipment>;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { fetchPB } from "@blitzkit/core";
|
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 { Equipment } from "@protos/equipment";
|
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 { TankUpgradePresets } from "@protos/tank_upgrade_presets";
|
||||||
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";
|
||||||
@@ -45,11 +45,8 @@ export class ClientAPI extends AbstractAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Cache()
|
@Cache()
|
||||||
tankUpgradePreset(name: string) {
|
tankUpgradePresets() {
|
||||||
return fetchPB(
|
return fetchPB(`/api/tanks/upgrades.pb`, TankUpgradePresets);
|
||||||
`/api/tanks/presets/upgrade/${name}.pb`,
|
|
||||||
TankUpgradePricePresetComponent,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cache()
|
@Cache()
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ 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";
|
||||||
|
import { TankUpgradePresets } from "@protos/tank_upgrade_presets";
|
||||||
import type { Tanks } from "@protos/tanks";
|
import type { Tanks } from "@protos/tanks";
|
||||||
import type { Tiers } from "@protos/tiers";
|
import type { Tiers } from "@protos/tiers";
|
||||||
import { existsSync } from "fs";
|
import { existsSync } from "fs";
|
||||||
@@ -95,10 +96,9 @@ export class ServerAPI extends AbstractAPI {
|
|||||||
|
|
||||||
if (!name) continue;
|
if (!name) continue;
|
||||||
|
|
||||||
const id = item.name;
|
|
||||||
const slug = sluggify(name);
|
const slug = sluggify(name);
|
||||||
|
|
||||||
list.push({ id, slug });
|
list.push({ id: item.id, slug });
|
||||||
}
|
}
|
||||||
|
|
||||||
return { list };
|
return { list };
|
||||||
@@ -114,7 +114,7 @@ export class ServerAPI extends AbstractAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { slug } = tankListEntry;
|
const { slug } = tankListEntry;
|
||||||
const item = this.metadata.item(`TankEntity.${id}`);
|
const item = this.metadata.item(id);
|
||||||
const tank = item.TankCatalog();
|
const tank = item.TankCatalog();
|
||||||
const compensation = item.Compensation();
|
const compensation = item.Compensation();
|
||||||
|
|
||||||
@@ -220,9 +220,15 @@ export class ServerAPI extends AbstractAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Cache()
|
@Cache()
|
||||||
async tankUpgradePreset(id: string) {
|
async tankUpgradePresets() {
|
||||||
const item = this.metadata.item(`TankUpgradePricePresetEntity.${id}`);
|
const group = this.metadata.group("TankUpgradePricePresetEntity");
|
||||||
return item.TankUpgradePricePreset();
|
const presets = TankUpgradePresets.create();
|
||||||
|
|
||||||
|
for (const item of group) {
|
||||||
|
presets.presets[item.id] = item.TankUpgradePricePreset();
|
||||||
|
}
|
||||||
|
|
||||||
|
return presets;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cache()
|
@Cache()
|
||||||
@@ -231,7 +237,7 @@ export class ServerAPI extends AbstractAPI {
|
|||||||
const tiers: Tiers = { tiers: {} };
|
const tiers: Tiers = { tiers: {} };
|
||||||
|
|
||||||
for (const item of group) {
|
for (const item of group) {
|
||||||
tiers.tiers[item.name] = item.TankTier();
|
tiers.tiers[item.id] = item.TankTier();
|
||||||
}
|
}
|
||||||
|
|
||||||
return tiers;
|
return tiers;
|
||||||
@@ -332,7 +338,7 @@ export class ServerAPI extends AbstractAPI {
|
|||||||
|
|
||||||
@Cache()
|
@Cache()
|
||||||
async avatar(id: string) {
|
async avatar(id: string) {
|
||||||
const avatar = this.metadata.item(`ProfileAvatarEntity.${id}`);
|
const avatar = this.metadata.item(id);
|
||||||
const name = avatar.name;
|
const name = avatar.name;
|
||||||
const stuff_ui = avatar.StuffUI("UIComponent");
|
const stuff_ui = avatar.StuffUI("UIComponent");
|
||||||
const profile_avatar = avatar.ProfileAvatar();
|
const profile_avatar = avatar.ProfileAvatar();
|
||||||
@@ -348,7 +354,7 @@ export class ServerAPI extends AbstractAPI {
|
|||||||
const avatars: Avatar[] = [];
|
const avatars: Avatar[] = [];
|
||||||
|
|
||||||
for (const item of this.metadata.group("ProfileAvatarEntity")) {
|
for (const item of this.metadata.group("ProfileAvatarEntity")) {
|
||||||
avatars.push(await this.avatar(item.name));
|
avatars.push(await this.avatar(item.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
return { avatars };
|
return { avatars };
|
||||||
@@ -364,7 +370,7 @@ export class ServerAPI extends AbstractAPI {
|
|||||||
|
|
||||||
@Cache()
|
@Cache()
|
||||||
async background(id: string) {
|
async background(id: string) {
|
||||||
const background = this.metadata.item(`ProfileBackgroundEntity.${id}`);
|
const background = this.metadata.item(id);
|
||||||
const name = background.name;
|
const name = background.name;
|
||||||
const stuff_ui = background.StuffUI("UIComponent");
|
const stuff_ui = background.StuffUI("UIComponent");
|
||||||
const profile_background = background.ProfileBackground();
|
const profile_background = background.ProfileBackground();
|
||||||
|
|||||||
@@ -5,11 +5,8 @@ export function useTierCompare() {
|
|||||||
const tiers = useAwait(() => api.tiers(), "tiers");
|
const tiers = useAwait(() => api.tiers(), "tiers");
|
||||||
|
|
||||||
function compare(a: string, b: string) {
|
function compare(a: string, b: string) {
|
||||||
const [, tierNameA] = a.split(".");
|
const tierA = tiers.tiers[a];
|
||||||
const [, tierNameB] = b.split(".");
|
const tierB = tiers.tiers[b];
|
||||||
const tierA = tiers.tiers[tierNameA];
|
|
||||||
const tierB = tiers.tiers[tierNameB];
|
|
||||||
|
|
||||||
return tierB.carousel_level - tierA.carousel_level;
|
return tierB.carousel_level - tierA.carousel_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,10 @@ import { api } from "../api/dynamic";
|
|||||||
import { useAwait } from "./useAwait";
|
import { useAwait } from "./useAwait";
|
||||||
|
|
||||||
export function useUpgradePreset(name: string) {
|
export function useUpgradePreset(name: string) {
|
||||||
const [, discriminator] = name.split(".");
|
const presets = useAwait(
|
||||||
const preset = useAwait(
|
() => api.tankUpgradePresets(),
|
||||||
() => api.tankUpgradePreset(discriminator),
|
"tank-upgrade-presets",
|
||||||
`tank-upgrade-preset-${discriminator}`,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return preset;
|
return presets.presets[name];
|
||||||
}
|
}
|
||||||
@@ -9,8 +9,3 @@ export const getStaticPaths = mixStaticPaths(_getStaticPaths, async () => {
|
|||||||
.group("TankUpgradePricePresetEntity")
|
.group("TankUpgradePricePresetEntity")
|
||||||
.map(({ name }) => ({ params: { id: name } }));
|
.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",
|
name: "tier",
|
||||||
render({ output, strings }) {
|
render({ output, strings }) {
|
||||||
const [, name] = (output as string).split(".");
|
const name = output as string;
|
||||||
|
|
||||||
if (name == "vintage") {
|
if (name == "vintage") {
|
||||||
return <VintageIcon />;
|
return <VintageIcon />;
|
||||||
|
|||||||
Reference in new issue
Block a user