mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-22 11:17:05 +02:00
feat: the thing
This commit is contained in:
1 parent
e60bbc03d2
commit
b856268ee0
9 files changed
+63
-107
No files matched your search
@@ -47,6 +47,7 @@ export * from './createDefaultProvisions';
|
||||
export * from './metaSortTank';
|
||||
export * from './romanize';
|
||||
export * from './tank';
|
||||
export * from './tankArmor';
|
||||
export * from './tanks';
|
||||
export * from './tanksFull';
|
||||
export * from './youtubers';
|
||||
@@ -0,0 +1,7 @@
|
||||
import { fetchPB } from '../protobuf';
|
||||
import { TankArmor } from '../protos';
|
||||
import { asset } from './asset';
|
||||
|
||||
export function fetchTankArmor(id: string) {
|
||||
return fetchPB(asset(`tanks/${id}/armor.pb`), TankArmor);
|
||||
}
|
||||
@@ -3,10 +3,8 @@ syntax = "proto2";
|
||||
package blitzkit;
|
||||
|
||||
message TankArmor {
|
||||
// tank id
|
||||
required string id = 1;
|
||||
// key can only ever be "chassis", "hull", "turret", or "gun"
|
||||
map<string, PenetrationGroup> groups = 4;
|
||||
map<string, PenetrationGroup> groups = 1;
|
||||
}
|
||||
|
||||
message PenetrationGroup {
|
||||
|
||||
@@ -10,8 +10,6 @@ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
||||
export const protobufPackage = "blitzkit";
|
||||
|
||||
export interface TankArmor {
|
||||
/** tank id */
|
||||
id: string;
|
||||
/** key can only ever be "chassis", "hull", "turret", or "gun" */
|
||||
groups: { [key: string]: PenetrationGroup };
|
||||
}
|
||||
@@ -42,16 +40,13 @@ export interface ArmorPlate {
|
||||
}
|
||||
|
||||
function createBaseTankArmor(): TankArmor {
|
||||
return { id: "", groups: {} };
|
||||
return { groups: {} };
|
||||
}
|
||||
|
||||
export const TankArmor: MessageFns<TankArmor> = {
|
||||
encode(message: TankArmor, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
||||
if (message.id !== "") {
|
||||
writer.uint32(10).string(message.id);
|
||||
}
|
||||
Object.entries(message.groups).forEach(([key, value]) => {
|
||||
TankArmor_GroupsEntry.encode({ key: key as any, value }, writer.uint32(34).fork()).join();
|
||||
TankArmor_GroupsEntry.encode({ key: key as any, value }, writer.uint32(10).fork()).join();
|
||||
});
|
||||
return writer;
|
||||
},
|
||||
@@ -68,17 +63,9 @@ export const TankArmor: MessageFns<TankArmor> = {
|
||||
break;
|
||||
}
|
||||
|
||||
message.id = reader.string();
|
||||
continue;
|
||||
}
|
||||
case 4: {
|
||||
if (tag !== 34) {
|
||||
break;
|
||||
}
|
||||
|
||||
const entry4 = TankArmor_GroupsEntry.decode(reader, reader.uint32());
|
||||
if (entry4.value !== undefined) {
|
||||
message.groups[entry4.key] = entry4.value;
|
||||
const entry1 = TankArmor_GroupsEntry.decode(reader, reader.uint32());
|
||||
if (entry1.value !== undefined) {
|
||||
message.groups[entry1.key] = entry1.value;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -93,7 +80,6 @@ export const TankArmor: MessageFns<TankArmor> = {
|
||||
|
||||
fromJSON(object: any): TankArmor {
|
||||
return {
|
||||
id: globalThis.String(assertSet("TankArmor.id", object.id)),
|
||||
groups: isObject(object.groups)
|
||||
? Object.entries(object.groups).reduce<{ [key: string]: PenetrationGroup }>((acc, [key, value]) => {
|
||||
acc[key] = PenetrationGroup.fromJSON(value);
|
||||
@@ -105,9 +91,6 @@ export const TankArmor: MessageFns<TankArmor> = {
|
||||
|
||||
toJSON(message: TankArmor): unknown {
|
||||
const obj: any = {};
|
||||
if (message.id !== "") {
|
||||
obj.id = message.id;
|
||||
}
|
||||
if (message.groups) {
|
||||
const entries = Object.entries(message.groups);
|
||||
if (entries.length > 0) {
|
||||
@@ -125,7 +108,6 @@ export const TankArmor: MessageFns<TankArmor> = {
|
||||
},
|
||||
fromPartial<I extends Exact<DeepPartial<TankArmor>, I>>(object: I): TankArmor {
|
||||
const message = createBaseTankArmor();
|
||||
message.id = object.id ?? "";
|
||||
message.groups = Object.entries(object.groups ?? {}).reduce<{ [key: string]: PenetrationGroup }>(
|
||||
(acc, [key, value]) => {
|
||||
if (value !== undefined) {
|
||||
|
||||
Reference in new issue
Block a user