mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 11:39:50 +02:00
feat: separate armors
This commit is contained in:
1 parent
30b18f60be
commit
e60bbc03d2
31 files changed
+1387
-690
No files matched your search
@@ -14,4 +14,5 @@ export * from './legacy_skill_definitions.ts';
|
||||
export * from './legacy_tank_definitions.ts';
|
||||
export * from './reviews.ts';
|
||||
export * from './tank.ts';
|
||||
export * from './tanks.ts';
|
||||
export * from './tanks.ts';
|
||||
export * from './tank_armor.ts';
|
||||
@@ -8,12 +8,4 @@ message Tank {
|
||||
required string id = 1;
|
||||
required string slug = 2;
|
||||
required I18n name = 3;
|
||||
// key can only ever be "chassis", "hull", "turret", or "gun"
|
||||
map<string, PenetrationGroup> penetration_groups = 4;
|
||||
}
|
||||
|
||||
message PenetrationGroup {
|
||||
// keys are mostly "armor_xyz" where xyz is an integer but sometimes can be
|
||||
// things like "commander", "rightTrack", etc.
|
||||
map<string, float> armors = 1;
|
||||
}
|
||||
@@ -5,63 +5,37 @@
|
||||
// source: packages/core/src/protos/tank.proto
|
||||
|
||||
/* eslint-disable */
|
||||
import { BinaryReader, BinaryWriter } from '@bufbuild/protobuf/wire';
|
||||
import { I18n, createBaseI18n } from './i18n';
|
||||
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
||||
import { I18n, createBaseI18n } from "./i18n";
|
||||
|
||||
export const protobufPackage = 'blitzkit';
|
||||
export const protobufPackage = "blitzkit";
|
||||
|
||||
export interface Tank {
|
||||
id: string;
|
||||
slug: string;
|
||||
name: I18n;
|
||||
/** key can only ever be "chassis", "hull", "turret", or "gun" */
|
||||
penetration_groups: { [key: string]: PenetrationGroup };
|
||||
}
|
||||
|
||||
export interface Tank_PenetrationGroupsEntry {
|
||||
key: string;
|
||||
value: PenetrationGroup | undefined;
|
||||
}
|
||||
|
||||
export interface PenetrationGroup {
|
||||
armors: { [key: string]: number };
|
||||
}
|
||||
|
||||
export interface PenetrationGroup_ArmorsEntry {
|
||||
key: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
function createBaseTank(): Tank {
|
||||
return { id: '', slug: '', name: createBaseI18n(), penetration_groups: {} };
|
||||
return { id: "", slug: "", name: createBaseI18n() };
|
||||
}
|
||||
|
||||
export const Tank: MessageFns<Tank> = {
|
||||
encode(
|
||||
message: Tank,
|
||||
writer: BinaryWriter = new BinaryWriter(),
|
||||
): BinaryWriter {
|
||||
if (message.id !== '') {
|
||||
encode(message: Tank, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
||||
if (message.id !== "") {
|
||||
writer.uint32(10).string(message.id);
|
||||
}
|
||||
if (message.slug !== '') {
|
||||
if (message.slug !== "") {
|
||||
writer.uint32(18).string(message.slug);
|
||||
}
|
||||
if (message.name !== undefined) {
|
||||
I18n.encode(message.name, writer.uint32(26).fork()).join();
|
||||
}
|
||||
Object.entries(message.penetration_groups).forEach(([key, value]) => {
|
||||
Tank_PenetrationGroupsEntry.encode(
|
||||
{ key: key as any, value },
|
||||
writer.uint32(34).fork(),
|
||||
).join();
|
||||
});
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: BinaryReader | Uint8Array, length?: number): Tank {
|
||||
const reader =
|
||||
input instanceof BinaryReader ? input : new BinaryReader(input);
|
||||
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseTank();
|
||||
while (reader.pos < end) {
|
||||
@@ -91,20 +65,6 @@ export const Tank: MessageFns<Tank> = {
|
||||
message.name = I18n.decode(reader, reader.uint32());
|
||||
continue;
|
||||
}
|
||||
case 4: {
|
||||
if (tag !== 34) {
|
||||
break;
|
||||
}
|
||||
|
||||
const entry4 = Tank_PenetrationGroupsEntry.decode(
|
||||
reader,
|
||||
reader.uint32(),
|
||||
);
|
||||
if (entry4.value !== undefined) {
|
||||
message.penetration_groups[entry4.key] = entry4.value;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ((tag & 7) === 4 || tag === 0) {
|
||||
break;
|
||||
@@ -116,40 +76,23 @@ export const Tank: MessageFns<Tank> = {
|
||||
|
||||
fromJSON(object: any): Tank {
|
||||
return {
|
||||
id: globalThis.String(assertSet('Tank.id', object.id)),
|
||||
slug: globalThis.String(assertSet('Tank.slug', object.slug)),
|
||||
name: I18n.fromJSON(assertSet('Tank.name', object.name)),
|
||||
penetration_groups: isObject(object.penetration_groups)
|
||||
? Object.entries(object.penetration_groups).reduce<{
|
||||
[key: string]: PenetrationGroup;
|
||||
}>((acc, [key, value]) => {
|
||||
acc[key] = PenetrationGroup.fromJSON(value);
|
||||
return acc;
|
||||
}, {})
|
||||
: {},
|
||||
id: globalThis.String(assertSet("Tank.id", object.id)),
|
||||
slug: globalThis.String(assertSet("Tank.slug", object.slug)),
|
||||
name: I18n.fromJSON(assertSet("Tank.name", object.name)),
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: Tank): unknown {
|
||||
const obj: any = {};
|
||||
if (message.id !== '') {
|
||||
if (message.id !== "") {
|
||||
obj.id = message.id;
|
||||
}
|
||||
if (message.slug !== '') {
|
||||
if (message.slug !== "") {
|
||||
obj.slug = message.slug;
|
||||
}
|
||||
if (message.name !== undefined) {
|
||||
obj.name = I18n.toJSON(message.name);
|
||||
}
|
||||
if (message.penetration_groups) {
|
||||
const entries = Object.entries(message.penetration_groups);
|
||||
if (entries.length > 0) {
|
||||
obj.penetration_groups = {};
|
||||
entries.forEach(([k, v]) => {
|
||||
obj.penetration_groups[k] = PenetrationGroup.toJSON(v);
|
||||
});
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
|
||||
@@ -158,340 +101,27 @@ export const Tank: MessageFns<Tank> = {
|
||||
},
|
||||
fromPartial<I extends Exact<DeepPartial<Tank>, I>>(object: I): Tank {
|
||||
const message = createBaseTank();
|
||||
message.id = object.id ?? '';
|
||||
message.slug = object.slug ?? '';
|
||||
message.name =
|
||||
object.name !== undefined && object.name !== null
|
||||
? I18n.fromPartial(object.name)
|
||||
: createBaseI18n();
|
||||
message.penetration_groups = Object.entries(
|
||||
object.penetration_groups ?? {},
|
||||
).reduce<{ [key: string]: PenetrationGroup }>((acc, [key, value]) => {
|
||||
if (value !== undefined) {
|
||||
acc[key] = PenetrationGroup.fromPartial(value);
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
message.id = object.id ?? "";
|
||||
message.slug = object.slug ?? "";
|
||||
message.name = (object.name !== undefined && object.name !== null)
|
||||
? I18n.fromPartial(object.name)
|
||||
: createBaseI18n();
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBaseTank_PenetrationGroupsEntry(): Tank_PenetrationGroupsEntry {
|
||||
return { key: '', value: createBasePenetrationGroup() };
|
||||
}
|
||||
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
||||
|
||||
export const Tank_PenetrationGroupsEntry: MessageFns<Tank_PenetrationGroupsEntry> =
|
||||
{
|
||||
encode(
|
||||
message: Tank_PenetrationGroupsEntry,
|
||||
writer: BinaryWriter = new BinaryWriter(),
|
||||
): BinaryWriter {
|
||||
if (message.key !== undefined) {
|
||||
writer.uint32(10).string(message.key);
|
||||
}
|
||||
if (message.value !== undefined) {
|
||||
PenetrationGroup.encode(message.value, writer.uint32(18).fork()).join();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(
|
||||
input: BinaryReader | Uint8Array,
|
||||
length?: number,
|
||||
): Tank_PenetrationGroupsEntry {
|
||||
const reader =
|
||||
input instanceof BinaryReader ? input : new BinaryReader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseTank_PenetrationGroupsEntry();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1: {
|
||||
if (tag !== 10) {
|
||||
break;
|
||||
}
|
||||
|
||||
message.key = reader.string();
|
||||
continue;
|
||||
}
|
||||
case 2: {
|
||||
if (tag !== 18) {
|
||||
break;
|
||||
}
|
||||
|
||||
message.value = PenetrationGroup.decode(reader, reader.uint32());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ((tag & 7) === 4 || tag === 0) {
|
||||
break;
|
||||
}
|
||||
reader.skip(tag & 7);
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): Tank_PenetrationGroupsEntry {
|
||||
return {
|
||||
key: globalThis.String(
|
||||
assertSet('Tank_PenetrationGroupsEntry.key', object.key),
|
||||
),
|
||||
value: PenetrationGroup.fromJSON(
|
||||
assertSet('Tank_PenetrationGroupsEntry.value', object.value),
|
||||
),
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: Tank_PenetrationGroupsEntry): unknown {
|
||||
const obj: any = {};
|
||||
if (message.key !== undefined) {
|
||||
obj.key = message.key;
|
||||
}
|
||||
if (message.value !== undefined) {
|
||||
obj.value = PenetrationGroup.toJSON(message.value);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
|
||||
create<I extends Exact<DeepPartial<Tank_PenetrationGroupsEntry>, I>>(
|
||||
base?: I,
|
||||
): Tank_PenetrationGroupsEntry {
|
||||
return Tank_PenetrationGroupsEntry.fromPartial(base ?? ({} as any));
|
||||
},
|
||||
fromPartial<I extends Exact<DeepPartial<Tank_PenetrationGroupsEntry>, I>>(
|
||||
object: I,
|
||||
): Tank_PenetrationGroupsEntry {
|
||||
const message = createBaseTank_PenetrationGroupsEntry();
|
||||
message.key = object.key ?? '';
|
||||
message.value =
|
||||
object.value !== undefined && object.value !== null
|
||||
? PenetrationGroup.fromPartial(object.value)
|
||||
: undefined;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBasePenetrationGroup(): PenetrationGroup {
|
||||
return { armors: {} };
|
||||
}
|
||||
|
||||
export const PenetrationGroup: MessageFns<PenetrationGroup> = {
|
||||
encode(
|
||||
message: PenetrationGroup,
|
||||
writer: BinaryWriter = new BinaryWriter(),
|
||||
): BinaryWriter {
|
||||
Object.entries(message.armors).forEach(([key, value]) => {
|
||||
PenetrationGroup_ArmorsEntry.encode(
|
||||
{ key: key as any, value },
|
||||
writer.uint32(10).fork(),
|
||||
).join();
|
||||
});
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: BinaryReader | Uint8Array, length?: number): PenetrationGroup {
|
||||
const reader =
|
||||
input instanceof BinaryReader ? input : new BinaryReader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBasePenetrationGroup();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1: {
|
||||
if (tag !== 10) {
|
||||
break;
|
||||
}
|
||||
|
||||
const entry1 = PenetrationGroup_ArmorsEntry.decode(
|
||||
reader,
|
||||
reader.uint32(),
|
||||
);
|
||||
if (entry1.value !== undefined) {
|
||||
message.armors[entry1.key] = entry1.value;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ((tag & 7) === 4 || tag === 0) {
|
||||
break;
|
||||
}
|
||||
reader.skip(tag & 7);
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): PenetrationGroup {
|
||||
return {
|
||||
armors: isObject(object.armors)
|
||||
? Object.entries(object.armors).reduce<{ [key: string]: number }>(
|
||||
(acc, [key, value]) => {
|
||||
acc[key] = Number(value);
|
||||
return acc;
|
||||
},
|
||||
{},
|
||||
)
|
||||
: {},
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: PenetrationGroup): unknown {
|
||||
const obj: any = {};
|
||||
if (message.armors) {
|
||||
const entries = Object.entries(message.armors);
|
||||
if (entries.length > 0) {
|
||||
obj.armors = {};
|
||||
entries.forEach(([k, v]) => {
|
||||
obj.armors[k] = v;
|
||||
});
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
|
||||
create<I extends Exact<DeepPartial<PenetrationGroup>, I>>(
|
||||
base?: I,
|
||||
): PenetrationGroup {
|
||||
return PenetrationGroup.fromPartial(base ?? ({} as any));
|
||||
},
|
||||
fromPartial<I extends Exact<DeepPartial<PenetrationGroup>, I>>(
|
||||
object: I,
|
||||
): PenetrationGroup {
|
||||
const message = createBasePenetrationGroup();
|
||||
message.armors = Object.entries(object.armors ?? {}).reduce<{
|
||||
[key: string]: number;
|
||||
}>((acc, [key, value]) => {
|
||||
if (value !== undefined) {
|
||||
acc[key] = globalThis.Number(value);
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBasePenetrationGroup_ArmorsEntry(): PenetrationGroup_ArmorsEntry {
|
||||
return { key: '', value: 0 };
|
||||
}
|
||||
|
||||
export const PenetrationGroup_ArmorsEntry: MessageFns<PenetrationGroup_ArmorsEntry> =
|
||||
{
|
||||
encode(
|
||||
message: PenetrationGroup_ArmorsEntry,
|
||||
writer: BinaryWriter = new BinaryWriter(),
|
||||
): BinaryWriter {
|
||||
if (message.key !== undefined) {
|
||||
writer.uint32(10).string(message.key);
|
||||
}
|
||||
if (message.value !== undefined) {
|
||||
writer.uint32(21).float(message.value);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(
|
||||
input: BinaryReader | Uint8Array,
|
||||
length?: number,
|
||||
): PenetrationGroup_ArmorsEntry {
|
||||
const reader =
|
||||
input instanceof BinaryReader ? input : new BinaryReader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBasePenetrationGroup_ArmorsEntry();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1: {
|
||||
if (tag !== 10) {
|
||||
break;
|
||||
}
|
||||
|
||||
message.key = reader.string();
|
||||
continue;
|
||||
}
|
||||
case 2: {
|
||||
if (tag !== 21) {
|
||||
break;
|
||||
}
|
||||
|
||||
message.value = reader.float();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ((tag & 7) === 4 || tag === 0) {
|
||||
break;
|
||||
}
|
||||
reader.skip(tag & 7);
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): PenetrationGroup_ArmorsEntry {
|
||||
return {
|
||||
key: globalThis.String(
|
||||
assertSet('PenetrationGroup_ArmorsEntry.key', object.key),
|
||||
),
|
||||
value: globalThis.Number(
|
||||
assertSet('PenetrationGroup_ArmorsEntry.value', object.value),
|
||||
),
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: PenetrationGroup_ArmorsEntry): unknown {
|
||||
const obj: any = {};
|
||||
if (message.key !== undefined) {
|
||||
obj.key = message.key;
|
||||
}
|
||||
if (message.value !== undefined) {
|
||||
obj.value = message.value;
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
|
||||
create<I extends Exact<DeepPartial<PenetrationGroup_ArmorsEntry>, I>>(
|
||||
base?: I,
|
||||
): PenetrationGroup_ArmorsEntry {
|
||||
return PenetrationGroup_ArmorsEntry.fromPartial(base ?? ({} as any));
|
||||
},
|
||||
fromPartial<I extends Exact<DeepPartial<PenetrationGroup_ArmorsEntry>, I>>(
|
||||
object: I,
|
||||
): PenetrationGroup_ArmorsEntry {
|
||||
const message = createBasePenetrationGroup_ArmorsEntry();
|
||||
message.key = object.key ?? '';
|
||||
message.value = object.value ?? 0;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
type Builtin =
|
||||
| Date
|
||||
| Function
|
||||
| Uint8Array
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| undefined;
|
||||
|
||||
export type DeepPartial<T> = T extends Builtin
|
||||
? T
|
||||
: T extends globalThis.Array<infer U>
|
||||
? globalThis.Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends { $case: string; value: unknown }
|
||||
? { $case: T['$case']; value?: DeepPartial<T['value']> }
|
||||
: T extends {}
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
export type DeepPartial<T> = T extends Builtin ? T
|
||||
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends { $case: string; value: unknown } ? { $case: T["$case"]; value?: DeepPartial<T["value"]> }
|
||||
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
|
||||
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
||||
export type Exact<P, I extends P> = P extends Builtin
|
||||
? P
|
||||
: P & { [K in keyof P]: Exact<P[K], I[K]> } & {
|
||||
[K in Exclude<keyof I, KeysOfUnion<P>>]: never;
|
||||
};
|
||||
|
||||
function isObject(value: any): boolean {
|
||||
return typeof value === 'object' && value !== null;
|
||||
}
|
||||
export type Exact<P, I extends P> = P extends Builtin ? P
|
||||
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
|
||||
|
||||
function isSet(value: any): boolean {
|
||||
return value !== null && value !== undefined;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
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;
|
||||
}
|
||||
|
||||
message PenetrationGroup {
|
||||
// keys are mostly "armor_xyz" where xyz is an integer but sometimes can be
|
||||
// things like "commander", "rightTrack", etc.
|
||||
map<string, ArmorPlate> armors = 1;
|
||||
}
|
||||
|
||||
message ArmorPlate {
|
||||
// this is the thickness of the armor in millimeters
|
||||
required float thickness = 1;
|
||||
// this can be stuff like ArmorScreen which is spaced armor, FuelTank, etc.
|
||||
required string type = 2;
|
||||
}
|
||||
@@ -0,0 +1,489 @@
|
||||
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-ts_proto v2.2.2
|
||||
// protoc v5.28.2
|
||||
// source: packages/core/src/protos/tank_armor.proto
|
||||
|
||||
/* eslint-disable */
|
||||
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 };
|
||||
}
|
||||
|
||||
export interface TankArmor_GroupsEntry {
|
||||
key: string;
|
||||
value: PenetrationGroup | undefined;
|
||||
}
|
||||
|
||||
export interface PenetrationGroup {
|
||||
/**
|
||||
* keys are mostly "armor_xyz" where xyz is an integer but sometimes can be
|
||||
* things like "commander", "rightTrack", etc.
|
||||
*/
|
||||
armors: { [key: string]: ArmorPlate };
|
||||
}
|
||||
|
||||
export interface PenetrationGroup_ArmorsEntry {
|
||||
key: string;
|
||||
value: ArmorPlate | undefined;
|
||||
}
|
||||
|
||||
export interface ArmorPlate {
|
||||
/** this is the thickness of the armor in millimeters */
|
||||
thickness: number;
|
||||
/** this can be stuff like ArmorScreen which is spaced armor, FuelTank, etc. */
|
||||
type: string;
|
||||
}
|
||||
|
||||
function createBaseTankArmor(): TankArmor {
|
||||
return { id: "", 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();
|
||||
});
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: BinaryReader | Uint8Array, length?: number): TankArmor {
|
||||
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseTankArmor();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1: {
|
||||
if (tag !== 10) {
|
||||
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;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ((tag & 7) === 4 || tag === 0) {
|
||||
break;
|
||||
}
|
||||
reader.skip(tag & 7);
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
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);
|
||||
return acc;
|
||||
}, {})
|
||||
: {},
|
||||
};
|
||||
},
|
||||
|
||||
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) {
|
||||
obj.groups = {};
|
||||
entries.forEach(([k, v]) => {
|
||||
obj.groups[k] = PenetrationGroup.toJSON(v);
|
||||
});
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
|
||||
create<I extends Exact<DeepPartial<TankArmor>, I>>(base?: I): TankArmor {
|
||||
return TankArmor.fromPartial(base ?? ({} as any));
|
||||
},
|
||||
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) {
|
||||
acc[key] = PenetrationGroup.fromPartial(value);
|
||||
}
|
||||
return acc;
|
||||
},
|
||||
{},
|
||||
);
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBaseTankArmor_GroupsEntry(): TankArmor_GroupsEntry {
|
||||
return { key: "", value: createBasePenetrationGroup() };
|
||||
}
|
||||
|
||||
export const TankArmor_GroupsEntry: MessageFns<TankArmor_GroupsEntry> = {
|
||||
encode(message: TankArmor_GroupsEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
||||
if (message.key !== undefined) {
|
||||
writer.uint32(10).string(message.key);
|
||||
}
|
||||
if (message.value !== undefined) {
|
||||
PenetrationGroup.encode(message.value, writer.uint32(18).fork()).join();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: BinaryReader | Uint8Array, length?: number): TankArmor_GroupsEntry {
|
||||
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseTankArmor_GroupsEntry();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1: {
|
||||
if (tag !== 10) {
|
||||
break;
|
||||
}
|
||||
|
||||
message.key = reader.string();
|
||||
continue;
|
||||
}
|
||||
case 2: {
|
||||
if (tag !== 18) {
|
||||
break;
|
||||
}
|
||||
|
||||
message.value = PenetrationGroup.decode(reader, reader.uint32());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ((tag & 7) === 4 || tag === 0) {
|
||||
break;
|
||||
}
|
||||
reader.skip(tag & 7);
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): TankArmor_GroupsEntry {
|
||||
return {
|
||||
key: globalThis.String(assertSet("TankArmor_GroupsEntry.key", object.key)),
|
||||
value: PenetrationGroup.fromJSON(assertSet("TankArmor_GroupsEntry.value", object.value)),
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: TankArmor_GroupsEntry): unknown {
|
||||
const obj: any = {};
|
||||
if (message.key !== undefined) {
|
||||
obj.key = message.key;
|
||||
}
|
||||
if (message.value !== undefined) {
|
||||
obj.value = PenetrationGroup.toJSON(message.value);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
|
||||
create<I extends Exact<DeepPartial<TankArmor_GroupsEntry>, I>>(base?: I): TankArmor_GroupsEntry {
|
||||
return TankArmor_GroupsEntry.fromPartial(base ?? ({} as any));
|
||||
},
|
||||
fromPartial<I extends Exact<DeepPartial<TankArmor_GroupsEntry>, I>>(object: I): TankArmor_GroupsEntry {
|
||||
const message = createBaseTankArmor_GroupsEntry();
|
||||
message.key = object.key ?? "";
|
||||
message.value = (object.value !== undefined && object.value !== null)
|
||||
? PenetrationGroup.fromPartial(object.value)
|
||||
: undefined;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBasePenetrationGroup(): PenetrationGroup {
|
||||
return { armors: {} };
|
||||
}
|
||||
|
||||
export const PenetrationGroup: MessageFns<PenetrationGroup> = {
|
||||
encode(message: PenetrationGroup, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
||||
Object.entries(message.armors).forEach(([key, value]) => {
|
||||
PenetrationGroup_ArmorsEntry.encode({ key: key as any, value }, writer.uint32(10).fork()).join();
|
||||
});
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: BinaryReader | Uint8Array, length?: number): PenetrationGroup {
|
||||
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBasePenetrationGroup();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1: {
|
||||
if (tag !== 10) {
|
||||
break;
|
||||
}
|
||||
|
||||
const entry1 = PenetrationGroup_ArmorsEntry.decode(reader, reader.uint32());
|
||||
if (entry1.value !== undefined) {
|
||||
message.armors[entry1.key] = entry1.value;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ((tag & 7) === 4 || tag === 0) {
|
||||
break;
|
||||
}
|
||||
reader.skip(tag & 7);
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): PenetrationGroup {
|
||||
return {
|
||||
armors: isObject(object.armors)
|
||||
? Object.entries(object.armors).reduce<{ [key: string]: ArmorPlate }>((acc, [key, value]) => {
|
||||
acc[key] = ArmorPlate.fromJSON(value);
|
||||
return acc;
|
||||
}, {})
|
||||
: {},
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: PenetrationGroup): unknown {
|
||||
const obj: any = {};
|
||||
if (message.armors) {
|
||||
const entries = Object.entries(message.armors);
|
||||
if (entries.length > 0) {
|
||||
obj.armors = {};
|
||||
entries.forEach(([k, v]) => {
|
||||
obj.armors[k] = ArmorPlate.toJSON(v);
|
||||
});
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
|
||||
create<I extends Exact<DeepPartial<PenetrationGroup>, I>>(base?: I): PenetrationGroup {
|
||||
return PenetrationGroup.fromPartial(base ?? ({} as any));
|
||||
},
|
||||
fromPartial<I extends Exact<DeepPartial<PenetrationGroup>, I>>(object: I): PenetrationGroup {
|
||||
const message = createBasePenetrationGroup();
|
||||
message.armors = Object.entries(object.armors ?? {}).reduce<{ [key: string]: ArmorPlate }>((acc, [key, value]) => {
|
||||
if (value !== undefined) {
|
||||
acc[key] = ArmorPlate.fromPartial(value);
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBasePenetrationGroup_ArmorsEntry(): PenetrationGroup_ArmorsEntry {
|
||||
return { key: "", value: createBaseArmorPlate() };
|
||||
}
|
||||
|
||||
export const PenetrationGroup_ArmorsEntry: MessageFns<PenetrationGroup_ArmorsEntry> = {
|
||||
encode(message: PenetrationGroup_ArmorsEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
||||
if (message.key !== undefined) {
|
||||
writer.uint32(10).string(message.key);
|
||||
}
|
||||
if (message.value !== undefined) {
|
||||
ArmorPlate.encode(message.value, writer.uint32(18).fork()).join();
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: BinaryReader | Uint8Array, length?: number): PenetrationGroup_ArmorsEntry {
|
||||
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBasePenetrationGroup_ArmorsEntry();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1: {
|
||||
if (tag !== 10) {
|
||||
break;
|
||||
}
|
||||
|
||||
message.key = reader.string();
|
||||
continue;
|
||||
}
|
||||
case 2: {
|
||||
if (tag !== 18) {
|
||||
break;
|
||||
}
|
||||
|
||||
message.value = ArmorPlate.decode(reader, reader.uint32());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ((tag & 7) === 4 || tag === 0) {
|
||||
break;
|
||||
}
|
||||
reader.skip(tag & 7);
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): PenetrationGroup_ArmorsEntry {
|
||||
return {
|
||||
key: globalThis.String(assertSet("PenetrationGroup_ArmorsEntry.key", object.key)),
|
||||
value: ArmorPlate.fromJSON(assertSet("PenetrationGroup_ArmorsEntry.value", object.value)),
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: PenetrationGroup_ArmorsEntry): unknown {
|
||||
const obj: any = {};
|
||||
if (message.key !== undefined) {
|
||||
obj.key = message.key;
|
||||
}
|
||||
if (message.value !== undefined) {
|
||||
obj.value = ArmorPlate.toJSON(message.value);
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
|
||||
create<I extends Exact<DeepPartial<PenetrationGroup_ArmorsEntry>, I>>(base?: I): PenetrationGroup_ArmorsEntry {
|
||||
return PenetrationGroup_ArmorsEntry.fromPartial(base ?? ({} as any));
|
||||
},
|
||||
fromPartial<I extends Exact<DeepPartial<PenetrationGroup_ArmorsEntry>, I>>(object: I): PenetrationGroup_ArmorsEntry {
|
||||
const message = createBasePenetrationGroup_ArmorsEntry();
|
||||
message.key = object.key ?? "";
|
||||
message.value = (object.value !== undefined && object.value !== null)
|
||||
? ArmorPlate.fromPartial(object.value)
|
||||
: undefined;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBaseArmorPlate(): ArmorPlate {
|
||||
return { thickness: 0, type: "" };
|
||||
}
|
||||
|
||||
export const ArmorPlate: MessageFns<ArmorPlate> = {
|
||||
encode(message: ArmorPlate, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
||||
if (message.thickness !== 0) {
|
||||
writer.uint32(13).float(message.thickness);
|
||||
}
|
||||
if (message.type !== "") {
|
||||
writer.uint32(18).string(message.type);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: BinaryReader | Uint8Array, length?: number): ArmorPlate {
|
||||
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBaseArmorPlate();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1: {
|
||||
if (tag !== 13) {
|
||||
break;
|
||||
}
|
||||
|
||||
message.thickness = reader.float();
|
||||
continue;
|
||||
}
|
||||
case 2: {
|
||||
if (tag !== 18) {
|
||||
break;
|
||||
}
|
||||
|
||||
message.type = reader.string();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ((tag & 7) === 4 || tag === 0) {
|
||||
break;
|
||||
}
|
||||
reader.skip(tag & 7);
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): ArmorPlate {
|
||||
return {
|
||||
thickness: globalThis.Number(assertSet("ArmorPlate.thickness", object.thickness)),
|
||||
type: globalThis.String(assertSet("ArmorPlate.type", object.type)),
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: ArmorPlate): unknown {
|
||||
const obj: any = {};
|
||||
if (message.thickness !== 0) {
|
||||
obj.thickness = message.thickness;
|
||||
}
|
||||
if (message.type !== "") {
|
||||
obj.type = message.type;
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
|
||||
create<I extends Exact<DeepPartial<ArmorPlate>, I>>(base?: I): ArmorPlate {
|
||||
return ArmorPlate.fromPartial(base ?? ({} as any));
|
||||
},
|
||||
fromPartial<I extends Exact<DeepPartial<ArmorPlate>, I>>(object: I): ArmorPlate {
|
||||
const message = createBaseArmorPlate();
|
||||
message.thickness = object.thickness ?? 0;
|
||||
message.type = object.type ?? "";
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
||||
|
||||
export type DeepPartial<T> = T extends Builtin ? T
|
||||
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends { $case: string; value: unknown } ? { $case: T["$case"]; value?: DeepPartial<T["value"]> }
|
||||
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
|
||||
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
||||
export type Exact<P, I extends P> = P extends Builtin ? P
|
||||
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
|
||||
|
||||
function isObject(value: any): boolean {
|
||||
return typeof value === "object" && value !== null;
|
||||
}
|
||||
|
||||
function isSet(value: any): boolean {
|
||||
return value !== null && value !== undefined;
|
||||
}
|
||||
|
||||
function assertSet<T>(field: string, value: T | undefined): T {
|
||||
if (!isSet(value)) {
|
||||
throw new TypeError(`Required field ${field} is not set`);
|
||||
}
|
||||
|
||||
return value as T;
|
||||
}
|
||||
|
||||
export interface MessageFns<T> {
|
||||
encode(message: T, writer?: BinaryWriter): BinaryWriter;
|
||||
decode(input: BinaryReader | Uint8Array, length?: number): T;
|
||||
fromJSON(object: any): T;
|
||||
toJSON(message: T): unknown;
|
||||
create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
|
||||
fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
|
||||
}
|
||||
Reference in new issue
Block a user