node-cs2
Version:
Modern CS2/CS:GO Game Coordinator integration with latest GameTracking-CS2 protobuf definitions. Includes support for highlight_reel, wrapped_sticker, variations, Promise-based API, crate opening, sticker/patch/keychain operations, and all modern CS2 fiel
1,262 lines (1,176 loc) • 889 kB
JavaScript
/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
(function(global, factory) { /* global define, require, module */
/* AMD */ if (typeof define === 'function' && define.amd)
define(["protobufjs/minimal"], factory);
/* CommonJS */ else if (typeof require === 'function' && typeof module === 'object' && module && module.exports)
module.exports = factory(require("protobufjs/minimal"));
})(this, function($protobuf) {
"use strict";
// Common aliases
var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
// Exported root namespace
var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});
/**
* EHitGroup enum.
* @exports EHitGroup
* @enum {number}
* @property {number} EHG_Generic=0 EHG_Generic value
* @property {number} EHG_Head=1 EHG_Head value
* @property {number} EHG_Chest=2 EHG_Chest value
* @property {number} EHG_Stomach=3 EHG_Stomach value
* @property {number} EHG_LeftArm=4 EHG_LeftArm value
* @property {number} EHG_RightArm=5 EHG_RightArm value
* @property {number} EHG_LeftLeg=6 EHG_LeftLeg value
* @property {number} EHG_RightLeg=7 EHG_RightLeg value
* @property {number} EHG_Gear=8 EHG_Gear value
* @property {number} EHG_Miss=9 EHG_Miss value
*/
$root.EHitGroup = (function() {
var valuesById = {}, values = Object.create(valuesById);
values[valuesById[0] = "EHG_Generic"] = 0;
values[valuesById[1] = "EHG_Head"] = 1;
values[valuesById[2] = "EHG_Chest"] = 2;
values[valuesById[3] = "EHG_Stomach"] = 3;
values[valuesById[4] = "EHG_LeftArm"] = 4;
values[valuesById[5] = "EHG_RightArm"] = 5;
values[valuesById[6] = "EHG_LeftLeg"] = 6;
values[valuesById[7] = "EHG_RightLeg"] = 7;
values[valuesById[8] = "EHG_Gear"] = 8;
values[valuesById[9] = "EHG_Miss"] = 9;
return values;
})();
/**
* ETeam enum.
* @exports ETeam
* @enum {number}
* @property {number} ET_Unknown=0 ET_Unknown value
* @property {number} ET_Spectator=1 ET_Spectator value
* @property {number} ET_Terrorist=2 ET_Terrorist value
* @property {number} ET_CT=3 ET_CT value
*/
$root.ETeam = (function() {
var valuesById = {}, values = Object.create(valuesById);
values[valuesById[0] = "ET_Unknown"] = 0;
values[valuesById[1] = "ET_Spectator"] = 1;
values[valuesById[2] = "ET_Terrorist"] = 2;
values[valuesById[3] = "ET_CT"] = 3;
return values;
})();
/**
* EWeaponType enum.
* @exports EWeaponType
* @enum {number}
* @property {number} EWT_Knife=0 EWT_Knife value
* @property {number} EWT_Pistol=1 EWT_Pistol value
* @property {number} EWT_SubMachineGun=2 EWT_SubMachineGun value
* @property {number} EWT_Rifle=3 EWT_Rifle value
* @property {number} EWT_Shotgun=4 EWT_Shotgun value
* @property {number} EWT_SniperRifle=5 EWT_SniperRifle value
* @property {number} EWT_MachineGun=6 EWT_MachineGun value
* @property {number} EWT_C4=7 EWT_C4 value
* @property {number} EWT_Grenade=8 EWT_Grenade value
* @property {number} EWT_Equipment=9 EWT_Equipment value
* @property {number} EWT_StackableItem=10 EWT_StackableItem value
* @property {number} EWT_Unknown=11 EWT_Unknown value
*/
$root.EWeaponType = (function() {
var valuesById = {}, values = Object.create(valuesById);
values[valuesById[0] = "EWT_Knife"] = 0;
values[valuesById[1] = "EWT_Pistol"] = 1;
values[valuesById[2] = "EWT_SubMachineGun"] = 2;
values[valuesById[3] = "EWT_Rifle"] = 3;
values[valuesById[4] = "EWT_Shotgun"] = 4;
values[valuesById[5] = "EWT_SniperRifle"] = 5;
values[valuesById[6] = "EWT_MachineGun"] = 6;
values[valuesById[7] = "EWT_C4"] = 7;
values[valuesById[8] = "EWT_Grenade"] = 8;
values[valuesById[9] = "EWT_Equipment"] = 9;
values[valuesById[10] = "EWT_StackableItem"] = 10;
values[valuesById[11] = "EWT_Unknown"] = 11;
return values;
})();
$root.MLDict = (function() {
/**
* Properties of a MLDict.
* @exports IMLDict
* @interface IMLDict
* @property {string|null} [key] MLDict key
* @property {string|null} [val_string] MLDict val_string
* @property {number|null} [val_int] MLDict val_int
* @property {number|null} [val_float] MLDict val_float
*/
/**
* Constructs a new MLDict.
* @exports MLDict
* @classdesc Represents a MLDict.
* @implements IMLDict
* @constructor
* @param {IMLDict=} [properties] Properties to set
*/
function MLDict(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
}
/**
* MLDict key.
* @member {string} key
* @memberof MLDict
* @instance
*/
MLDict.prototype.key = "";
/**
* MLDict val_string.
* @member {string} val_string
* @memberof MLDict
* @instance
*/
MLDict.prototype.val_string = "";
/**
* MLDict val_int.
* @member {number} val_int
* @memberof MLDict
* @instance
*/
MLDict.prototype.val_int = 0;
/**
* MLDict val_float.
* @member {number} val_float
* @memberof MLDict
* @instance
*/
MLDict.prototype.val_float = 0;
/**
* Creates a new MLDict instance using the specified properties.
* @function create
* @memberof MLDict
* @static
* @param {IMLDict=} [properties] Properties to set
* @returns {MLDict} MLDict instance
*/
MLDict.create = function create(properties) {
return new MLDict(properties);
};
/**
* Encodes the specified MLDict message. Does not implicitly {@link MLDict.verify|verify} messages.
* @function encode
* @memberof MLDict
* @static
* @param {IMLDict} message MLDict message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
MLDict.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.key != null && Object.hasOwnProperty.call(message, "key"))
writer.uint32(/* id 1, wireType 2 =*/10).string(message.key);
if (message.val_string != null && Object.hasOwnProperty.call(message, "val_string"))
writer.uint32(/* id 2, wireType 2 =*/18).string(message.val_string);
if (message.val_int != null && Object.hasOwnProperty.call(message, "val_int"))
writer.uint32(/* id 3, wireType 0 =*/24).int32(message.val_int);
if (message.val_float != null && Object.hasOwnProperty.call(message, "val_float"))
writer.uint32(/* id 4, wireType 5 =*/37).float(message.val_float);
return writer;
};
/**
* Encodes the specified MLDict message, length delimited. Does not implicitly {@link MLDict.verify|verify} messages.
* @function encodeDelimited
* @memberof MLDict
* @static
* @param {IMLDict} message MLDict message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
MLDict.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
};
/**
* Decodes a MLDict message from the specified reader or buffer.
* @function decode
* @memberof MLDict
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {MLDict} MLDict
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
MLDict.decode = function decode(reader, length, error) {
if (!(reader instanceof $Reader))
reader = $Reader.create(reader);
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.MLDict();
while (reader.pos < end) {
var tag = reader.uint32();
if (tag === error)
break;
switch (tag >>> 3) {
case 1: {
message.key = reader.string();
break;
}
case 2: {
message.val_string = reader.string();
break;
}
case 3: {
message.val_int = reader.int32();
break;
}
case 4: {
message.val_float = reader.float();
break;
}
default:
reader.skipType(tag & 7);
break;
}
}
return message;
};
/**
* Decodes a MLDict message from the specified reader or buffer, length delimited.
* @function decodeDelimited
* @memberof MLDict
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @returns {MLDict} MLDict
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
MLDict.decodeDelimited = function decodeDelimited(reader) {
if (!(reader instanceof $Reader))
reader = new $Reader(reader);
return this.decode(reader, reader.uint32());
};
/**
* Verifies a MLDict message.
* @function verify
* @memberof MLDict
* @static
* @param {Object.<string,*>} message Plain object to verify
* @returns {string|null} `null` if valid, otherwise the reason why it is not
*/
MLDict.verify = function verify(message) {
if (typeof message !== "object" || message === null)
return "object expected";
if (message.key != null && message.hasOwnProperty("key"))
if (!$util.isString(message.key))
return "key: string expected";
if (message.val_string != null && message.hasOwnProperty("val_string"))
if (!$util.isString(message.val_string))
return "val_string: string expected";
if (message.val_int != null && message.hasOwnProperty("val_int"))
if (!$util.isInteger(message.val_int))
return "val_int: integer expected";
if (message.val_float != null && message.hasOwnProperty("val_float"))
if (typeof message.val_float !== "number")
return "val_float: number expected";
return null;
};
/**
* Creates a MLDict message from a plain object. Also converts values to their respective internal types.
* @function fromObject
* @memberof MLDict
* @static
* @param {Object.<string,*>} object Plain object
* @returns {MLDict} MLDict
*/
MLDict.fromObject = function fromObject(object) {
if (object instanceof $root.MLDict)
return object;
var message = new $root.MLDict();
if (object.key != null)
message.key = String(object.key);
if (object.val_string != null)
message.val_string = String(object.val_string);
if (object.val_int != null)
message.val_int = object.val_int | 0;
if (object.val_float != null)
message.val_float = Number(object.val_float);
return message;
};
/**
* Creates a plain object from a MLDict message. Also converts values to other types if specified.
* @function toObject
* @memberof MLDict
* @static
* @param {MLDict} message MLDict
* @param {$protobuf.IConversionOptions} [options] Conversion options
* @returns {Object.<string,*>} Plain object
*/
MLDict.toObject = function toObject(message, options) {
if (!options)
options = {};
var object = {};
if (options.defaults) {
object.key = "";
object.val_string = "";
object.val_int = 0;
object.val_float = 0;
}
if (message.key != null && message.hasOwnProperty("key"))
object.key = message.key;
if (message.val_string != null && message.hasOwnProperty("val_string"))
object.val_string = message.val_string;
if (message.val_int != null && message.hasOwnProperty("val_int"))
object.val_int = message.val_int;
if (message.val_float != null && message.hasOwnProperty("val_float"))
object.val_float = options.json && !isFinite(message.val_float) ? String(message.val_float) : message.val_float;
return object;
};
/**
* Converts this MLDict to JSON.
* @function toJSON
* @memberof MLDict
* @instance
* @returns {Object.<string,*>} JSON object
*/
MLDict.prototype.toJSON = function toJSON() {
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
};
/**
* Gets the default type url for MLDict
* @function getTypeUrl
* @memberof MLDict
* @static
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
* @returns {string} The default type url
*/
MLDict.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
if (typeUrlPrefix === undefined) {
typeUrlPrefix = "type.googleapis.com";
}
return typeUrlPrefix + "/MLDict";
};
return MLDict;
})();
$root.MLEvent = (function() {
/**
* Properties of a MLEvent.
* @exports IMLEvent
* @interface IMLEvent
* @property {string|null} [event_name] MLEvent event_name
* @property {Array.<IMLDict>|null} [data] MLEvent data
*/
/**
* Constructs a new MLEvent.
* @exports MLEvent
* @classdesc Represents a MLEvent.
* @implements IMLEvent
* @constructor
* @param {IMLEvent=} [properties] Properties to set
*/
function MLEvent(properties) {
this.data = [];
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
}
/**
* MLEvent event_name.
* @member {string} event_name
* @memberof MLEvent
* @instance
*/
MLEvent.prototype.event_name = "";
/**
* MLEvent data.
* @member {Array.<IMLDict>} data
* @memberof MLEvent
* @instance
*/
MLEvent.prototype.data = $util.emptyArray;
/**
* Creates a new MLEvent instance using the specified properties.
* @function create
* @memberof MLEvent
* @static
* @param {IMLEvent=} [properties] Properties to set
* @returns {MLEvent} MLEvent instance
*/
MLEvent.create = function create(properties) {
return new MLEvent(properties);
};
/**
* Encodes the specified MLEvent message. Does not implicitly {@link MLEvent.verify|verify} messages.
* @function encode
* @memberof MLEvent
* @static
* @param {IMLEvent} message MLEvent message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
MLEvent.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.event_name != null && Object.hasOwnProperty.call(message, "event_name"))
writer.uint32(/* id 1, wireType 2 =*/10).string(message.event_name);
if (message.data != null && message.data.length)
for (var i = 0; i < message.data.length; ++i)
$root.MLDict.encode(message.data[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim();
return writer;
};
/**
* Encodes the specified MLEvent message, length delimited. Does not implicitly {@link MLEvent.verify|verify} messages.
* @function encodeDelimited
* @memberof MLEvent
* @static
* @param {IMLEvent} message MLEvent message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
MLEvent.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
};
/**
* Decodes a MLEvent message from the specified reader or buffer.
* @function decode
* @memberof MLEvent
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {MLEvent} MLEvent
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
MLEvent.decode = function decode(reader, length, error) {
if (!(reader instanceof $Reader))
reader = $Reader.create(reader);
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.MLEvent();
while (reader.pos < end) {
var tag = reader.uint32();
if (tag === error)
break;
switch (tag >>> 3) {
case 1: {
message.event_name = reader.string();
break;
}
case 2: {
if (!(message.data && message.data.length))
message.data = [];
message.data.push($root.MLDict.decode(reader, reader.uint32()));
break;
}
default:
reader.skipType(tag & 7);
break;
}
}
return message;
};
/**
* Decodes a MLEvent message from the specified reader or buffer, length delimited.
* @function decodeDelimited
* @memberof MLEvent
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @returns {MLEvent} MLEvent
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
MLEvent.decodeDelimited = function decodeDelimited(reader) {
if (!(reader instanceof $Reader))
reader = new $Reader(reader);
return this.decode(reader, reader.uint32());
};
/**
* Verifies a MLEvent message.
* @function verify
* @memberof MLEvent
* @static
* @param {Object.<string,*>} message Plain object to verify
* @returns {string|null} `null` if valid, otherwise the reason why it is not
*/
MLEvent.verify = function verify(message) {
if (typeof message !== "object" || message === null)
return "object expected";
if (message.event_name != null && message.hasOwnProperty("event_name"))
if (!$util.isString(message.event_name))
return "event_name: string expected";
if (message.data != null && message.hasOwnProperty("data")) {
if (!Array.isArray(message.data))
return "data: array expected";
for (var i = 0; i < message.data.length; ++i) {
var error = $root.MLDict.verify(message.data[i]);
if (error)
return "data." + error;
}
}
return null;
};
/**
* Creates a MLEvent message from a plain object. Also converts values to their respective internal types.
* @function fromObject
* @memberof MLEvent
* @static
* @param {Object.<string,*>} object Plain object
* @returns {MLEvent} MLEvent
*/
MLEvent.fromObject = function fromObject(object) {
if (object instanceof $root.MLEvent)
return object;
var message = new $root.MLEvent();
if (object.event_name != null)
message.event_name = String(object.event_name);
if (object.data) {
if (!Array.isArray(object.data))
throw TypeError(".MLEvent.data: array expected");
message.data = [];
for (var i = 0; i < object.data.length; ++i) {
if (typeof object.data[i] !== "object")
throw TypeError(".MLEvent.data: object expected");
message.data[i] = $root.MLDict.fromObject(object.data[i]);
}
}
return message;
};
/**
* Creates a plain object from a MLEvent message. Also converts values to other types if specified.
* @function toObject
* @memberof MLEvent
* @static
* @param {MLEvent} message MLEvent
* @param {$protobuf.IConversionOptions} [options] Conversion options
* @returns {Object.<string,*>} Plain object
*/
MLEvent.toObject = function toObject(message, options) {
if (!options)
options = {};
var object = {};
if (options.arrays || options.defaults)
object.data = [];
if (options.defaults)
object.event_name = "";
if (message.event_name != null && message.hasOwnProperty("event_name"))
object.event_name = message.event_name;
if (message.data && message.data.length) {
object.data = [];
for (var j = 0; j < message.data.length; ++j)
object.data[j] = $root.MLDict.toObject(message.data[j], options);
}
return object;
};
/**
* Converts this MLEvent to JSON.
* @function toJSON
* @memberof MLEvent
* @instance
* @returns {Object.<string,*>} JSON object
*/
MLEvent.prototype.toJSON = function toJSON() {
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
};
/**
* Gets the default type url for MLEvent
* @function getTypeUrl
* @memberof MLEvent
* @static
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
* @returns {string} The default type url
*/
MLEvent.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
if (typeUrlPrefix === undefined) {
typeUrlPrefix = "type.googleapis.com";
}
return typeUrlPrefix + "/MLEvent";
};
return MLEvent;
})();
$root.MLMatchState = (function() {
/**
* Properties of a MLMatchState.
* @exports IMLMatchState
* @interface IMLMatchState
* @property {string|null} [game_mode] MLMatchState game_mode
* @property {string|null} [phase] MLMatchState phase
* @property {number|null} [round] MLMatchState round
* @property {number|null} [score_ct] MLMatchState score_ct
* @property {number|null} [score_t] MLMatchState score_t
*/
/**
* Constructs a new MLMatchState.
* @exports MLMatchState
* @classdesc Represents a MLMatchState.
* @implements IMLMatchState
* @constructor
* @param {IMLMatchState=} [properties] Properties to set
*/
function MLMatchState(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
}
/**
* MLMatchState game_mode.
* @member {string} game_mode
* @memberof MLMatchState
* @instance
*/
MLMatchState.prototype.game_mode = "";
/**
* MLMatchState phase.
* @member {string} phase
* @memberof MLMatchState
* @instance
*/
MLMatchState.prototype.phase = "";
/**
* MLMatchState round.
* @member {number} round
* @memberof MLMatchState
* @instance
*/
MLMatchState.prototype.round = 0;
/**
* MLMatchState score_ct.
* @member {number} score_ct
* @memberof MLMatchState
* @instance
*/
MLMatchState.prototype.score_ct = 0;
/**
* MLMatchState score_t.
* @member {number} score_t
* @memberof MLMatchState
* @instance
*/
MLMatchState.prototype.score_t = 0;
/**
* Creates a new MLMatchState instance using the specified properties.
* @function create
* @memberof MLMatchState
* @static
* @param {IMLMatchState=} [properties] Properties to set
* @returns {MLMatchState} MLMatchState instance
*/
MLMatchState.create = function create(properties) {
return new MLMatchState(properties);
};
/**
* Encodes the specified MLMatchState message. Does not implicitly {@link MLMatchState.verify|verify} messages.
* @function encode
* @memberof MLMatchState
* @static
* @param {IMLMatchState} message MLMatchState message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
MLMatchState.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.game_mode != null && Object.hasOwnProperty.call(message, "game_mode"))
writer.uint32(/* id 1, wireType 2 =*/10).string(message.game_mode);
if (message.phase != null && Object.hasOwnProperty.call(message, "phase"))
writer.uint32(/* id 2, wireType 2 =*/18).string(message.phase);
if (message.round != null && Object.hasOwnProperty.call(message, "round"))
writer.uint32(/* id 3, wireType 0 =*/24).int32(message.round);
if (message.score_ct != null && Object.hasOwnProperty.call(message, "score_ct"))
writer.uint32(/* id 4, wireType 0 =*/32).int32(message.score_ct);
if (message.score_t != null && Object.hasOwnProperty.call(message, "score_t"))
writer.uint32(/* id 5, wireType 0 =*/40).int32(message.score_t);
return writer;
};
/**
* Encodes the specified MLMatchState message, length delimited. Does not implicitly {@link MLMatchState.verify|verify} messages.
* @function encodeDelimited
* @memberof MLMatchState
* @static
* @param {IMLMatchState} message MLMatchState message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
MLMatchState.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
};
/**
* Decodes a MLMatchState message from the specified reader or buffer.
* @function decode
* @memberof MLMatchState
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {MLMatchState} MLMatchState
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
MLMatchState.decode = function decode(reader, length, error) {
if (!(reader instanceof $Reader))
reader = $Reader.create(reader);
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.MLMatchState();
while (reader.pos < end) {
var tag = reader.uint32();
if (tag === error)
break;
switch (tag >>> 3) {
case 1: {
message.game_mode = reader.string();
break;
}
case 2: {
message.phase = reader.string();
break;
}
case 3: {
message.round = reader.int32();
break;
}
case 4: {
message.score_ct = reader.int32();
break;
}
case 5: {
message.score_t = reader.int32();
break;
}
default:
reader.skipType(tag & 7);
break;
}
}
return message;
};
/**
* Decodes a MLMatchState message from the specified reader or buffer, length delimited.
* @function decodeDelimited
* @memberof MLMatchState
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @returns {MLMatchState} MLMatchState
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
MLMatchState.decodeDelimited = function decodeDelimited(reader) {
if (!(reader instanceof $Reader))
reader = new $Reader(reader);
return this.decode(reader, reader.uint32());
};
/**
* Verifies a MLMatchState message.
* @function verify
* @memberof MLMatchState
* @static
* @param {Object.<string,*>} message Plain object to verify
* @returns {string|null} `null` if valid, otherwise the reason why it is not
*/
MLMatchState.verify = function verify(message) {
if (typeof message !== "object" || message === null)
return "object expected";
if (message.game_mode != null && message.hasOwnProperty("game_mode"))
if (!$util.isString(message.game_mode))
return "game_mode: string expected";
if (message.phase != null && message.hasOwnProperty("phase"))
if (!$util.isString(message.phase))
return "phase: string expected";
if (message.round != null && message.hasOwnProperty("round"))
if (!$util.isInteger(message.round))
return "round: integer expected";
if (message.score_ct != null && message.hasOwnProperty("score_ct"))
if (!$util.isInteger(message.score_ct))
return "score_ct: integer expected";
if (message.score_t != null && message.hasOwnProperty("score_t"))
if (!$util.isInteger(message.score_t))
return "score_t: integer expected";
return null;
};
/**
* Creates a MLMatchState message from a plain object. Also converts values to their respective internal types.
* @function fromObject
* @memberof MLMatchState
* @static
* @param {Object.<string,*>} object Plain object
* @returns {MLMatchState} MLMatchState
*/
MLMatchState.fromObject = function fromObject(object) {
if (object instanceof $root.MLMatchState)
return object;
var message = new $root.MLMatchState();
if (object.game_mode != null)
message.game_mode = String(object.game_mode);
if (object.phase != null)
message.phase = String(object.phase);
if (object.round != null)
message.round = object.round | 0;
if (object.score_ct != null)
message.score_ct = object.score_ct | 0;
if (object.score_t != null)
message.score_t = object.score_t | 0;
return message;
};
/**
* Creates a plain object from a MLMatchState message. Also converts values to other types if specified.
* @function toObject
* @memberof MLMatchState
* @static
* @param {MLMatchState} message MLMatchState
* @param {$protobuf.IConversionOptions} [options] Conversion options
* @returns {Object.<string,*>} Plain object
*/
MLMatchState.toObject = function toObject(message, options) {
if (!options)
options = {};
var object = {};
if (options.defaults) {
object.game_mode = "";
object.phase = "";
object.round = 0;
object.score_ct = 0;
object.score_t = 0;
}
if (message.game_mode != null && message.hasOwnProperty("game_mode"))
object.game_mode = message.game_mode;
if (message.phase != null && message.hasOwnProperty("phase"))
object.phase = message.phase;
if (message.round != null && message.hasOwnProperty("round"))
object.round = message.round;
if (message.score_ct != null && message.hasOwnProperty("score_ct"))
object.score_ct = message.score_ct;
if (message.score_t != null && message.hasOwnProperty("score_t"))
object.score_t = message.score_t;
return object;
};
/**
* Converts this MLMatchState to JSON.
* @function toJSON
* @memberof MLMatchState
* @instance
* @returns {Object.<string,*>} JSON object
*/
MLMatchState.prototype.toJSON = function toJSON() {
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
};
/**
* Gets the default type url for MLMatchState
* @function getTypeUrl
* @memberof MLMatchState
* @static
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
* @returns {string} The default type url
*/
MLMatchState.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
if (typeUrlPrefix === undefined) {
typeUrlPrefix = "type.googleapis.com";
}
return typeUrlPrefix + "/MLMatchState";
};
return MLMatchState;
})();
$root.MLRoundState = (function() {
/**
* Properties of a MLRoundState.
* @exports IMLRoundState
* @interface IMLRoundState
* @property {string|null} [phase] MLRoundState phase
* @property {ETeam|null} [win_team] MLRoundState win_team
* @property {string|null} [bomb_state] MLRoundState bomb_state
*/
/**
* Constructs a new MLRoundState.
* @exports MLRoundState
* @classdesc Represents a MLRoundState.
* @implements IMLRoundState
* @constructor
* @param {IMLRoundState=} [properties] Properties to set
*/
function MLRoundState(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
}
/**
* MLRoundState phase.
* @member {string} phase
* @memberof MLRoundState
* @instance
*/
MLRoundState.prototype.phase = "";
/**
* MLRoundState win_team.
* @member {ETeam} win_team
* @memberof MLRoundState
* @instance
*/
MLRoundState.prototype.win_team = 0;
/**
* MLRoundState bomb_state.
* @member {string} bomb_state
* @memberof MLRoundState
* @instance
*/
MLRoundState.prototype.bomb_state = "";
/**
* Creates a new MLRoundState instance using the specified properties.
* @function create
* @memberof MLRoundState
* @static
* @param {IMLRoundState=} [properties] Properties to set
* @returns {MLRoundState} MLRoundState instance
*/
MLRoundState.create = function create(properties) {
return new MLRoundState(properties);
};
/**
* Encodes the specified MLRoundState message. Does not implicitly {@link MLRoundState.verify|verify} messages.
* @function encode
* @memberof MLRoundState
* @static
* @param {IMLRoundState} message MLRoundState message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
MLRoundState.encode = function encode(message, writer) {
if (!writer)
writer = $Writer.create();
if (message.phase != null && Object.hasOwnProperty.call(message, "phase"))
writer.uint32(/* id 1, wireType 2 =*/10).string(message.phase);
if (message.win_team != null && Object.hasOwnProperty.call(message, "win_team"))
writer.uint32(/* id 2, wireType 0 =*/16).int32(message.win_team);
if (message.bomb_state != null && Object.hasOwnProperty.call(message, "bomb_state"))
writer.uint32(/* id 3, wireType 2 =*/26).string(message.bomb_state);
return writer;
};
/**
* Encodes the specified MLRoundState message, length delimited. Does not implicitly {@link MLRoundState.verify|verify} messages.
* @function encodeDelimited
* @memberof MLRoundState
* @static
* @param {IMLRoundState} message MLRoundState message or plain object to encode
* @param {$protobuf.Writer} [writer] Writer to encode to
* @returns {$protobuf.Writer} Writer
*/
MLRoundState.encodeDelimited = function encodeDelimited(message, writer) {
return this.encode(message, writer).ldelim();
};
/**
* Decodes a MLRoundState message from the specified reader or buffer.
* @function decode
* @memberof MLRoundState
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @param {number} [length] Message length if known beforehand
* @returns {MLRoundState} MLRoundState
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
MLRoundState.decode = function decode(reader, length, error) {
if (!(reader instanceof $Reader))
reader = $Reader.create(reader);
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.MLRoundState();
while (reader.pos < end) {
var tag = reader.uint32();
if (tag === error)
break;
switch (tag >>> 3) {
case 1: {
message.phase = reader.string();
break;
}
case 2: {
message.win_team = reader.int32();
break;
}
case 3: {
message.bomb_state = reader.string();
break;
}
default:
reader.skipType(tag & 7);
break;
}
}
return message;
};
/**
* Decodes a MLRoundState message from the specified reader or buffer, length delimited.
* @function decodeDelimited
* @memberof MLRoundState
* @static
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
* @returns {MLRoundState} MLRoundState
* @throws {Error} If the payload is not a reader or valid buffer
* @throws {$protobuf.util.ProtocolError} If required fields are missing
*/
MLRoundState.decodeDelimited = function decodeDelimited(reader) {
if (!(reader instanceof $Reader))
reader = new $Reader(reader);
return this.decode(reader, reader.uint32());
};
/**
* Verifies a MLRoundState message.
* @function verify
* @memberof MLRoundState
* @static
* @param {Object.<string,*>} message Plain object to verify
* @returns {string|null} `null` if valid, otherwise the reason why it is not
*/
MLRoundState.verify = function verify(message) {
if (typeof message !== "object" || message === null)
return "object expected";
if (message.phase != null && message.hasOwnProperty("phase"))
if (!$util.isString(message.phase))
return "phase: string expected";
if (message.win_team != null && message.hasOwnProperty("win_team"))
switch (message.win_team) {
default:
return "win_team: enum value expected";
case 0:
case 1:
case 2:
case 3:
break;
}
if (message.bomb_state != null && message.hasOwnProperty("bomb_state"))
if (!$util.isString(message.bomb_state))
return "bomb_state: string expected";
return null;
};
/**
* Creates a MLRoundState message from a plain object. Also converts values to their respective internal types.
* @function fromObject
* @memberof MLRoundState
* @static
* @param {Object.<string,*>} object Plain object
* @returns {MLRoundState} MLRoundState
*/
MLRoundState.fromObject = function fromObject(object) {
if (object instanceof $root.MLRoundState)
return object;
var message = new $root.MLRoundState();
if (object.phase != null)
message.phase = String(object.phase);
switch (object.win_team) {
default:
if (typeof object.win_team === "number") {
message.win_team = object.win_team;
break;
}
break;
case "ET_Unknown":
case 0:
message.win_team = 0;
break;
case "ET_Spectator":
case 1:
message.win_team = 1;
break;
case "ET_Terrorist":
case 2:
message.win_team = 2;
break;
case "ET_CT":
case 3:
message.win_team = 3;
break;
}
if (object.bomb_state != null)
message.bomb_state = String(object.bomb_state);
return message;
};
/**
* Creates a plain object from a MLRoundState message. Also converts values to other types if specified.
* @function toObject
* @memberof MLRoundState
* @static
* @param {MLRoundState} message MLRoundState
* @param {$protobuf.IConversionOptions} [options] Conversion options
* @returns {Object.<string,*>} Plain object
*/
MLRoundState.toObject = function toObject(message, options) {
if (!options)
options = {};
var object = {};
if (options.defaults) {
object.phase = "";
object.win_team = options.enums === String ? "ET_Unknown" : 0;
object.bomb_state = "";
}
if (message.phase != null && message.hasOwnProperty("phase"))
object.phase = message.phase;
if (message.win_team != null && message.hasOwnProperty("win_team"))
object.win_team = options.enums === String ? $root.ETeam[message.win_team] === undefined ? message.win_team : $root.ETeam[message.win_team] : message.win_team;
if (message.bomb_state != null && message.hasOwnProperty("bomb_state"))
object.bomb_state = message.bomb_state;
return object;
};
/**
* Converts this MLRoundState to JSON.
* @function toJSON
* @memberof MLRoundState
* @instance
* @returns {Object.<string,*>} JSON object
*/
MLRoundState.prototype.toJSON = function toJSON() {
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
};
/**
* Gets the default type url for MLRoundState
* @function getTypeUrl
* @memberof MLRoundState
* @static
* @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
* @returns {string} The default type url
*/
MLRoundState.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
if (typeUrlPrefix === undefined) {
typeUrlPrefix = "type.googleapis.com";
}
return typeUrlPrefix + "/MLRoundState";
};
return MLRoundState;
})();
$root.MLWeaponState = (function() {
/**
* Properties of a MLWeaponState.
* @exports IMLWeaponState
* @interface IMLWeaponState
* @property {number|null} [index] MLWeaponState index
* @property {string|null} [name] MLWeaponState name
* @property {EWeaponType|null} [type] MLWeaponState type
* @property {number|null} [ammo_clip] MLWeaponState ammo_clip
* @property {number|null} [ammo_clip_max] MLWeaponState ammo_clip_max
* @property {number|null} [ammo_reserve] MLWeaponState ammo_reserve
* @property {string|null} [state] MLWeaponState state
* @property {number|null} [recoil_index] MLWeaponState recoil_index
*/
/**
* Constructs a new MLWeaponState.
* @exports MLWeaponState
* @classdesc Represents a MLWeaponState.
* @implements IMLWeaponState
* @constructor
* @param {IMLWeaponState=} [properties] Properties to set
*/
function MLWeaponState(properties) {
if (properties)
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
if (properties[keys[i]] != null)
this[keys[i]] = properties[keys[i]];
}
/**
* MLWeaponState index.
* @member {number} index
* @memberof MLWeaponState
* @instance
*/
MLWeaponState.prototype.index = 0;
/**
* MLWeaponState name.
* @member {string} name
* @memberof MLWeaponState
* @instance
*/
MLWeaponState.prototype.name = "";
/**
* MLWeaponState type.
* @member {EWeaponType} type
* @memberof MLWeaponState
* @instance
*/
MLWeaponState.prototype.type = 0;
/**
* MLWeaponState ammo_clip.