From e6a939b107ad4b289c19a96d4d5f49cf452dca75 Mon Sep 17 00:00:00 2001 From: tangmingyou <234767776@qq.com> Date: Wed, 1 Feb 2023 17:49:49 +0800 Subject: [PATCH] join game table render --- src/api/proto.js | 2167 ++++++++++++++++++++++++++++- src/api/websocket.js | 10 +- src/api/wsapi.js | 8 + src/components/card.jsx | 12 +- src/pages/lobby/lobby.jsx | 38 +- src/pages/new_table/new_table.jsx | 5 +- src/pages/table/table.jsx | 271 ++-- src/utils/application.js | 4 +- src/utils/validator.js | 12 + 9 files changed, 2338 insertions(+), 189 deletions(-) create mode 100644 src/utils/validator.js diff --git a/src/api/proto.js b/src/api/proto.js index e9b96bb..b88b066 100644 --- a/src/api/proto.js +++ b/src/api/proto.js @@ -761,6 +761,7 @@ export const api = $root.api = (() => { * Properties of a ResSuccess. * @memberof api * @interface IResSuccess + * @property {number|null} [code] ResSuccess code */ /** @@ -778,6 +779,14 @@ export const api = $root.api = (() => { this[keys[i]] = properties[keys[i]]; } + /** + * ResSuccess code. + * @member {number} code + * @memberof api.ResSuccess + * @instance + */ + ResSuccess.prototype.code = 0; + /** * Creates a new ResSuccess instance using the specified properties. * @function create @@ -802,6 +811,8 @@ export const api = $root.api = (() => { ResSuccess.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); + if (message.code != null && Object.hasOwnProperty.call(message, "code")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.code); return writer; }; @@ -836,6 +847,10 @@ export const api = $root.api = (() => { while (reader.pos < end) { let tag = reader.uint32(); switch (tag >>> 3) { + case 1: { + message.code = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -871,6 +886,9 @@ export const api = $root.api = (() => { ResSuccess.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; + if (message.code != null && message.hasOwnProperty("code")) + if (!$util.isInteger(message.code)) + return "code: integer expected"; return null; }; @@ -885,7 +903,10 @@ export const api = $root.api = (() => { ResSuccess.fromObject = function fromObject(object) { if (object instanceof $root.api.ResSuccess) return object; - return new $root.api.ResSuccess(); + let message = new $root.api.ResSuccess(); + if (object.code != null) + message.code = object.code | 0; + return message; }; /** @@ -897,8 +918,15 @@ export const api = $root.api = (() => { * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - ResSuccess.toObject = function toObject() { - return {}; + ResSuccess.toObject = function toObject(message, options) { + if (!options) + options = {}; + let object = {}; + if (options.defaults) + object.code = 0; + if (message.code != null && message.hasOwnProperty("code")) + object.code = message.code; + return object; }; /** @@ -936,6 +964,7 @@ export const api = $root.api = (() => { * Properties of a ResFail. * @memberof api * @interface IResFail + * @property {number|null} [code] ResFail code * @property {string|null} [msg] ResFail msg */ @@ -954,6 +983,14 @@ export const api = $root.api = (() => { this[keys[i]] = properties[keys[i]]; } + /** + * ResFail code. + * @member {number} code + * @memberof api.ResFail + * @instance + */ + ResFail.prototype.code = 0; + /** * ResFail msg. * @member {string} msg @@ -986,6 +1023,8 @@ export const api = $root.api = (() => { ResFail.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); + if (message.code != null && Object.hasOwnProperty.call(message, "code")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.code); if (message.msg != null && Object.hasOwnProperty.call(message, "msg")) writer.uint32(/* id 3, wireType 2 =*/26).string(message.msg); return writer; @@ -1022,6 +1061,10 @@ export const api = $root.api = (() => { while (reader.pos < end) { let tag = reader.uint32(); switch (tag >>> 3) { + case 1: { + message.code = reader.int32(); + break; + } case 3: { message.msg = reader.string(); break; @@ -1061,6 +1104,9 @@ export const api = $root.api = (() => { ResFail.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; + if (message.code != null && message.hasOwnProperty("code")) + if (!$util.isInteger(message.code)) + return "code: integer expected"; if (message.msg != null && message.hasOwnProperty("msg")) if (!$util.isString(message.msg)) return "msg: string expected"; @@ -1079,6 +1125,8 @@ export const api = $root.api = (() => { if (object instanceof $root.api.ResFail) return object; let message = new $root.api.ResFail(); + if (object.code != null) + message.code = object.code | 0; if (object.msg != null) message.msg = String(object.msg); return message; @@ -1097,8 +1145,12 @@ export const api = $root.api = (() => { if (!options) options = {}; let object = {}; - if (options.defaults) + if (options.defaults) { + object.code = 0; object.msg = ""; + } + if (message.code != null && message.hasOwnProperty("code")) + object.code = message.code; if (message.msg != null && message.hasOwnProperty("msg")) object.msg = message.msg; return object; @@ -2980,6 +3032,7 @@ export const api = $root.api = (() => { * Properties of a ReqJoinTable. * @memberof api * @interface IReqJoinTable + * @property {number|null} [tableNo] ReqJoinTable tableNo */ /** @@ -2997,6 +3050,14 @@ export const api = $root.api = (() => { this[keys[i]] = properties[keys[i]]; } + /** + * ReqJoinTable tableNo. + * @member {number} tableNo + * @memberof api.ReqJoinTable + * @instance + */ + ReqJoinTable.prototype.tableNo = 0; + /** * Creates a new ReqJoinTable instance using the specified properties. * @function create @@ -3021,6 +3082,8 @@ export const api = $root.api = (() => { ReqJoinTable.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); + if (message.tableNo != null && Object.hasOwnProperty.call(message, "tableNo")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.tableNo); return writer; }; @@ -3055,6 +3118,10 @@ export const api = $root.api = (() => { while (reader.pos < end) { let tag = reader.uint32(); switch (tag >>> 3) { + case 1: { + message.tableNo = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -3090,6 +3157,9 @@ export const api = $root.api = (() => { ReqJoinTable.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; + if (message.tableNo != null && message.hasOwnProperty("tableNo")) + if (!$util.isInteger(message.tableNo)) + return "tableNo: integer expected"; return null; }; @@ -3104,7 +3174,10 @@ export const api = $root.api = (() => { ReqJoinTable.fromObject = function fromObject(object) { if (object instanceof $root.api.ReqJoinTable) return object; - return new $root.api.ReqJoinTable(); + let message = new $root.api.ReqJoinTable(); + if (object.tableNo != null) + message.tableNo = object.tableNo | 0; + return message; }; /** @@ -3116,8 +3189,15 @@ export const api = $root.api = (() => { * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - ReqJoinTable.toObject = function toObject() { - return {}; + ReqJoinTable.toObject = function toObject(message, options) { + if (!options) + options = {}; + let object = {}; + if (options.defaults) + object.tableNo = 0; + if (message.tableNo != null && message.hasOwnProperty("tableNo")) + object.tableNo = message.tableNo; + return object; }; /** @@ -3149,23 +3229,198 @@ export const api = $root.api = (() => { return ReqJoinTable; })(); - api.ResJoinTable = (function() { + api.ReqLeaveTable = (function() { + + /** + * Properties of a ReqLeaveTable. + * @memberof api + * @interface IReqLeaveTable + */ + + /** + * Constructs a new ReqLeaveTable. + * @memberof api + * @classdesc Represents a ReqLeaveTable. + * @implements IReqLeaveTable + * @constructor + * @param {api.IReqLeaveTable=} [properties] Properties to set + */ + function ReqLeaveTable(properties) { + if (properties) + for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Creates a new ReqLeaveTable instance using the specified properties. + * @function create + * @memberof api.ReqLeaveTable + * @static + * @param {api.IReqLeaveTable=} [properties] Properties to set + * @returns {api.ReqLeaveTable} ReqLeaveTable instance + */ + ReqLeaveTable.create = function create(properties) { + return new ReqLeaveTable(properties); + }; + + /** + * Encodes the specified ReqLeaveTable message. Does not implicitly {@link api.ReqLeaveTable.verify|verify} messages. + * @function encode + * @memberof api.ReqLeaveTable + * @static + * @param {api.IReqLeaveTable} message ReqLeaveTable message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReqLeaveTable.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified ReqLeaveTable message, length delimited. Does not implicitly {@link api.ReqLeaveTable.verify|verify} messages. + * @function encodeDelimited + * @memberof api.ReqLeaveTable + * @static + * @param {api.IReqLeaveTable} message ReqLeaveTable message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReqLeaveTable.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ReqLeaveTable message from the specified reader or buffer. + * @function decode + * @memberof api.ReqLeaveTable + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {api.ReqLeaveTable} ReqLeaveTable + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReqLeaveTable.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + let end = length === undefined ? reader.len : reader.pos + length, message = new $root.api.ReqLeaveTable(); + while (reader.pos < end) { + let tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ReqLeaveTable message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof api.ReqLeaveTable + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {api.ReqLeaveTable} ReqLeaveTable + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReqLeaveTable.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ReqLeaveTable message. + * @function verify + * @memberof api.ReqLeaveTable + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReqLeaveTable.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a ReqLeaveTable message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof api.ReqLeaveTable + * @static + * @param {Object.} object Plain object + * @returns {api.ReqLeaveTable} ReqLeaveTable + */ + ReqLeaveTable.fromObject = function fromObject(object) { + if (object instanceof $root.api.ReqLeaveTable) + return object; + return new $root.api.ReqLeaveTable(); + }; + + /** + * Creates a plain object from a ReqLeaveTable message. Also converts values to other types if specified. + * @function toObject + * @memberof api.ReqLeaveTable + * @static + * @param {api.ReqLeaveTable} message ReqLeaveTable + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReqLeaveTable.toObject = function toObject() { + return {}; + }; + + /** + * Converts this ReqLeaveTable to JSON. + * @function toJSON + * @memberof api.ReqLeaveTable + * @instance + * @returns {Object.} JSON object + */ + ReqLeaveTable.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ReqLeaveTable + * @function getTypeUrl + * @memberof api.ReqLeaveTable + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ReqLeaveTable.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/api.ReqLeaveTable"; + }; + + return ReqLeaveTable; + })(); + + api.ReqReadyStart = (function() { /** - * Properties of a ResJoinTable. + * Properties of a ReqReadyStart. * @memberof api - * @interface IResJoinTable + * @interface IReqReadyStart */ /** - * Constructs a new ResJoinTable. + * Constructs a new ReqReadyStart. * @memberof api - * @classdesc Represents a ResJoinTable. - * @implements IResJoinTable + * @classdesc Represents a ReqReadyStart. + * @implements IReqReadyStart * @constructor - * @param {api.IResJoinTable=} [properties] Properties to set + * @param {api.IReqReadyStart=} [properties] Properties to set */ - function ResJoinTable(properties) { + function ReqReadyStart(properties) { if (properties) for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -3173,60 +3428,60 @@ export const api = $root.api = (() => { } /** - * Creates a new ResJoinTable instance using the specified properties. + * Creates a new ReqReadyStart instance using the specified properties. * @function create - * @memberof api.ResJoinTable + * @memberof api.ReqReadyStart * @static - * @param {api.IResJoinTable=} [properties] Properties to set - * @returns {api.ResJoinTable} ResJoinTable instance + * @param {api.IReqReadyStart=} [properties] Properties to set + * @returns {api.ReqReadyStart} ReqReadyStart instance */ - ResJoinTable.create = function create(properties) { - return new ResJoinTable(properties); + ReqReadyStart.create = function create(properties) { + return new ReqReadyStart(properties); }; /** - * Encodes the specified ResJoinTable message. Does not implicitly {@link api.ResJoinTable.verify|verify} messages. + * Encodes the specified ReqReadyStart message. Does not implicitly {@link api.ReqReadyStart.verify|verify} messages. * @function encode - * @memberof api.ResJoinTable + * @memberof api.ReqReadyStart * @static - * @param {api.IResJoinTable} message ResJoinTable message or plain object to encode + * @param {api.IReqReadyStart} message ReqReadyStart message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - ResJoinTable.encode = function encode(message, writer) { + ReqReadyStart.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); return writer; }; /** - * Encodes the specified ResJoinTable message, length delimited. Does not implicitly {@link api.ResJoinTable.verify|verify} messages. + * Encodes the specified ReqReadyStart message, length delimited. Does not implicitly {@link api.ReqReadyStart.verify|verify} messages. * @function encodeDelimited - * @memberof api.ResJoinTable + * @memberof api.ReqReadyStart * @static - * @param {api.IResJoinTable} message ResJoinTable message or plain object to encode + * @param {api.IReqReadyStart} message ReqReadyStart message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - ResJoinTable.encodeDelimited = function encodeDelimited(message, writer) { + ReqReadyStart.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a ResJoinTable message from the specified reader or buffer. + * Decodes a ReqReadyStart message from the specified reader or buffer. * @function decode - * @memberof api.ResJoinTable + * @memberof api.ReqReadyStart * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {api.ResJoinTable} ResJoinTable + * @returns {api.ReqReadyStart} ReqReadyStart * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - ResJoinTable.decode = function decode(reader, length) { + ReqReadyStart.decode = function decode(reader, length) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - let end = length === undefined ? reader.len : reader.pos + length, message = new $root.api.ResJoinTable(); + let end = length === undefined ? reader.len : reader.pos + length, message = new $root.api.ReqReadyStart(); while (reader.pos < end) { let tag = reader.uint32(); switch (tag >>> 3) { @@ -3239,89 +3494,1883 @@ export const api = $root.api = (() => { }; /** - * Decodes a ResJoinTable message from the specified reader or buffer, length delimited. + * Decodes a ReqReadyStart message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof api.ResJoinTable + * @memberof api.ReqReadyStart * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {api.ResJoinTable} ResJoinTable + * @returns {api.ReqReadyStart} ReqReadyStart * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - ResJoinTable.decodeDelimited = function decodeDelimited(reader) { + ReqReadyStart.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a ResJoinTable message. + * Verifies a ReqReadyStart message. * @function verify - * @memberof api.ResJoinTable + * @memberof api.ReqReadyStart * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - ResJoinTable.verify = function verify(message) { + ReqReadyStart.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; return null; }; /** - * Creates a ResJoinTable message from a plain object. Also converts values to their respective internal types. + * Creates a ReqReadyStart message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof api.ResJoinTable + * @memberof api.ReqReadyStart * @static * @param {Object.} object Plain object - * @returns {api.ResJoinTable} ResJoinTable + * @returns {api.ReqReadyStart} ReqReadyStart */ - ResJoinTable.fromObject = function fromObject(object) { - if (object instanceof $root.api.ResJoinTable) + ReqReadyStart.fromObject = function fromObject(object) { + if (object instanceof $root.api.ReqReadyStart) return object; - return new $root.api.ResJoinTable(); + return new $root.api.ReqReadyStart(); }; /** - * Creates a plain object from a ResJoinTable message. Also converts values to other types if specified. + * Creates a plain object from a ReqReadyStart message. Also converts values to other types if specified. * @function toObject - * @memberof api.ResJoinTable + * @memberof api.ReqReadyStart * @static - * @param {api.ResJoinTable} message ResJoinTable + * @param {api.ReqReadyStart} message ReqReadyStart * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - ResJoinTable.toObject = function toObject() { + ReqReadyStart.toObject = function toObject() { return {}; }; /** - * Converts this ResJoinTable to JSON. + * Converts this ReqReadyStart to JSON. + * @function toJSON + * @memberof api.ReqReadyStart + * @instance + * @returns {Object.} JSON object + */ + ReqReadyStart.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ReqReadyStart + * @function getTypeUrl + * @memberof api.ReqReadyStart + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ReqReadyStart.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/api.ReqReadyStart"; + }; + + return ReqReadyStart; + })(); + + api.ReqKickOutTable = (function() { + + /** + * Properties of a ReqKickOutTable. + * @memberof api + * @interface IReqKickOutTable + * @property {number|null} [playerId] ReqKickOutTable playerId + */ + + /** + * Constructs a new ReqKickOutTable. + * @memberof api + * @classdesc Represents a ReqKickOutTable. + * @implements IReqKickOutTable + * @constructor + * @param {api.IReqKickOutTable=} [properties] Properties to set + */ + function ReqKickOutTable(properties) { + if (properties) + for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ReqKickOutTable playerId. + * @member {number} playerId + * @memberof api.ReqKickOutTable + * @instance + */ + ReqKickOutTable.prototype.playerId = 0; + + /** + * Creates a new ReqKickOutTable instance using the specified properties. + * @function create + * @memberof api.ReqKickOutTable + * @static + * @param {api.IReqKickOutTable=} [properties] Properties to set + * @returns {api.ReqKickOutTable} ReqKickOutTable instance + */ + ReqKickOutTable.create = function create(properties) { + return new ReqKickOutTable(properties); + }; + + /** + * Encodes the specified ReqKickOutTable message. Does not implicitly {@link api.ReqKickOutTable.verify|verify} messages. + * @function encode + * @memberof api.ReqKickOutTable + * @static + * @param {api.IReqKickOutTable} message ReqKickOutTable message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReqKickOutTable.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.playerId != null && Object.hasOwnProperty.call(message, "playerId")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.playerId); + return writer; + }; + + /** + * Encodes the specified ReqKickOutTable message, length delimited. Does not implicitly {@link api.ReqKickOutTable.verify|verify} messages. + * @function encodeDelimited + * @memberof api.ReqKickOutTable + * @static + * @param {api.IReqKickOutTable} message ReqKickOutTable message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReqKickOutTable.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ReqKickOutTable message from the specified reader or buffer. + * @function decode + * @memberof api.ReqKickOutTable + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {api.ReqKickOutTable} ReqKickOutTable + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReqKickOutTable.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + let end = length === undefined ? reader.len : reader.pos + length, message = new $root.api.ReqKickOutTable(); + while (reader.pos < end) { + let tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.playerId = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ReqKickOutTable message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof api.ReqKickOutTable + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {api.ReqKickOutTable} ReqKickOutTable + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReqKickOutTable.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ReqKickOutTable message. + * @function verify + * @memberof api.ReqKickOutTable + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReqKickOutTable.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.playerId != null && message.hasOwnProperty("playerId")) + if (!$util.isInteger(message.playerId)) + return "playerId: integer expected"; + return null; + }; + + /** + * Creates a ReqKickOutTable message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof api.ReqKickOutTable + * @static + * @param {Object.} object Plain object + * @returns {api.ReqKickOutTable} ReqKickOutTable + */ + ReqKickOutTable.fromObject = function fromObject(object) { + if (object instanceof $root.api.ReqKickOutTable) + return object; + let message = new $root.api.ReqKickOutTable(); + if (object.playerId != null) + message.playerId = object.playerId | 0; + return message; + }; + + /** + * Creates a plain object from a ReqKickOutTable message. Also converts values to other types if specified. + * @function toObject + * @memberof api.ReqKickOutTable + * @static + * @param {api.ReqKickOutTable} message ReqKickOutTable + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReqKickOutTable.toObject = function toObject(message, options) { + if (!options) + options = {}; + let object = {}; + if (options.defaults) + object.playerId = 0; + if (message.playerId != null && message.hasOwnProperty("playerId")) + object.playerId = message.playerId; + return object; + }; + + /** + * Converts this ReqKickOutTable to JSON. + * @function toJSON + * @memberof api.ReqKickOutTable + * @instance + * @returns {Object.} JSON object + */ + ReqKickOutTable.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ReqKickOutTable + * @function getTypeUrl + * @memberof api.ReqKickOutTable + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ReqKickOutTable.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/api.ReqKickOutTable"; + }; + + return ReqKickOutTable; + })(); + + api.ReqGameAction = (function() { + + /** + * Properties of a ReqGameAction. + * @memberof api + * @interface IReqGameAction + * @property {number|null} [action] ReqGameAction action + * @property {number|null} [chip] ReqGameAction chip + */ + + /** + * Constructs a new ReqGameAction. + * @memberof api + * @classdesc Represents a ReqGameAction. + * @implements IReqGameAction + * @constructor + * @param {api.IReqGameAction=} [properties] Properties to set + */ + function ReqGameAction(properties) { + if (properties) + for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ReqGameAction action. + * @member {number} action + * @memberof api.ReqGameAction + * @instance + */ + ReqGameAction.prototype.action = 0; + + /** + * ReqGameAction chip. + * @member {number} chip + * @memberof api.ReqGameAction + * @instance + */ + ReqGameAction.prototype.chip = 0; + + /** + * Creates a new ReqGameAction instance using the specified properties. + * @function create + * @memberof api.ReqGameAction + * @static + * @param {api.IReqGameAction=} [properties] Properties to set + * @returns {api.ReqGameAction} ReqGameAction instance + */ + ReqGameAction.create = function create(properties) { + return new ReqGameAction(properties); + }; + + /** + * Encodes the specified ReqGameAction message. Does not implicitly {@link api.ReqGameAction.verify|verify} messages. + * @function encode + * @memberof api.ReqGameAction + * @static + * @param {api.IReqGameAction} message ReqGameAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReqGameAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.action != null && Object.hasOwnProperty.call(message, "action")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.action); + if (message.chip != null && Object.hasOwnProperty.call(message, "chip")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.chip); + return writer; + }; + + /** + * Encodes the specified ReqGameAction message, length delimited. Does not implicitly {@link api.ReqGameAction.verify|verify} messages. + * @function encodeDelimited + * @memberof api.ReqGameAction + * @static + * @param {api.IReqGameAction} message ReqGameAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReqGameAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ReqGameAction message from the specified reader or buffer. + * @function decode + * @memberof api.ReqGameAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {api.ReqGameAction} ReqGameAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReqGameAction.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + let end = length === undefined ? reader.len : reader.pos + length, message = new $root.api.ReqGameAction(); + while (reader.pos < end) { + let tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.action = reader.int32(); + break; + } + case 2: { + message.chip = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ReqGameAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof api.ReqGameAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {api.ReqGameAction} ReqGameAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReqGameAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ReqGameAction message. + * @function verify + * @memberof api.ReqGameAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReqGameAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.action != null && message.hasOwnProperty("action")) + if (!$util.isInteger(message.action)) + return "action: integer expected"; + if (message.chip != null && message.hasOwnProperty("chip")) + if (!$util.isInteger(message.chip)) + return "chip: integer expected"; + return null; + }; + + /** + * Creates a ReqGameAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof api.ReqGameAction + * @static + * @param {Object.} object Plain object + * @returns {api.ReqGameAction} ReqGameAction + */ + ReqGameAction.fromObject = function fromObject(object) { + if (object instanceof $root.api.ReqGameAction) + return object; + let message = new $root.api.ReqGameAction(); + if (object.action != null) + message.action = object.action | 0; + if (object.chip != null) + message.chip = object.chip | 0; + return message; + }; + + /** + * Creates a plain object from a ReqGameAction message. Also converts values to other types if specified. + * @function toObject + * @memberof api.ReqGameAction + * @static + * @param {api.ReqGameAction} message ReqGameAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReqGameAction.toObject = function toObject(message, options) { + if (!options) + options = {}; + let object = {}; + if (options.defaults) { + object.action = 0; + object.chip = 0; + } + if (message.action != null && message.hasOwnProperty("action")) + object.action = message.action; + if (message.chip != null && message.hasOwnProperty("chip")) + object.chip = message.chip; + return object; + }; + + /** + * Converts this ReqGameAction to JSON. + * @function toJSON + * @memberof api.ReqGameAction + * @instance + * @returns {Object.} JSON object + */ + ReqGameAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ReqGameAction + * @function getTypeUrl + * @memberof api.ReqGameAction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ReqGameAction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/api.ReqGameAction"; + }; + + return ReqGameAction; + })(); + + api.ResGameAction = (function() { + + /** + * Properties of a ResGameAction. + * @memberof api + * @interface IResGameAction + */ + + /** + * Constructs a new ResGameAction. + * @memberof api + * @classdesc Represents a ResGameAction. + * @implements IResGameAction + * @constructor + * @param {api.IResGameAction=} [properties] Properties to set + */ + function ResGameAction(properties) { + if (properties) + for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Creates a new ResGameAction instance using the specified properties. + * @function create + * @memberof api.ResGameAction + * @static + * @param {api.IResGameAction=} [properties] Properties to set + * @returns {api.ResGameAction} ResGameAction instance + */ + ResGameAction.create = function create(properties) { + return new ResGameAction(properties); + }; + + /** + * Encodes the specified ResGameAction message. Does not implicitly {@link api.ResGameAction.verify|verify} messages. + * @function encode + * @memberof api.ResGameAction + * @static + * @param {api.IResGameAction} message ResGameAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResGameAction.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified ResGameAction message, length delimited. Does not implicitly {@link api.ResGameAction.verify|verify} messages. + * @function encodeDelimited + * @memberof api.ResGameAction + * @static + * @param {api.IResGameAction} message ResGameAction message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResGameAction.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ResGameAction message from the specified reader or buffer. + * @function decode + * @memberof api.ResGameAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {api.ResGameAction} ResGameAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResGameAction.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + let end = length === undefined ? reader.len : reader.pos + length, message = new $root.api.ResGameAction(); + while (reader.pos < end) { + let tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ResGameAction message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof api.ResGameAction + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {api.ResGameAction} ResGameAction + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResGameAction.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ResGameAction message. + * @function verify + * @memberof api.ResGameAction + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ResGameAction.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a ResGameAction message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof api.ResGameAction + * @static + * @param {Object.} object Plain object + * @returns {api.ResGameAction} ResGameAction + */ + ResGameAction.fromObject = function fromObject(object) { + if (object instanceof $root.api.ResGameAction) + return object; + return new $root.api.ResGameAction(); + }; + + /** + * Creates a plain object from a ResGameAction message. Also converts values to other types if specified. + * @function toObject + * @memberof api.ResGameAction + * @static + * @param {api.ResGameAction} message ResGameAction + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ResGameAction.toObject = function toObject() { + return {}; + }; + + /** + * Converts this ResGameAction to JSON. + * @function toJSON + * @memberof api.ResGameAction + * @instance + * @returns {Object.} JSON object + */ + ResGameAction.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ResGameAction + * @function getTypeUrl + * @memberof api.ResGameAction + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ResGameAction.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/api.ResGameAction"; + }; + + return ResGameAction; + })(); + + api.ReqGameFullStatus = (function() { + + /** + * Properties of a ReqGameFullStatus. + * @memberof api + * @interface IReqGameFullStatus + */ + + /** + * Constructs a new ReqGameFullStatus. + * @memberof api + * @classdesc Represents a ReqGameFullStatus. + * @implements IReqGameFullStatus + * @constructor + * @param {api.IReqGameFullStatus=} [properties] Properties to set + */ + function ReqGameFullStatus(properties) { + if (properties) + for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Creates a new ReqGameFullStatus instance using the specified properties. + * @function create + * @memberof api.ReqGameFullStatus + * @static + * @param {api.IReqGameFullStatus=} [properties] Properties to set + * @returns {api.ReqGameFullStatus} ReqGameFullStatus instance + */ + ReqGameFullStatus.create = function create(properties) { + return new ReqGameFullStatus(properties); + }; + + /** + * Encodes the specified ReqGameFullStatus message. Does not implicitly {@link api.ReqGameFullStatus.verify|verify} messages. + * @function encode + * @memberof api.ReqGameFullStatus + * @static + * @param {api.IReqGameFullStatus} message ReqGameFullStatus message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReqGameFullStatus.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified ReqGameFullStatus message, length delimited. Does not implicitly {@link api.ReqGameFullStatus.verify|verify} messages. + * @function encodeDelimited + * @memberof api.ReqGameFullStatus + * @static + * @param {api.IReqGameFullStatus} message ReqGameFullStatus message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReqGameFullStatus.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ReqGameFullStatus message from the specified reader or buffer. + * @function decode + * @memberof api.ReqGameFullStatus + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {api.ReqGameFullStatus} ReqGameFullStatus + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReqGameFullStatus.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + let end = length === undefined ? reader.len : reader.pos + length, message = new $root.api.ReqGameFullStatus(); + while (reader.pos < end) { + let tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ReqGameFullStatus message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof api.ReqGameFullStatus + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {api.ReqGameFullStatus} ReqGameFullStatus + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReqGameFullStatus.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ReqGameFullStatus message. + * @function verify + * @memberof api.ReqGameFullStatus + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReqGameFullStatus.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a ReqGameFullStatus message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof api.ReqGameFullStatus + * @static + * @param {Object.} object Plain object + * @returns {api.ReqGameFullStatus} ReqGameFullStatus + */ + ReqGameFullStatus.fromObject = function fromObject(object) { + if (object instanceof $root.api.ReqGameFullStatus) + return object; + return new $root.api.ReqGameFullStatus(); + }; + + /** + * Creates a plain object from a ReqGameFullStatus message. Also converts values to other types if specified. + * @function toObject + * @memberof api.ReqGameFullStatus + * @static + * @param {api.ReqGameFullStatus} message ReqGameFullStatus + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReqGameFullStatus.toObject = function toObject() { + return {}; + }; + + /** + * Converts this ReqGameFullStatus to JSON. + * @function toJSON + * @memberof api.ReqGameFullStatus + * @instance + * @returns {Object.} JSON object + */ + ReqGameFullStatus.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ReqGameFullStatus + * @function getTypeUrl + * @memberof api.ReqGameFullStatus + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ReqGameFullStatus.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/api.ReqGameFullStatus"; + }; + + return ReqGameFullStatus; + })(); + + api.ResGameFullStatus = (function() { + + /** + * Properties of a ResGameFullStatus. + * @memberof api + * @interface IResGameFullStatus + * @property {boolean|null} [inGame] ResGameFullStatus inGame + * @property {number|null} [tableNo] ResGameFullStatus tableNo + * @property {number|null} [gameStage] ResGameFullStatus gameStage + * @property {number|null} [chip] ResGameFullStatus chip + * @property {number|null} [RoundTimes] ResGameFullStatus RoundTimes + * @property {Array.|null} [publicCard] ResGameFullStatus publicCard + * @property {Array.|null} [players] ResGameFullStatus players + */ + + /** + * Constructs a new ResGameFullStatus. + * @memberof api + * @classdesc Represents a ResGameFullStatus. + * @implements IResGameFullStatus + * @constructor + * @param {api.IResGameFullStatus=} [properties] Properties to set + */ + function ResGameFullStatus(properties) { + this.publicCard = []; + this.players = []; + if (properties) + for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ResGameFullStatus inGame. + * @member {boolean} inGame + * @memberof api.ResGameFullStatus + * @instance + */ + ResGameFullStatus.prototype.inGame = false; + + /** + * ResGameFullStatus tableNo. + * @member {number} tableNo + * @memberof api.ResGameFullStatus + * @instance + */ + ResGameFullStatus.prototype.tableNo = 0; + + /** + * ResGameFullStatus gameStage. + * @member {number} gameStage + * @memberof api.ResGameFullStatus + * @instance + */ + ResGameFullStatus.prototype.gameStage = 0; + + /** + * ResGameFullStatus chip. + * @member {number} chip + * @memberof api.ResGameFullStatus + * @instance + */ + ResGameFullStatus.prototype.chip = 0; + + /** + * ResGameFullStatus RoundTimes. + * @member {number} RoundTimes + * @memberof api.ResGameFullStatus + * @instance + */ + ResGameFullStatus.prototype.RoundTimes = 0; + + /** + * ResGameFullStatus publicCard. + * @member {Array.} publicCard + * @memberof api.ResGameFullStatus + * @instance + */ + ResGameFullStatus.prototype.publicCard = $util.emptyArray; + + /** + * ResGameFullStatus players. + * @member {Array.} players + * @memberof api.ResGameFullStatus + * @instance + */ + ResGameFullStatus.prototype.players = $util.emptyArray; + + /** + * Creates a new ResGameFullStatus instance using the specified properties. + * @function create + * @memberof api.ResGameFullStatus + * @static + * @param {api.IResGameFullStatus=} [properties] Properties to set + * @returns {api.ResGameFullStatus} ResGameFullStatus instance + */ + ResGameFullStatus.create = function create(properties) { + return new ResGameFullStatus(properties); + }; + + /** + * Encodes the specified ResGameFullStatus message. Does not implicitly {@link api.ResGameFullStatus.verify|verify} messages. + * @function encode + * @memberof api.ResGameFullStatus + * @static + * @param {api.IResGameFullStatus} message ResGameFullStatus message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResGameFullStatus.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.inGame != null && Object.hasOwnProperty.call(message, "inGame")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.inGame); + if (message.tableNo != null && Object.hasOwnProperty.call(message, "tableNo")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.tableNo); + if (message.gameStage != null && Object.hasOwnProperty.call(message, "gameStage")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.gameStage); + if (message.chip != null && Object.hasOwnProperty.call(message, "chip")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.chip); + if (message.RoundTimes != null && Object.hasOwnProperty.call(message, "RoundTimes")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.RoundTimes); + if (message.publicCard != null && message.publicCard.length) + for (let i = 0; i < message.publicCard.length; ++i) + $root.api.Card.encode(message.publicCard[i], writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.players != null && message.players.length) + for (let i = 0; i < message.players.length; ++i) + $root.api.TablePlayer.encode(message.players[i], writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ResGameFullStatus message, length delimited. Does not implicitly {@link api.ResGameFullStatus.verify|verify} messages. + * @function encodeDelimited + * @memberof api.ResGameFullStatus + * @static + * @param {api.IResGameFullStatus} message ResGameFullStatus message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResGameFullStatus.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ResGameFullStatus message from the specified reader or buffer. + * @function decode + * @memberof api.ResGameFullStatus + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {api.ResGameFullStatus} ResGameFullStatus + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResGameFullStatus.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + let end = length === undefined ? reader.len : reader.pos + length, message = new $root.api.ResGameFullStatus(); + while (reader.pos < end) { + let tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.inGame = reader.bool(); + break; + } + case 2: { + message.tableNo = reader.int32(); + break; + } + case 3: { + message.gameStage = reader.int32(); + break; + } + case 4: { + message.chip = reader.int32(); + break; + } + case 5: { + message.RoundTimes = reader.int32(); + break; + } + case 9: { + if (!(message.publicCard && message.publicCard.length)) + message.publicCard = []; + message.publicCard.push($root.api.Card.decode(reader, reader.uint32())); + break; + } + case 10: { + if (!(message.players && message.players.length)) + message.players = []; + message.players.push($root.api.TablePlayer.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ResGameFullStatus message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof api.ResGameFullStatus + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {api.ResGameFullStatus} ResGameFullStatus + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResGameFullStatus.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ResGameFullStatus message. + * @function verify + * @memberof api.ResGameFullStatus + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ResGameFullStatus.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.inGame != null && message.hasOwnProperty("inGame")) + if (typeof message.inGame !== "boolean") + return "inGame: boolean expected"; + if (message.tableNo != null && message.hasOwnProperty("tableNo")) + if (!$util.isInteger(message.tableNo)) + return "tableNo: integer expected"; + if (message.gameStage != null && message.hasOwnProperty("gameStage")) + if (!$util.isInteger(message.gameStage)) + return "gameStage: integer expected"; + if (message.chip != null && message.hasOwnProperty("chip")) + if (!$util.isInteger(message.chip)) + return "chip: integer expected"; + if (message.RoundTimes != null && message.hasOwnProperty("RoundTimes")) + if (!$util.isInteger(message.RoundTimes)) + return "RoundTimes: integer expected"; + if (message.publicCard != null && message.hasOwnProperty("publicCard")) { + if (!Array.isArray(message.publicCard)) + return "publicCard: array expected"; + for (let i = 0; i < message.publicCard.length; ++i) { + let error = $root.api.Card.verify(message.publicCard[i]); + if (error) + return "publicCard." + error; + } + } + if (message.players != null && message.hasOwnProperty("players")) { + if (!Array.isArray(message.players)) + return "players: array expected"; + for (let i = 0; i < message.players.length; ++i) { + let error = $root.api.TablePlayer.verify(message.players[i]); + if (error) + return "players." + error; + } + } + return null; + }; + + /** + * Creates a ResGameFullStatus message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof api.ResGameFullStatus + * @static + * @param {Object.} object Plain object + * @returns {api.ResGameFullStatus} ResGameFullStatus + */ + ResGameFullStatus.fromObject = function fromObject(object) { + if (object instanceof $root.api.ResGameFullStatus) + return object; + let message = new $root.api.ResGameFullStatus(); + if (object.inGame != null) + message.inGame = Boolean(object.inGame); + if (object.tableNo != null) + message.tableNo = object.tableNo | 0; + if (object.gameStage != null) + message.gameStage = object.gameStage | 0; + if (object.chip != null) + message.chip = object.chip | 0; + if (object.RoundTimes != null) + message.RoundTimes = object.RoundTimes | 0; + if (object.publicCard) { + if (!Array.isArray(object.publicCard)) + throw TypeError(".api.ResGameFullStatus.publicCard: array expected"); + message.publicCard = []; + for (let i = 0; i < object.publicCard.length; ++i) { + if (typeof object.publicCard[i] !== "object") + throw TypeError(".api.ResGameFullStatus.publicCard: object expected"); + message.publicCard[i] = $root.api.Card.fromObject(object.publicCard[i]); + } + } + if (object.players) { + if (!Array.isArray(object.players)) + throw TypeError(".api.ResGameFullStatus.players: array expected"); + message.players = []; + for (let i = 0; i < object.players.length; ++i) { + if (typeof object.players[i] !== "object") + throw TypeError(".api.ResGameFullStatus.players: object expected"); + message.players[i] = $root.api.TablePlayer.fromObject(object.players[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a ResGameFullStatus message. Also converts values to other types if specified. + * @function toObject + * @memberof api.ResGameFullStatus + * @static + * @param {api.ResGameFullStatus} message ResGameFullStatus + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ResGameFullStatus.toObject = function toObject(message, options) { + if (!options) + options = {}; + let object = {}; + if (options.arrays || options.defaults) { + object.publicCard = []; + object.players = []; + } + if (options.defaults) { + object.inGame = false; + object.tableNo = 0; + object.gameStage = 0; + object.chip = 0; + object.RoundTimes = 0; + } + if (message.inGame != null && message.hasOwnProperty("inGame")) + object.inGame = message.inGame; + if (message.tableNo != null && message.hasOwnProperty("tableNo")) + object.tableNo = message.tableNo; + if (message.gameStage != null && message.hasOwnProperty("gameStage")) + object.gameStage = message.gameStage; + if (message.chip != null && message.hasOwnProperty("chip")) + object.chip = message.chip; + if (message.RoundTimes != null && message.hasOwnProperty("RoundTimes")) + object.RoundTimes = message.RoundTimes; + if (message.publicCard && message.publicCard.length) { + object.publicCard = []; + for (let j = 0; j < message.publicCard.length; ++j) + object.publicCard[j] = $root.api.Card.toObject(message.publicCard[j], options); + } + if (message.players && message.players.length) { + object.players = []; + for (let j = 0; j < message.players.length; ++j) + object.players[j] = $root.api.TablePlayer.toObject(message.players[j], options); + } + return object; + }; + + /** + * Converts this ResGameFullStatus to JSON. + * @function toJSON + * @memberof api.ResGameFullStatus + * @instance + * @returns {Object.} JSON object + */ + ResGameFullStatus.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ResGameFullStatus + * @function getTypeUrl + * @memberof api.ResGameFullStatus + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ResGameFullStatus.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/api.ResGameFullStatus"; + }; + + return ResGameFullStatus; + })(); + + api.TablePlayer = (function() { + + /** + * Properties of a TablePlayer. + * @memberof api + * @interface ITablePlayer + * @property {boolean|null} [robot] TablePlayer robot + * @property {number|Long|null} [id] TablePlayer id + * @property {string|null} [username] TablePlayer username + * @property {string|null} [avatar] TablePlayer avatar + * @property {number|null} [chip] TablePlayer chip + * @property {number|null} [status] TablePlayer status + * @property {boolean|null} [master] TablePlayer master + * @property {Array.|null} [handCard] TablePlayer handCard + */ + + /** + * Constructs a new TablePlayer. + * @memberof api + * @classdesc Represents a TablePlayer. + * @implements ITablePlayer + * @constructor + * @param {api.ITablePlayer=} [properties] Properties to set + */ + function TablePlayer(properties) { + this.handCard = []; + if (properties) + for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * TablePlayer robot. + * @member {boolean} robot + * @memberof api.TablePlayer + * @instance + */ + TablePlayer.prototype.robot = false; + + /** + * TablePlayer id. + * @member {number|Long} id + * @memberof api.TablePlayer + * @instance + */ + TablePlayer.prototype.id = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * TablePlayer username. + * @member {string} username + * @memberof api.TablePlayer + * @instance + */ + TablePlayer.prototype.username = ""; + + /** + * TablePlayer avatar. + * @member {string} avatar + * @memberof api.TablePlayer + * @instance + */ + TablePlayer.prototype.avatar = ""; + + /** + * TablePlayer chip. + * @member {number} chip + * @memberof api.TablePlayer + * @instance + */ + TablePlayer.prototype.chip = 0; + + /** + * TablePlayer status. + * @member {number} status + * @memberof api.TablePlayer + * @instance + */ + TablePlayer.prototype.status = 0; + + /** + * TablePlayer master. + * @member {boolean} master + * @memberof api.TablePlayer + * @instance + */ + TablePlayer.prototype.master = false; + + /** + * TablePlayer handCard. + * @member {Array.} handCard + * @memberof api.TablePlayer + * @instance + */ + TablePlayer.prototype.handCard = $util.emptyArray; + + /** + * Creates a new TablePlayer instance using the specified properties. + * @function create + * @memberof api.TablePlayer + * @static + * @param {api.ITablePlayer=} [properties] Properties to set + * @returns {api.TablePlayer} TablePlayer instance + */ + TablePlayer.create = function create(properties) { + return new TablePlayer(properties); + }; + + /** + * Encodes the specified TablePlayer message. Does not implicitly {@link api.TablePlayer.verify|verify} messages. + * @function encode + * @memberof api.TablePlayer + * @static + * @param {api.ITablePlayer} message TablePlayer message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TablePlayer.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.robot != null && Object.hasOwnProperty.call(message, "robot")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.robot); + if (message.id != null && Object.hasOwnProperty.call(message, "id")) + writer.uint32(/* id 2, wireType 0 =*/16).int64(message.id); + if (message.username != null && Object.hasOwnProperty.call(message, "username")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.username); + if (message.avatar != null && Object.hasOwnProperty.call(message, "avatar")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.avatar); + if (message.chip != null && Object.hasOwnProperty.call(message, "chip")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.chip); + if (message.status != null && Object.hasOwnProperty.call(message, "status")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.status); + if (message.master != null && Object.hasOwnProperty.call(message, "master")) + writer.uint32(/* id 7, wireType 0 =*/56).bool(message.master); + if (message.handCard != null && message.handCard.length) + for (let i = 0; i < message.handCard.length; ++i) + $root.api.Card.encode(message.handCard[i], writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified TablePlayer message, length delimited. Does not implicitly {@link api.TablePlayer.verify|verify} messages. + * @function encodeDelimited + * @memberof api.TablePlayer + * @static + * @param {api.ITablePlayer} message TablePlayer message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TablePlayer.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a TablePlayer message from the specified reader or buffer. + * @function decode + * @memberof api.TablePlayer + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {api.TablePlayer} TablePlayer + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TablePlayer.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + let end = length === undefined ? reader.len : reader.pos + length, message = new $root.api.TablePlayer(); + while (reader.pos < end) { + let tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.robot = reader.bool(); + break; + } + case 2: { + message.id = reader.int64(); + break; + } + case 3: { + message.username = reader.string(); + break; + } + case 4: { + message.avatar = reader.string(); + break; + } + case 5: { + message.chip = reader.int32(); + break; + } + case 6: { + message.status = reader.int32(); + break; + } + case 7: { + message.master = reader.bool(); + break; + } + case 8: { + if (!(message.handCard && message.handCard.length)) + message.handCard = []; + message.handCard.push($root.api.Card.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TablePlayer message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof api.TablePlayer + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {api.TablePlayer} TablePlayer + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TablePlayer.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TablePlayer message. + * @function verify + * @memberof api.TablePlayer + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TablePlayer.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.robot != null && message.hasOwnProperty("robot")) + if (typeof message.robot !== "boolean") + return "robot: boolean expected"; + if (message.id != null && message.hasOwnProperty("id")) + if (!$util.isInteger(message.id) && !(message.id && $util.isInteger(message.id.low) && $util.isInteger(message.id.high))) + return "id: integer|Long expected"; + if (message.username != null && message.hasOwnProperty("username")) + if (!$util.isString(message.username)) + return "username: string expected"; + if (message.avatar != null && message.hasOwnProperty("avatar")) + if (!$util.isString(message.avatar)) + return "avatar: string expected"; + if (message.chip != null && message.hasOwnProperty("chip")) + if (!$util.isInteger(message.chip)) + return "chip: integer expected"; + if (message.status != null && message.hasOwnProperty("status")) + if (!$util.isInteger(message.status)) + return "status: integer expected"; + if (message.master != null && message.hasOwnProperty("master")) + if (typeof message.master !== "boolean") + return "master: boolean expected"; + if (message.handCard != null && message.hasOwnProperty("handCard")) { + if (!Array.isArray(message.handCard)) + return "handCard: array expected"; + for (let i = 0; i < message.handCard.length; ++i) { + let error = $root.api.Card.verify(message.handCard[i]); + if (error) + return "handCard." + error; + } + } + return null; + }; + + /** + * Creates a TablePlayer message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof api.TablePlayer + * @static + * @param {Object.} object Plain object + * @returns {api.TablePlayer} TablePlayer + */ + TablePlayer.fromObject = function fromObject(object) { + if (object instanceof $root.api.TablePlayer) + return object; + let message = new $root.api.TablePlayer(); + if (object.robot != null) + message.robot = Boolean(object.robot); + if (object.id != null) + if ($util.Long) + (message.id = $util.Long.fromValue(object.id)).unsigned = false; + else if (typeof object.id === "string") + message.id = parseInt(object.id, 10); + else if (typeof object.id === "number") + message.id = object.id; + else if (typeof object.id === "object") + message.id = new $util.LongBits(object.id.low >>> 0, object.id.high >>> 0).toNumber(); + if (object.username != null) + message.username = String(object.username); + if (object.avatar != null) + message.avatar = String(object.avatar); + if (object.chip != null) + message.chip = object.chip | 0; + if (object.status != null) + message.status = object.status | 0; + if (object.master != null) + message.master = Boolean(object.master); + if (object.handCard) { + if (!Array.isArray(object.handCard)) + throw TypeError(".api.TablePlayer.handCard: array expected"); + message.handCard = []; + for (let i = 0; i < object.handCard.length; ++i) { + if (typeof object.handCard[i] !== "object") + throw TypeError(".api.TablePlayer.handCard: object expected"); + message.handCard[i] = $root.api.Card.fromObject(object.handCard[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a TablePlayer message. Also converts values to other types if specified. + * @function toObject + * @memberof api.TablePlayer + * @static + * @param {api.TablePlayer} message TablePlayer + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TablePlayer.toObject = function toObject(message, options) { + if (!options) + options = {}; + let object = {}; + if (options.arrays || options.defaults) + object.handCard = []; + if (options.defaults) { + object.robot = false; + if ($util.Long) { + let long = new $util.Long(0, 0, false); + object.id = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.id = options.longs === String ? "0" : 0; + object.username = ""; + object.avatar = ""; + object.chip = 0; + object.status = 0; + object.master = false; + } + if (message.robot != null && message.hasOwnProperty("robot")) + object.robot = message.robot; + if (message.id != null && message.hasOwnProperty("id")) + if (typeof message.id === "number") + object.id = options.longs === String ? String(message.id) : message.id; + else + object.id = options.longs === String ? $util.Long.prototype.toString.call(message.id) : options.longs === Number ? new $util.LongBits(message.id.low >>> 0, message.id.high >>> 0).toNumber() : message.id; + if (message.username != null && message.hasOwnProperty("username")) + object.username = message.username; + if (message.avatar != null && message.hasOwnProperty("avatar")) + object.avatar = message.avatar; + if (message.chip != null && message.hasOwnProperty("chip")) + object.chip = message.chip; + if (message.status != null && message.hasOwnProperty("status")) + object.status = message.status; + if (message.master != null && message.hasOwnProperty("master")) + object.master = message.master; + if (message.handCard && message.handCard.length) { + object.handCard = []; + for (let j = 0; j < message.handCard.length; ++j) + object.handCard[j] = $root.api.Card.toObject(message.handCard[j], options); + } + return object; + }; + + /** + * Converts this TablePlayer to JSON. + * @function toJSON + * @memberof api.TablePlayer + * @instance + * @returns {Object.} JSON object + */ + TablePlayer.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for TablePlayer + * @function getTypeUrl + * @memberof api.TablePlayer + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + TablePlayer.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/api.TablePlayer"; + }; + + return TablePlayer; + })(); + + api.Card = (function() { + + /** + * Properties of a Card. + * @memberof api + * @interface ICard + * @property {number|null} [dot] Card dot + * @property {string|null} [suit] Card suit + */ + + /** + * Constructs a new Card. + * @memberof api + * @classdesc Represents a Card. + * @implements ICard + * @constructor + * @param {api.ICard=} [properties] Properties to set + */ + function Card(properties) { + if (properties) + for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Card dot. + * @member {number} dot + * @memberof api.Card + * @instance + */ + Card.prototype.dot = 0; + + /** + * Card suit. + * @member {string} suit + * @memberof api.Card + * @instance + */ + Card.prototype.suit = ""; + + /** + * Creates a new Card instance using the specified properties. + * @function create + * @memberof api.Card + * @static + * @param {api.ICard=} [properties] Properties to set + * @returns {api.Card} Card instance + */ + Card.create = function create(properties) { + return new Card(properties); + }; + + /** + * Encodes the specified Card message. Does not implicitly {@link api.Card.verify|verify} messages. + * @function encode + * @memberof api.Card + * @static + * @param {api.ICard} message Card message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Card.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.dot != null && Object.hasOwnProperty.call(message, "dot")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.dot); + if (message.suit != null && Object.hasOwnProperty.call(message, "suit")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.suit); + return writer; + }; + + /** + * Encodes the specified Card message, length delimited. Does not implicitly {@link api.Card.verify|verify} messages. + * @function encodeDelimited + * @memberof api.Card + * @static + * @param {api.ICard} message Card message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Card.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Card message from the specified reader or buffer. + * @function decode + * @memberof api.Card + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {api.Card} Card + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Card.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + let end = length === undefined ? reader.len : reader.pos + length, message = new $root.api.Card(); + while (reader.pos < end) { + let tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.dot = reader.int32(); + break; + } + case 2: { + message.suit = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Card message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof api.Card + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {api.Card} Card + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Card.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Card message. + * @function verify + * @memberof api.Card + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Card.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.dot != null && message.hasOwnProperty("dot")) + if (!$util.isInteger(message.dot)) + return "dot: integer expected"; + if (message.suit != null && message.hasOwnProperty("suit")) + if (!$util.isString(message.suit)) + return "suit: string expected"; + return null; + }; + + /** + * Creates a Card message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof api.Card + * @static + * @param {Object.} object Plain object + * @returns {api.Card} Card + */ + Card.fromObject = function fromObject(object) { + if (object instanceof $root.api.Card) + return object; + let message = new $root.api.Card(); + if (object.dot != null) + message.dot = object.dot | 0; + if (object.suit != null) + message.suit = String(object.suit); + return message; + }; + + /** + * Creates a plain object from a Card message. Also converts values to other types if specified. + * @function toObject + * @memberof api.Card + * @static + * @param {api.Card} message Card + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Card.toObject = function toObject(message, options) { + if (!options) + options = {}; + let object = {}; + if (options.defaults) { + object.dot = 0; + object.suit = ""; + } + if (message.dot != null && message.hasOwnProperty("dot")) + object.dot = message.dot; + if (message.suit != null && message.hasOwnProperty("suit")) + object.suit = message.suit; + return object; + }; + + /** + * Converts this Card to JSON. * @function toJSON - * @memberof api.ResJoinTable + * @memberof api.Card * @instance * @returns {Object.} JSON object */ - ResJoinTable.prototype.toJSON = function toJSON() { + Card.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for ResJoinTable + * Gets the default type url for Card * @function getTypeUrl - * @memberof api.ResJoinTable + * @memberof api.Card * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - ResJoinTable.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + Card.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/api.ResJoinTable"; + return typeUrlPrefix + "/api.Card"; }; - return ResJoinTable; + return Card; })(); return api; diff --git a/src/api/websocket.js b/src/api/websocket.js index fee9f38..488862b 100644 --- a/src/api/websocket.js +++ b/src/api/websocket.js @@ -50,14 +50,14 @@ const websocket = { console.log('res msg:', res) if (wrap.seq !== 0) { // 对应请求callback - const waitCall = this.waitCall[wrap.seq]; + const caller = this.waitCall[wrap.seq]; delete this.waitCall[wrap.seq]; // console.log(waitCall, this.waitCall); - if (waitCall) { + if (caller) { if (wrap.op === opFail) { - waitCall.onFail(res, wrap); + caller.onFail(res, wrap); } else { - waitCall.onRes(res, wrap); + caller.onRes(res, wrap); } return; } @@ -98,7 +98,7 @@ const websocket = { this.waitCall[wrap.seq] = { seq: wrap.seq, onRes: resCall, - onError: errCall, + onFail: errCall, } } // 定时检查是否超时... diff --git a/src/api/wsapi.js b/src/api/wsapi.js index 21ec75d..5636b97 100644 --- a/src/api/wsapi.js +++ b/src/api/wsapi.js @@ -1,3 +1,11 @@ import { sendPromise } from './websocket' +import { api } from './proto' export const aa = msg => sendPromise(msg) + +// 大厅桌面预览 +export const reqLobbyView = () => sendPromise(api.ReqLobbyView.create()); + +export const reqGameFullStatus = () => sendPromise(api.ReqGameFullStatus.create({})); + +export const reqJoinTable = tableNo => sendPromise(api.ReqJoinTable.create({tableNo})); diff --git a/src/components/card.jsx b/src/components/card.jsx index 79ac232..8b4b19c 100644 --- a/src/components/card.jsx +++ b/src/components/card.jsx @@ -12,7 +12,17 @@ import cardBack1 from '@/assets/card-back-1.svg' import cardBack2 from '@/assets/card-back-2.svg' import cardBack3 from '@/assets/card-back-3.svg' -const suits = [suit0Icon, suit1Icon, suit2Icon, suit3Icon]; +const suits = { + 0: suit0Icon, + 1: suit1Icon, + 2: suit2Icon, + 3: suit3Icon, + + D: suit0Icon, + C: suit1Icon, + H: suit2Icon, + S: suit3Icon, +}; const dots = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"]; function Card(props) { diff --git a/src/pages/lobby/lobby.jsx b/src/pages/lobby/lobby.jsx index 4aefaf5..405591d 100644 --- a/src/pages/lobby/lobby.jsx +++ b/src/pages/lobby/lobby.jsx @@ -5,10 +5,10 @@ import Taro from '@tarojs/taro' import { useSelector, useDispatch } from 'react-redux' import './lobby.scss' -import { navigateTo } from '@/utils/application' +import { navigateTo, redirectTo, showToast } from '@/utils/application' import { increment } from '@/store/index' import { fetchOpMap, fetchLobbyView } from '@/api/api' -import { sendPromise } from '@/api/websocket' +import { reqLobbyView, reqJoinTable } from '@/api/wsapi' import proto from '@/api/proto' import Title from '@/components/title' import coin1 from '@/assets/coin-1.png' @@ -30,14 +30,16 @@ class Lobby extends Component { } componentDidMount() { - sendPromise(ReqLobbyView.create()) - .then(res => { - console.log('lobby res:', res) - this.setState({tables: res.tables}) - }) - .catch(err => { - console.log('lobby err:', err) - }) + setTimeout(() => { + reqLobbyView() + .then(res => { + console.log('lobby res:', res) + this.setState({tables: res.tables}) + }) + .catch(err => { + console.log('lobby err:', err) + }) + }, 1500) // fetchLobbyView() // .then(res => { @@ -49,11 +51,21 @@ class Lobby extends Component { // }) } + async handleJoinTable(table) { + try { + const res = await reqJoinTable(table.tableNo) + redirectTo({url: '/pages/table/table'}) + // console.log('join res...', res) + }catch(err) { + showToast({title: err}) + } + } + render() { // const count = useSelector((state) => state.counter.value) // const user = useSelector((state) => state.user) - console.log('state', this.state) + // console.log('state', this.state) return ( @@ -61,7 +73,7 @@ class Lobby extends Component { <View className="tab"> { this.state.tables.map((table, i) => ( - <View key={table.TableNo} className="tab-wrap" onClick={() => {console.log('join', table)}}> + <View key={table.tableNo} className="tab-wrap" onClick={this.handleJoinTable.bind(this, table)}> <View className="circle-wrap"> <View className="circle-inner"><Image className="inner-coin" src={coin1} /></View> { @@ -87,7 +99,7 @@ class Lobby extends Component { )) } - <View className="tab-wrap"></View> + <View key="tab-wrap" className="tab-wrap"></View> </View> <View className="bottom-btn-wrap"> <Button className="bottom-btn" onClick={() => navigateTo({url: '/pages/new_table/new_table'})}>Create New Table</Button> diff --git a/src/pages/new_table/new_table.jsx b/src/pages/new_table/new_table.jsx index 6dabd8a..eba748d 100644 --- a/src/pages/new_table/new_table.jsx +++ b/src/pages/new_table/new_table.jsx @@ -3,6 +3,7 @@ import { View, Text, Image, Button } from '@tarojs/components' import { Popup, Picker } from '@nutui/nutui-react-taro'; import { useSelector } from 'react-redux' +import { redirectTo } from '@/utils/application' import './new_table.scss' import Title from '@/components/title' import { sendPromise } from '@/api/websocket' @@ -38,8 +39,8 @@ function NewTable() { robots: players.filter(type => type === 2).length }) try { - const res = await sendPromise(req) - console.log('finish', res) + const _ = await sendPromise(req) + redirectTo({url: '/pages/table/table'}) }catch(err) { showToast({title: err}) } finally { diff --git a/src/pages/table/table.jsx b/src/pages/table/table.jsx index 6862838..a02bba3 100644 --- a/src/pages/table/table.jsx +++ b/src/pages/table/table.jsx @@ -1,8 +1,11 @@ import React, { Component, useState } from 'react' import { View, Text, Image, Input, Button } from '@tarojs/components' -import { useSelector } from 'react-redux' +import { connect } from 'react-redux' import cnames from 'classnames' +import { reqGameFullStatus } from '@/api/wsapi' +import { ifEmpty } from '@/utils/validator' + import './table.scss' import Title from '@/components/title' import Card from '@/components/card' @@ -11,6 +14,7 @@ import coin2Icon from '@/assets/icon/coin-2.svg' import plus1Icon from '@/assets/icon/plus-1.svg' import sub1Icon from '@/assets/icon/sub-1.svg' import Taro from '@tarojs/taro' +import { showToast } from '@/utils/application' function PlayerStatus() { return ( @@ -20,129 +24,180 @@ function PlayerStatus() { ) } -function Table() { +function cardDot(card, cardBackCode) { + if (!card || !card.suit) { + return cardBackCode; + } + return card['dot']; +} - const { username, nickname, avatar } = useSelector(state => state.user); +function cardSuit(card) { + return card.suit || 'D'; +} - const players = [1, 2, 3, 4, 5, 6]; - const playerRows = players.reduce((arr, item, idx) => { - const row = parseInt(idx / 2); - let rowArr = arr[row] || []; - rowArr[idx % 2] = { index: idx, item }; - arr[row] = rowArr; - parseInt() - return arr; - }, []); +class Table extends Component { + constructor(props) { + super(props) + this.state = { + inGame: false, + tableNo: 0, + stage: 0, // 游戏阶段: 1等待玩家准备;2下大盲注;3下小盲注;4发公共牌;5发第四张公共牌,轮流下注;6发第五张公共牌,轮流下注,7比牌结算 + chip: 0, + RoundTimes: 0, - return ( - <View className="tab"> - <Title title="GAME" /> - { - playerRows.map((row, i) => ( - <View key={i} className="playerRow"> - { - row.map((player, j) => ( - <View key={j} className="player-wrap"> - { - j % 2 === 0 && - <View className={cnames('player-state-wrap', {'state-left': j % 2 === 0})}> - <PlayerStatus action={1} /> - </View> - } - <View className="player-bar"> - <View className={cnames("player-no", { "player-no-running": player.index === 0 })}><Text>#{player.index}</Text></View> - <View className="card1"><Card w={38} h={48} dot={-1} suit={2} /></View> - <View className="card2"><Card w={38} h={48} dot={-1} suit={3} /></View> - <View className={cnames("player", {'player-wait': player.index !== 0})}> - <View className="avatar-wrap"><Image className="avatar" src={avatar} /></View> - <View className="player-name"><Text>Player{player.item}</Text></View> - </View> - <View className="wallet-wrap"> - <View className={cnames("wallet", {'wallet-wait': player.index !== 0})}> - <View className="wallet-icon"><Image className="wallet-icon-img" src={coinIcon} /></View> - <View className="wallet-amount"><Text>3,000,000</Text></View> + players: [], + publicCard: [], + } + } + componentDidMount() { + console.log('table mount') + setTimeout(() => { + reqGameFullStatus() + .then(res => { + this.setState({ + inGame: !!res.inGame, + tableNo: res.tableNo, + stage: res.gameStage, + chip: res.chip || 0, + RoundTimes: res.RoundTimes || 0, + + players: res.players, + publicCard: res.publicCard, + }) + console.log('res game', res, res.publicCard[0].dot, ifEmpty(res.publicCard[0].dot, -3)) + window.publicCard = res.publicCard + }) + .catch(err => { + showToast({title: err}) + }) + }, 2000) + } + + render() { + const { username, nickname, avatar } = this.props.user; // useSelector(state => state.user); + // const players = [1, 2, 3, 4, 5, 6]; + const playerRows = this.state.players.reduce((arr, player, idx) => { + const row = parseInt(idx / 2); + let rowArr = arr[row] || []; + rowArr[idx % 2] = { index: idx, player }; + arr[row] = rowArr; + return arr; + }, []); + + return ( + <View className="tab"> + <Title title="GAME" /> + { + playerRows.map((row, i) => ( + <View key={i} className="playerRow"> + { + row.map((player, j) => ( + <View key={j} className="player-wrap"> + { + j % 2 === 0 && + <View className={cnames('player-state-wrap', {'state-left': j % 2 === 0})}> + <PlayerStatus action={1} /> + </View> + } + <View className="player-bar"> + <View className={cnames("player-no", { "player-no-running": player.index === 0 })}><Text>#{player.index}</Text></View> + <View className="card1"><Card w={38} h={48} dot={-1} suit={2} /></View> + <View className="card2"><Card w={38} h={48} dot={-1} suit={3} /></View> + <View className={cnames("player", {'player-wait': player.index !== 0})}> + <View className="avatar-wrap"><Image className="avatar" src={avatar} /></View> + <View className="player-name"><Text>Player{player.item}</Text></View> + </View> + <View className="wallet-wrap"> + <View className={cnames("wallet", {'wallet-wait': player.index !== 0})}> + <View className="wallet-icon"><Image className="wallet-icon-img" src={coinIcon} /></View> + <View className="wallet-amount"><Text>3,000,000</Text></View> + </View> + <View className="pct"><Text>25%</Text></View> </View> - <View className="pct"><Text>25%</Text></View> </View> </View> - </View> - )) - } - </View> - )) - } - <View className="desktop-box"> - <View className="desktop-wrap"> - <View className="desktop-cards"> - { - [1, 2, 3, -3, -3].map((item, i) => ( - <Card key={i} w={38} h={48} dot={item} suit={2} /> - )) - } - </View> - <View className="desktop-wallet"> - <View className="d-wallet-icon"> - <Image className="d-wallet-icon-img" src={coinIcon} /> - <Text className="d-wallet-icon-text">POT</Text> + )) + } + </View> + )) + } + <View className="desktop-box"> + <View className="desktop-wrap"> + <View className="desktop-cards"> + { + this.state.publicCard.map((card, i) => ( + <Card key={i} w={38} h={48} dot={cardDot(card, -3)} suit={cardSuit(card)} /> + )) + } + </View> + <View className="desktop-wallet"> + <View className="d-wallet-icon"> + <Image className="d-wallet-icon-img" src={coinIcon} /> + <Text className="d-wallet-icon-text">POT</Text> + </View> + <View className="d-wallet-amount">22,088,000</View> </View> - <View className="d-wallet-amount">22,088,000</View> </View> + {/* <View className="chatbox" style={{ display: 'none' }}> + <View className='chat-window'> + <View className="line">Kelly(#1)进入了游戏</View> + <View className="line">Apollo(#2)进入了游戏</View> + </View> + <View className='chat-panel'> + <View><Input name="chat" type="text" placeholder="" /></View> + <View><Button>OK</Button></View> + </View> + </View> */} </View> - {/* <View className="chatbox" style={{ display: 'none' }}> - <View className='chat-window'> - <View className="line">Kelly(#1)进入了游戏</View> - <View className="line">Apollo(#2)进入了游戏</View> - </View> - <View className='chat-panel'> - <View><Input name="chat" type="text" placeholder="" /></View> - <View><Button>OK</Button></View> - </View> - </View> */} - </View> - <View className="self-box"> - <View className="self-wrap"> - <View className={cnames("player-no", { "player-no-running": true })}><Text>#7</Text></View> - <View className="hand-card1"><Card w={38} h={48} dot={12} suit={3} /></View> - <View className="hand-card2"><Card w={38} h={48} dot={12} suit={3} /></View> - <View className="hand-five"> - { - [1, 2, 3, 4, 5].map((_, i) => ( - <View key={i} className="hand-five-item"><Card w={28} h={36} dot={12} suit={2} /></View> - )) - } - </View> - <View className='u-opt' style={{ display: 'flex' }}> - <View> - <View className="s-info-wrap"> - <View className="s-avatar"><Image className="s-avatar-img" src={avatar} /></View> - <View className="s-username"><Text>Prometheus</Text></View> - </View> - <View className="s-wallet-wrap"> - <View className="s-w-amount-wrap"> - <View className="s-w-amount-icon"><Image className="s-w-amount-icon-img" src={coin2Icon} /></View> - <View className="s-w-amount"><Text>3,000,000</Text></View> - </View> - <View className="s-w-pct"><Text>0%</Text></View> - </View> + <View className="self-box"> + <View className="self-wrap"> + <View className={cnames("player-no", { "player-no-running": true })}><Text>#7</Text></View> + <View className="hand-card1"><Card w={38} h={48} dot={12} suit={3} /></View> + <View className="hand-card2"><Card w={38} h={48} dot={12} suit={3} /></View> + <View className="hand-five"> + { + [1, 2, 3, 4, 5].map((_, i) => ( + <View key={i} className="hand-five-item"><Card w={28} h={36} dot={12} suit={2} /></View> + )) + } </View> - <View className="control"> - <View className="ctl-opt-wrap"> - <View className="amount-input"><Input placeholder='your chip' defaultValue={0} /></View> - <View className="amount-sub"><Image className="amount-sub-icon" src={sub1Icon} /></View> - <View className="amount-plus"><Image className="amount-plus-icon" src={plus1Icon} /></View> + <View className='u-opt' style={{ display: 'flex' }}> + <View> + <View className="s-info-wrap"> + <View className="s-avatar"><Image className="s-avatar-img" src={avatar} /></View> + <View className="s-username"><Text>Prometheus</Text></View> + </View> + <View className="s-wallet-wrap"> + <View className="s-w-amount-wrap"> + <View className="s-w-amount-icon"><Image className="s-w-amount-icon-img" src={coin2Icon} /></View> + <View className="s-w-amount"><Text>3,000,000</Text></View> + </View> + <View className="s-w-pct"><Text>0%</Text></View> + </View> </View> - <View className="ctl-opt-wrap" style={{ marginTop: Taro.pxTransform(10) }}> - <View className="ctl-opt"><Button className="ctl-opt-btn-1">让牌</Button></View> - <View className="ctl-opt"><Button className="ctl-opt-btn-2">弃牌</Button></View> - <View className="ctl-opt"><Button className="ctl-opt-btn-3">跟注</Button></View> + <View className="control"> + <View className="ctl-opt-wrap"> + <View className="amount-input"><Input placeholder='your chip' defaultValue={0} /></View> + <View className="amount-sub"><Image className="amount-sub-icon" src={sub1Icon} /></View> + <View className="amount-plus"><Image className="amount-plus-icon" src={plus1Icon} /></View> + </View> + <View className="ctl-opt-wrap" style={{ marginTop: Taro.pxTransform(10) }}> + <View className="ctl-opt"><Button className="ctl-opt-btn-1">让牌</Button></View> + <View className="ctl-opt"><Button className="ctl-opt-btn-2">弃牌</Button></View> + <View className="ctl-opt"><Button className="ctl-opt-btn-3">跟注</Button></View> + </View> </View> </View> </View> </View> </View> - </View> - ) + ) + } +} + +function mapStateToProps(state) { + return {user: state.user} } -export default Table +export default connect(mapStateToProps)(Table) diff --git a/src/utils/application.js b/src/utils/application.js index ec64351..2f543b1 100644 --- a/src/utils/application.js +++ b/src/utils/application.js @@ -54,7 +54,7 @@ export const navigateBack = function(option = {delta: 1}) { return Taro.navigateBack(option); } -export const showToast = function(option = {icon: 'success'}) { +export const showToast = function(option = {title: '', icon: 'none'}) { let {title} = option if (!title) { return } title = typeof(title) === 'string' ? title : title.msg || title.message; @@ -62,5 +62,7 @@ export const showToast = function(option = {icon: 'success'}) { console.log('no title toast:', option.title) return } + option.title = title + option.icon = option.icon || 'none'; Taro.showToast(option) } diff --git a/src/utils/validator.js b/src/utils/validator.js new file mode 100644 index 0000000..6886990 --- /dev/null +++ b/src/utils/validator.js @@ -0,0 +1,12 @@ + +// 判断数据是否为空 +export const isEmpty = data => { + return data === undefined || data === null || data === '' || + (Array.isArray(data) && data.length === 0) || + (typeof data === 'object' && Object.keys(data).length === 0); +} + +// 如果数据为空, 则使用默认值 +export const ifEmpty = (data, defaultValue) => { + return isEmpty(data) ? defaultValue : data; +}