mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-13 04:36:12 +01:00
feat: load tank data
This commit is contained in:
1 parent
6a958da390
commit
383d3a36ef
3 files changed
+39
-1
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import type { TankCatalogComponent } from "@protos/blitz_static_tank_component";
|
||||
import type { Tanks } from "../../protos/tanks";
|
||||
|
||||
export abstract class AbstractAPI {
|
||||
@@ -7,4 +8,6 @@ export abstract class AbstractAPI {
|
||||
locale: string,
|
||||
prefix?: string
|
||||
): Promise<Record<string, string>>;
|
||||
|
||||
abstract tank(id: string): Promise<TankCatalogComponent>;
|
||||
}
|
||||
@@ -78,7 +78,12 @@ export class ServerAPI extends AbstractAPI {
|
||||
|
||||
for (const item of group) {
|
||||
const tankCatalog = item.TankCatalog();
|
||||
const name = strings[tankCatalog.name!.value];
|
||||
|
||||
if (!tankCatalog.name) continue;
|
||||
|
||||
const name = strings[tankCatalog.name.value];
|
||||
|
||||
if (!name) continue;
|
||||
|
||||
const id = item.name;
|
||||
const slug = sluggify(name);
|
||||
@@ -88,4 +93,11 @@ export class ServerAPI extends AbstractAPI {
|
||||
|
||||
return { tanks };
|
||||
}
|
||||
|
||||
async tank(id: string) {
|
||||
const item = this.metadata.item(`TankEntity.${id}`);
|
||||
const tankCatalog = item.TankCatalog();
|
||||
|
||||
return tankCatalog;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user