// Code generated by protoc-gen-ts_proto. DO NOT EDIT. // versions: // protoc-gen-ts_proto v2.11.2 // protoc v5.28.2 // source: game_definitions.proto /* eslint-disable */ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire"; import { I18nString } from "./i18n"; export const protobufPackage = "blitzkit"; export interface GameDefinitions { version: string; nations: string[]; gameModes: { [key: number]: GameMode }; roles: { [key: number]: GameModeRole }; } export interface GameDefinitions_GameModesEntry { key: number; value: GameMode | undefined; } export interface GameDefinitions_RolesEntry { key: number; value: GameModeRole | undefined; } export interface GameMode { name: I18nString | undefined; } export interface GameModeRole { provisions: number[]; consumables: number[]; } function createBaseGameDefinitions(): GameDefinitions { return { version: "", nations: [], gameModes: {}, roles: {} }; } export const GameDefinitions: MessageFns = { encode(message: GameDefinitions, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.version !== "") { writer.uint32(10).string(message.version); } for (const v of message.nations) { writer.uint32(18).string(v!); } globalThis.Object.entries(message.gameModes).forEach(([key, value]: [string, GameMode]) => { GameDefinitions_GameModesEntry.encode({ key: key as any, value }, writer.uint32(26).fork()).join(); }); globalThis.Object.entries(message.roles).forEach(([key, value]: [string, GameModeRole]) => { GameDefinitions_RolesEntry.encode({ key: key as any, value }, writer.uint32(34).fork()).join(); }); return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): GameDefinitions { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseGameDefinitions(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.version = reader.string(); continue; } case 2: { if (tag !== 18) { break; } message.nations.push(reader.string()); continue; } case 3: { if (tag !== 26) { break; } const entry3 = GameDefinitions_GameModesEntry.decode(reader, reader.uint32()); if (entry3.value !== undefined) { message.gameModes[entry3.key] = entry3.value; } continue; } case 4: { if (tag !== 34) { break; } const entry4 = GameDefinitions_RolesEntry.decode(reader, reader.uint32()); if (entry4.value !== undefined) { message.roles[entry4.key] = entry4.value; } continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object: any): GameDefinitions { return { version: isSet(object.version) ? globalThis.String(object.version) : "", nations: globalThis.Array.isArray(object?.nations) ? object.nations.map((e: any) => globalThis.String(e)) : [], gameModes: isObject(object.gameModes) ? (globalThis.Object.entries(object.gameModes) as [string, any][]).reduce( (acc: { [key: number]: GameMode }, [key, value]: [string, any]) => { acc[globalThis.Number(key)] = GameMode.fromJSON(value); return acc; }, {}, ) : {}, roles: isObject(object.roles) ? (globalThis.Object.entries(object.roles) as [string, any][]).reduce( (acc: { [key: number]: GameModeRole }, [key, value]: [string, any]) => { acc[globalThis.Number(key)] = GameModeRole.fromJSON(value); return acc; }, {}, ) : {}, }; }, toJSON(message: GameDefinitions): unknown { const obj: any = {}; if (message.version !== "") { obj.version = message.version; } if (message.nations?.length) { obj.nations = message.nations; } if (message.gameModes) { const entries = globalThis.Object.entries(message.gameModes) as [string, GameMode][]; if (entries.length > 0) { obj.gameModes = {}; entries.forEach(([k, v]) => { obj.gameModes[k] = GameMode.toJSON(v); }); } } if (message.roles) { const entries = globalThis.Object.entries(message.roles) as [string, GameModeRole][]; if (entries.length > 0) { obj.roles = {}; entries.forEach(([k, v]) => { obj.roles[k] = GameModeRole.toJSON(v); }); } } return obj; }, create, I>>(base?: I): GameDefinitions { return GameDefinitions.fromPartial(base ?? ({} as any)); }, fromPartial, I>>(object: I): GameDefinitions { const message = createBaseGameDefinitions(); message.version = object.version ?? ""; message.nations = object.nations?.map((e) => e) || []; message.gameModes = (globalThis.Object.entries(object.gameModes ?? {}) as [string, GameMode][]).reduce( (acc: { [key: number]: GameMode }, [key, value]: [string, GameMode]) => { if (value !== undefined) { acc[globalThis.Number(key)] = GameMode.fromPartial(value); } return acc; }, {}, ); message.roles = (globalThis.Object.entries(object.roles ?? {}) as [string, GameModeRole][]).reduce( (acc: { [key: number]: GameModeRole }, [key, value]: [string, GameModeRole]) => { if (value !== undefined) { acc[globalThis.Number(key)] = GameModeRole.fromPartial(value); } return acc; }, {}, ); return message; }, }; function createBaseGameDefinitions_GameModesEntry(): GameDefinitions_GameModesEntry { return { key: 0, value: undefined }; } export const GameDefinitions_GameModesEntry: MessageFns = { encode(message: GameDefinitions_GameModesEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.key !== 0) { writer.uint32(8).uint32(message.key); } if (message.value !== undefined) { GameMode.encode(message.value, writer.uint32(18).fork()).join(); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): GameDefinitions_GameModesEntry { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseGameDefinitions_GameModesEntry(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 8) { break; } message.key = reader.uint32(); continue; } case 2: { if (tag !== 18) { break; } message.value = GameMode.decode(reader, reader.uint32()); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object: any): GameDefinitions_GameModesEntry { return { key: isSet(object.key) ? globalThis.Number(object.key) : 0, value: isSet(object.value) ? GameMode.fromJSON(object.value) : undefined, }; }, toJSON(message: GameDefinitions_GameModesEntry): unknown { const obj: any = {}; if (message.key !== 0) { obj.key = Math.round(message.key); } if (message.value !== undefined) { obj.value = GameMode.toJSON(message.value); } return obj; }, create, I>>(base?: I): GameDefinitions_GameModesEntry { return GameDefinitions_GameModesEntry.fromPartial(base ?? ({} as any)); }, fromPartial, I>>( object: I, ): GameDefinitions_GameModesEntry { const message = createBaseGameDefinitions_GameModesEntry(); message.key = object.key ?? 0; message.value = (object.value !== undefined && object.value !== null) ? GameMode.fromPartial(object.value) : undefined; return message; }, }; function createBaseGameDefinitions_RolesEntry(): GameDefinitions_RolesEntry { return { key: 0, value: undefined }; } export const GameDefinitions_RolesEntry: MessageFns = { encode(message: GameDefinitions_RolesEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.key !== 0) { writer.uint32(8).uint32(message.key); } if (message.value !== undefined) { GameModeRole.encode(message.value, writer.uint32(18).fork()).join(); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): GameDefinitions_RolesEntry { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseGameDefinitions_RolesEntry(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 8) { break; } message.key = reader.uint32(); continue; } case 2: { if (tag !== 18) { break; } message.value = GameModeRole.decode(reader, reader.uint32()); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object: any): GameDefinitions_RolesEntry { return { key: isSet(object.key) ? globalThis.Number(object.key) : 0, value: isSet(object.value) ? GameModeRole.fromJSON(object.value) : undefined, }; }, toJSON(message: GameDefinitions_RolesEntry): unknown { const obj: any = {}; if (message.key !== 0) { obj.key = Math.round(message.key); } if (message.value !== undefined) { obj.value = GameModeRole.toJSON(message.value); } return obj; }, create, I>>(base?: I): GameDefinitions_RolesEntry { return GameDefinitions_RolesEntry.fromPartial(base ?? ({} as any)); }, fromPartial, I>>(object: I): GameDefinitions_RolesEntry { const message = createBaseGameDefinitions_RolesEntry(); message.key = object.key ?? 0; message.value = (object.value !== undefined && object.value !== null) ? GameModeRole.fromPartial(object.value) : undefined; return message; }, }; function createBaseGameMode(): GameMode { return { name: undefined }; } export const GameMode: MessageFns = { encode(message: GameMode, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.name !== undefined) { I18nString.encode(message.name, writer.uint32(10).fork()).join(); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): GameMode { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseGameMode(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.name = I18nString.decode(reader, reader.uint32()); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object: any): GameMode { return { name: isSet(object.name) ? I18nString.fromJSON(object.name) : undefined }; }, toJSON(message: GameMode): unknown { const obj: any = {}; if (message.name !== undefined) { obj.name = I18nString.toJSON(message.name); } return obj; }, create, I>>(base?: I): GameMode { return GameMode.fromPartial(base ?? ({} as any)); }, fromPartial, I>>(object: I): GameMode { const message = createBaseGameMode(); message.name = (object.name !== undefined && object.name !== null) ? I18nString.fromPartial(object.name) : undefined; return message; }, }; function createBaseGameModeRole(): GameModeRole { return { provisions: [], consumables: [] }; } export const GameModeRole: MessageFns = { encode(message: GameModeRole, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { for (const v of message.provisions) { writer.uint32(8).uint32(v!); } for (const v of message.consumables) { writer.uint32(16).uint32(v!); } return writer; }, decode(input: BinaryReader | Uint8Array, length?: number): GameModeRole { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseGameModeRole(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag === 8) { message.provisions.push(reader.uint32()); continue; } if (tag === 10) { const end2 = reader.uint32() + reader.pos; while (reader.pos < end2) { message.provisions.push(reader.uint32()); } continue; } break; } case 2: { if (tag === 16) { message.consumables.push(reader.uint32()); continue; } if (tag === 18) { const end2 = reader.uint32() + reader.pos; while (reader.pos < end2) { message.consumables.push(reader.uint32()); } continue; } break; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object: any): GameModeRole { return { provisions: globalThis.Array.isArray(object?.provisions) ? object.provisions.map((e: any) => globalThis.Number(e)) : [], consumables: globalThis.Array.isArray(object?.consumables) ? object.consumables.map((e: any) => globalThis.Number(e)) : [], }; }, toJSON(message: GameModeRole): unknown { const obj: any = {}; if (message.provisions?.length) { obj.provisions = message.provisions.map((e) => Math.round(e)); } if (message.consumables?.length) { obj.consumables = message.consumables.map((e) => Math.round(e)); } return obj; }, create, I>>(base?: I): GameModeRole { return GameModeRole.fromPartial(base ?? ({} as any)); }, fromPartial, I>>(object: I): GameModeRole { const message = createBaseGameModeRole(); message.provisions = object.provisions?.map((e) => e) || []; message.consumables = object.consumables?.map((e) => e) || []; return message; }, }; type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; export type DeepPartial = T extends Builtin ? T : T extends globalThis.Array ? globalThis.Array> : T extends ReadonlyArray ? ReadonlyArray> : T extends { $case: string; value: unknown } ? { $case: T["$case"]; value?: DeepPartial } : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isObject(value: any): boolean { return typeof value === "object" && value !== null; } function isSet(value: any): boolean { return value !== null && value !== undefined; } export interface MessageFns { encode(message: T, writer?: BinaryWriter): BinaryWriter; decode(input: BinaryReader | Uint8Array, length?: number): T; fromJSON(object: any): T; toJSON(message: T): unknown; create, I>>(base?: I): T; fromPartial, I>>(object: I): T; }