2026-01-02 14:20:29 -06:00
|
|
|
import type { CatalogItemAccessor } from "@blitzkit/closed";
|
2026-01-09 13:38:00 -06:00
|
|
|
import type { Strings } from "@blitzkit/i18n";
|
|
|
|
|
import locales from "@blitzkit/i18n/locales.json";
|
|
|
|
|
import type { Tank } from "../../protos/tank";
|
|
|
|
|
import type { TankList } from "../../protos/tank_list";
|
|
|
|
|
import type { Tanks } from "../../protos/tanks";
|
2025-11-28 13:51:17 -06:00
|
|
|
|
|
|
|
|
export abstract class AbstractAPI {
|
|
|
|
|
abstract tanks(): Promise<Tanks>;
|
2025-11-28 14:13:03 -06:00
|
|
|
|
2025-12-26 14:59:09 -06:00
|
|
|
abstract tankList(): Promise<TankList>;
|
|
|
|
|
|
2026-01-09 13:38:00 -06:00
|
|
|
abstract _strings(locale: string): Promise<Strings>;
|
|
|
|
|
abstract _gameStrings(
|
2025-11-28 14:13:03 -06:00
|
|
|
locale: string,
|
2026-01-09 13:38:00 -06:00
|
|
|
prefix: string
|
2025-11-28 14:13:03 -06:00
|
|
|
): Promise<Record<string, string>>;
|
2025-11-28 14:21:26 -06:00
|
|
|
|
2026-01-09 13:38:00 -06:00
|
|
|
private assertLocale(locale: string) {
|
|
|
|
|
const supported = locales.supported.find(
|
|
|
|
|
(supported) => supported.locale === locale
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (supported === undefined) {
|
|
|
|
|
throw new Error(`Unsupported locale: ${locale}`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return supported;
|
|
|
|
|
}
|
|
|
|
|
async strings(locale: string) {
|
|
|
|
|
this.assertLocale(locale);
|
|
|
|
|
return await this._strings(locale);
|
|
|
|
|
}
|
|
|
|
|
async gameStrings(locale: string, prefix: string) {
|
2026-01-09 13:57:28 -06:00
|
|
|
this.assertLocale(locale);
|
|
|
|
|
return await this._gameStrings(locale, prefix);
|
2026-01-09 13:38:00 -06:00
|
|
|
}
|
|
|
|
|
|
2025-12-26 14:14:29 -06:00
|
|
|
abstract tank(id: string): Promise<Tank>;
|
2026-01-02 14:20:29 -06:00
|
|
|
|
|
|
|
|
abstract avatars(): Promise<CatalogItemAccessor[]>;
|
2026-01-02 20:04:19 -06:00
|
|
|
abstract avatar(id: string): Promise<CatalogItemAccessor>;
|
2026-01-02 20:17:24 -06:00
|
|
|
|
|
|
|
|
abstract backgrounds(): Promise<CatalogItemAccessor[]>;
|
|
|
|
|
abstract background(id: string): Promise<CatalogItemAccessor>;
|
2025-11-28 13:51:17 -06:00
|
|
|
}
|