diff --git a/src/api/proto.js b/src/api/proto.js index 6a21602..ea32ca9 100644 --- a/src/api/proto.js +++ b/src/api/proto.js @@ -5289,6 +5289,8 @@ export const api = $root.api = (() => { * @property {number|null} [status] TablePlayer status * @property {number|null} [lastStatus] TablePlayer lastStatus * @property {boolean|null} [master] TablePlayer master + * @property {number|null} [roundBetTimes] TablePlayer roundBetTimes + * @property {number|null} [totalBetChip] TablePlayer totalBetChip * @property {api.IBetRole|null} [betRole] TablePlayer betRole * @property {Array.|null} [handCard] TablePlayer handCard */ @@ -5373,6 +5375,22 @@ export const api = $root.api = (() => { */ TablePlayer.prototype.master = false; + /** + * TablePlayer roundBetTimes. + * @member {number} roundBetTimes + * @memberof api.TablePlayer + * @instance + */ + TablePlayer.prototype.roundBetTimes = 0; + + /** + * TablePlayer totalBetChip. + * @member {number} totalBetChip + * @memberof api.TablePlayer + * @instance + */ + TablePlayer.prototype.totalBetChip = 0; + /** * TablePlayer betRole. * @member {api.IBetRole|null|undefined} betRole @@ -5429,6 +5447,10 @@ export const api = $root.api = (() => { writer.uint32(/* id 7, wireType 0 =*/56).int32(message.lastStatus); if (message.master != null && Object.hasOwnProperty.call(message, "master")) writer.uint32(/* id 8, wireType 0 =*/64).bool(message.master); + if (message.roundBetTimes != null && Object.hasOwnProperty.call(message, "roundBetTimes")) + writer.uint32(/* id 11, wireType 0 =*/88).int32(message.roundBetTimes); + if (message.totalBetChip != null && Object.hasOwnProperty.call(message, "totalBetChip")) + writer.uint32(/* id 13, wireType 0 =*/104).int32(message.totalBetChip); if (message.betRole != null && Object.hasOwnProperty.call(message, "betRole")) $root.api.BetRole.encode(message.betRole, writer.uint32(/* id 14, wireType 2 =*/114).fork()).ldelim(); if (message.handCard != null && message.handCard.length) @@ -5500,6 +5522,14 @@ export const api = $root.api = (() => { message.master = reader.bool(); break; } + case 11: { + message.roundBetTimes = reader.int32(); + break; + } + case 13: { + message.totalBetChip = reader.int32(); + break; + } case 14: { message.betRole = $root.api.BetRole.decode(reader, reader.uint32()); break; @@ -5569,6 +5599,12 @@ export const api = $root.api = (() => { if (message.master != null && message.hasOwnProperty("master")) if (typeof message.master !== "boolean") return "master: boolean expected"; + if (message.roundBetTimes != null && message.hasOwnProperty("roundBetTimes")) + if (!$util.isInteger(message.roundBetTimes)) + return "roundBetTimes: integer expected"; + if (message.totalBetChip != null && message.hasOwnProperty("totalBetChip")) + if (!$util.isInteger(message.totalBetChip)) + return "totalBetChip: integer expected"; if (message.betRole != null && message.hasOwnProperty("betRole")) { let error = $root.api.BetRole.verify(message.betRole); if (error) @@ -5621,6 +5657,10 @@ export const api = $root.api = (() => { message.lastStatus = object.lastStatus | 0; if (object.master != null) message.master = Boolean(object.master); + if (object.roundBetTimes != null) + message.roundBetTimes = object.roundBetTimes | 0; + if (object.totalBetChip != null) + message.totalBetChip = object.totalBetChip | 0; if (object.betRole != null) { if (typeof object.betRole !== "object") throw TypeError(".api.TablePlayer.betRole: object expected"); @@ -5667,6 +5707,8 @@ export const api = $root.api = (() => { object.status = 0; object.lastStatus = 0; object.master = false; + object.roundBetTimes = 0; + object.totalBetChip = 0; object.betRole = null; } if (message.robot != null && message.hasOwnProperty("robot")) @@ -5688,6 +5730,10 @@ export const api = $root.api = (() => { object.lastStatus = message.lastStatus; if (message.master != null && message.hasOwnProperty("master")) object.master = message.master; + if (message.roundBetTimes != null && message.hasOwnProperty("roundBetTimes")) + object.roundBetTimes = message.roundBetTimes; + if (message.totalBetChip != null && message.hasOwnProperty("totalBetChip")) + object.totalBetChip = message.totalBetChip; if (message.betRole != null && message.hasOwnProperty("betRole")) object.betRole = $root.api.BetRole.toObject(message.betRole, options); if (message.handCard && message.handCard.length) { @@ -5960,8 +6006,9 @@ export const api = $root.api = (() => { * Properties of a BetRole. * @memberof api * @interface IBetRole - * @property {number|null} [minChip] BetRole minChip - * @property {number|null} [maxChip] BetRole maxChip + * @property {number|null} [betMin] BetRole betMin + * @property {number|null} [betMax] BetRole betMax + * @property {Array.|null} [betOpts] BetRole betOpts */ /** @@ -5973,6 +6020,7 @@ export const api = $root.api = (() => { * @param {api.IBetRole=} [properties] Properties to set */ function BetRole(properties) { + this.betOpts = []; if (properties) for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -5980,20 +6028,28 @@ export const api = $root.api = (() => { } /** - * BetRole minChip. - * @member {number} minChip + * BetRole betMin. + * @member {number} betMin * @memberof api.BetRole * @instance */ - BetRole.prototype.minChip = 0; + BetRole.prototype.betMin = 0; /** - * BetRole maxChip. - * @member {number} maxChip + * BetRole betMax. + * @member {number} betMax * @memberof api.BetRole * @instance */ - BetRole.prototype.maxChip = 0; + BetRole.prototype.betMax = 0; + + /** + * BetRole betOpts. + * @member {Array.} betOpts + * @memberof api.BetRole + * @instance + */ + BetRole.prototype.betOpts = $util.emptyArray; /** * Creates a new BetRole instance using the specified properties. @@ -6019,10 +6075,16 @@ export const api = $root.api = (() => { BetRole.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); - if (message.minChip != null && Object.hasOwnProperty.call(message, "minChip")) - writer.uint32(/* id 1, wireType 0 =*/8).int32(message.minChip); - if (message.maxChip != null && Object.hasOwnProperty.call(message, "maxChip")) - writer.uint32(/* id 2, wireType 0 =*/16).int32(message.maxChip); + if (message.betMin != null && Object.hasOwnProperty.call(message, "betMin")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.betMin); + if (message.betMax != null && Object.hasOwnProperty.call(message, "betMax")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.betMax); + if (message.betOpts != null && message.betOpts.length) { + writer.uint32(/* id 13, wireType 2 =*/106).fork(); + for (let i = 0; i < message.betOpts.length; ++i) + writer.int32(message.betOpts[i]); + writer.ldelim(); + } return writer; }; @@ -6058,11 +6120,22 @@ export const api = $root.api = (() => { let tag = reader.uint32(); switch (tag >>> 3) { case 1: { - message.minChip = reader.int32(); + message.betMin = reader.int32(); break; } case 2: { - message.maxChip = reader.int32(); + message.betMax = reader.int32(); + break; + } + case 13: { + if (!(message.betOpts && message.betOpts.length)) + message.betOpts = []; + if ((tag & 7) === 2) { + let end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.betOpts.push(reader.int32()); + } else + message.betOpts.push(reader.int32()); break; } default: @@ -6100,12 +6173,19 @@ export const api = $root.api = (() => { BetRole.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; - if (message.minChip != null && message.hasOwnProperty("minChip")) - if (!$util.isInteger(message.minChip)) - return "minChip: integer expected"; - if (message.maxChip != null && message.hasOwnProperty("maxChip")) - if (!$util.isInteger(message.maxChip)) - return "maxChip: integer expected"; + if (message.betMin != null && message.hasOwnProperty("betMin")) + if (!$util.isInteger(message.betMin)) + return "betMin: integer expected"; + if (message.betMax != null && message.hasOwnProperty("betMax")) + if (!$util.isInteger(message.betMax)) + return "betMax: integer expected"; + if (message.betOpts != null && message.hasOwnProperty("betOpts")) { + if (!Array.isArray(message.betOpts)) + return "betOpts: array expected"; + for (let i = 0; i < message.betOpts.length; ++i) + if (!$util.isInteger(message.betOpts[i])) + return "betOpts: integer[] expected"; + } return null; }; @@ -6121,10 +6201,17 @@ export const api = $root.api = (() => { if (object instanceof $root.api.BetRole) return object; let message = new $root.api.BetRole(); - if (object.minChip != null) - message.minChip = object.minChip | 0; - if (object.maxChip != null) - message.maxChip = object.maxChip | 0; + if (object.betMin != null) + message.betMin = object.betMin | 0; + if (object.betMax != null) + message.betMax = object.betMax | 0; + if (object.betOpts) { + if (!Array.isArray(object.betOpts)) + throw TypeError(".api.BetRole.betOpts: array expected"); + message.betOpts = []; + for (let i = 0; i < object.betOpts.length; ++i) + message.betOpts[i] = object.betOpts[i] | 0; + } return message; }; @@ -6141,14 +6228,21 @@ export const api = $root.api = (() => { if (!options) options = {}; let object = {}; + if (options.arrays || options.defaults) + object.betOpts = []; if (options.defaults) { - object.minChip = 0; - object.maxChip = 0; + object.betMin = 0; + object.betMax = 0; + } + if (message.betMin != null && message.hasOwnProperty("betMin")) + object.betMin = message.betMin; + if (message.betMax != null && message.hasOwnProperty("betMax")) + object.betMax = message.betMax; + if (message.betOpts && message.betOpts.length) { + object.betOpts = []; + for (let j = 0; j < message.betOpts.length; ++j) + object.betOpts[j] = message.betOpts[j]; } - if (message.minChip != null && message.hasOwnProperty("minChip")) - object.minChip = message.minChip; - if (message.maxChip != null && message.hasOwnProperty("maxChip")) - object.maxChip = message.maxChip; return object; }; @@ -6706,25 +6800,25 @@ export const api = $root.api = (() => { return ResDismissGameTable; })(); - api.ReqPlaceBetChip = (function() { + api.ReqBetting = (function() { /** - * Properties of a ReqPlaceBetChip. + * Properties of a ReqBetting. * @memberof api - * @interface IReqPlaceBetChip - * @property {number|null} [betChip] ReqPlaceBetChip betChip - * @property {boolean|null} [allIn] ReqPlaceBetChip allIn + * @interface IReqBetting + * @property {number|null} [betType] ReqBetting betType + * @property {number|null} [betChip] ReqBetting betChip */ /** - * Constructs a new ReqPlaceBetChip. + * Constructs a new ReqBetting. * @memberof api - * @classdesc Represents a ReqPlaceBetChip. - * @implements IReqPlaceBetChip + * @classdesc Represents a ReqBetting. + * @implements IReqBetting * @constructor - * @param {api.IReqPlaceBetChip=} [properties] Properties to set + * @param {api.IReqBetting=} [properties] Properties to set */ - function ReqPlaceBetChip(properties) { + function ReqBetting(properties) { if (properties) for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -6732,89 +6826,89 @@ export const api = $root.api = (() => { } /** - * ReqPlaceBetChip betChip. - * @member {number} betChip - * @memberof api.ReqPlaceBetChip + * ReqBetting betType. + * @member {number} betType + * @memberof api.ReqBetting * @instance */ - ReqPlaceBetChip.prototype.betChip = 0; + ReqBetting.prototype.betType = 0; /** - * ReqPlaceBetChip allIn. - * @member {boolean} allIn - * @memberof api.ReqPlaceBetChip + * ReqBetting betChip. + * @member {number} betChip + * @memberof api.ReqBetting * @instance */ - ReqPlaceBetChip.prototype.allIn = false; + ReqBetting.prototype.betChip = 0; /** - * Creates a new ReqPlaceBetChip instance using the specified properties. + * Creates a new ReqBetting instance using the specified properties. * @function create - * @memberof api.ReqPlaceBetChip + * @memberof api.ReqBetting * @static - * @param {api.IReqPlaceBetChip=} [properties] Properties to set - * @returns {api.ReqPlaceBetChip} ReqPlaceBetChip instance + * @param {api.IReqBetting=} [properties] Properties to set + * @returns {api.ReqBetting} ReqBetting instance */ - ReqPlaceBetChip.create = function create(properties) { - return new ReqPlaceBetChip(properties); + ReqBetting.create = function create(properties) { + return new ReqBetting(properties); }; /** - * Encodes the specified ReqPlaceBetChip message. Does not implicitly {@link api.ReqPlaceBetChip.verify|verify} messages. + * Encodes the specified ReqBetting message. Does not implicitly {@link api.ReqBetting.verify|verify} messages. * @function encode - * @memberof api.ReqPlaceBetChip + * @memberof api.ReqBetting * @static - * @param {api.IReqPlaceBetChip} message ReqPlaceBetChip message or plain object to encode + * @param {api.IReqBetting} message ReqBetting message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - ReqPlaceBetChip.encode = function encode(message, writer) { + ReqBetting.encode = function encode(message, writer) { if (!writer) writer = $Writer.create(); + if (message.betType != null && Object.hasOwnProperty.call(message, "betType")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.betType); if (message.betChip != null && Object.hasOwnProperty.call(message, "betChip")) - writer.uint32(/* id 1, wireType 0 =*/8).int32(message.betChip); - if (message.allIn != null && Object.hasOwnProperty.call(message, "allIn")) - writer.uint32(/* id 2, wireType 0 =*/16).bool(message.allIn); + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.betChip); return writer; }; /** - * Encodes the specified ReqPlaceBetChip message, length delimited. Does not implicitly {@link api.ReqPlaceBetChip.verify|verify} messages. + * Encodes the specified ReqBetting message, length delimited. Does not implicitly {@link api.ReqBetting.verify|verify} messages. * @function encodeDelimited - * @memberof api.ReqPlaceBetChip + * @memberof api.ReqBetting * @static - * @param {api.IReqPlaceBetChip} message ReqPlaceBetChip message or plain object to encode + * @param {api.IReqBetting} message ReqBetting message or plain object to encode * @param {$protobuf.Writer} [writer] Writer to encode to * @returns {$protobuf.Writer} Writer */ - ReqPlaceBetChip.encodeDelimited = function encodeDelimited(message, writer) { + ReqBetting.encodeDelimited = function encodeDelimited(message, writer) { return this.encode(message, writer).ldelim(); }; /** - * Decodes a ReqPlaceBetChip message from the specified reader or buffer. + * Decodes a ReqBetting message from the specified reader or buffer. * @function decode - * @memberof api.ReqPlaceBetChip + * @memberof api.ReqBetting * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from * @param {number} [length] Message length if known beforehand - * @returns {api.ReqPlaceBetChip} ReqPlaceBetChip + * @returns {api.ReqBetting} ReqBetting * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - ReqPlaceBetChip.decode = function decode(reader, length) { + ReqBetting.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.ReqPlaceBetChip(); + let end = length === undefined ? reader.len : reader.pos + length, message = new $root.api.ReqBetting(); while (reader.pos < end) { let tag = reader.uint32(); switch (tag >>> 3) { case 1: { - message.betChip = reader.int32(); + message.betType = reader.int32(); break; } case 2: { - message.allIn = reader.bool(); + message.betChip = reader.int32(); break; } default: @@ -6826,461 +6920,111 @@ export const api = $root.api = (() => { }; /** - * Decodes a ReqPlaceBetChip message from the specified reader or buffer, length delimited. + * Decodes a ReqBetting message from the specified reader or buffer, length delimited. * @function decodeDelimited - * @memberof api.ReqPlaceBetChip + * @memberof api.ReqBetting * @static * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {api.ReqPlaceBetChip} ReqPlaceBetChip + * @returns {api.ReqBetting} ReqBetting * @throws {Error} If the payload is not a reader or valid buffer * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - ReqPlaceBetChip.decodeDelimited = function decodeDelimited(reader) { + ReqBetting.decodeDelimited = function decodeDelimited(reader) { if (!(reader instanceof $Reader)) reader = new $Reader(reader); return this.decode(reader, reader.uint32()); }; /** - * Verifies a ReqPlaceBetChip message. + * Verifies a ReqBetting message. * @function verify - * @memberof api.ReqPlaceBetChip + * @memberof api.ReqBetting * @static * @param {Object.} message Plain object to verify * @returns {string|null} `null` if valid, otherwise the reason why it is not */ - ReqPlaceBetChip.verify = function verify(message) { + ReqBetting.verify = function verify(message) { if (typeof message !== "object" || message === null) return "object expected"; + if (message.betType != null && message.hasOwnProperty("betType")) + if (!$util.isInteger(message.betType)) + return "betType: integer expected"; if (message.betChip != null && message.hasOwnProperty("betChip")) if (!$util.isInteger(message.betChip)) return "betChip: integer expected"; - if (message.allIn != null && message.hasOwnProperty("allIn")) - if (typeof message.allIn !== "boolean") - return "allIn: boolean expected"; return null; }; /** - * Creates a ReqPlaceBetChip message from a plain object. Also converts values to their respective internal types. + * Creates a ReqBetting message from a plain object. Also converts values to their respective internal types. * @function fromObject - * @memberof api.ReqPlaceBetChip + * @memberof api.ReqBetting * @static * @param {Object.} object Plain object - * @returns {api.ReqPlaceBetChip} ReqPlaceBetChip + * @returns {api.ReqBetting} ReqBetting */ - ReqPlaceBetChip.fromObject = function fromObject(object) { - if (object instanceof $root.api.ReqPlaceBetChip) + ReqBetting.fromObject = function fromObject(object) { + if (object instanceof $root.api.ReqBetting) return object; - let message = new $root.api.ReqPlaceBetChip(); + let message = new $root.api.ReqBetting(); + if (object.betType != null) + message.betType = object.betType | 0; if (object.betChip != null) message.betChip = object.betChip | 0; - if (object.allIn != null) - message.allIn = Boolean(object.allIn); return message; }; /** - * Creates a plain object from a ReqPlaceBetChip message. Also converts values to other types if specified. + * Creates a plain object from a ReqBetting message. Also converts values to other types if specified. * @function toObject - * @memberof api.ReqPlaceBetChip + * @memberof api.ReqBetting * @static - * @param {api.ReqPlaceBetChip} message ReqPlaceBetChip + * @param {api.ReqBetting} message ReqBetting * @param {$protobuf.IConversionOptions} [options] Conversion options * @returns {Object.} Plain object */ - ReqPlaceBetChip.toObject = function toObject(message, options) { + ReqBetting.toObject = function toObject(message, options) { if (!options) options = {}; let object = {}; if (options.defaults) { + object.betType = 0; object.betChip = 0; - object.allIn = false; } + if (message.betType != null && message.hasOwnProperty("betType")) + object.betType = message.betType; if (message.betChip != null && message.hasOwnProperty("betChip")) object.betChip = message.betChip; - if (message.allIn != null && message.hasOwnProperty("allIn")) - object.allIn = message.allIn; return object; }; /** - * Converts this ReqPlaceBetChip to JSON. - * @function toJSON - * @memberof api.ReqPlaceBetChip - * @instance - * @returns {Object.} JSON object - */ - ReqPlaceBetChip.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - /** - * Gets the default type url for ReqPlaceBetChip - * @function getTypeUrl - * @memberof api.ReqPlaceBetChip - * @static - * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") - * @returns {string} The default type url - */ - ReqPlaceBetChip.getTypeUrl = function getTypeUrl(typeUrlPrefix) { - if (typeUrlPrefix === undefined) { - typeUrlPrefix = "type.googleapis.com"; - } - return typeUrlPrefix + "/api.ReqPlaceBetChip"; - }; - - return ReqPlaceBetChip; - })(); - - api.ReqBetWeakHand = (function() { - - /** - * Properties of a ReqBetWeakHand. - * @memberof api - * @interface IReqBetWeakHand - */ - - /** - * Constructs a new ReqBetWeakHand. - * @memberof api - * @classdesc Represents a ReqBetWeakHand. - * @implements IReqBetWeakHand - * @constructor - * @param {api.IReqBetWeakHand=} [properties] Properties to set - */ - function ReqBetWeakHand(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 ReqBetWeakHand instance using the specified properties. - * @function create - * @memberof api.ReqBetWeakHand - * @static - * @param {api.IReqBetWeakHand=} [properties] Properties to set - * @returns {api.ReqBetWeakHand} ReqBetWeakHand instance - */ - ReqBetWeakHand.create = function create(properties) { - return new ReqBetWeakHand(properties); - }; - - /** - * Encodes the specified ReqBetWeakHand message. Does not implicitly {@link api.ReqBetWeakHand.verify|verify} messages. - * @function encode - * @memberof api.ReqBetWeakHand - * @static - * @param {api.IReqBetWeakHand} message ReqBetWeakHand message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ReqBetWeakHand.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - return writer; - }; - - /** - * Encodes the specified ReqBetWeakHand message, length delimited. Does not implicitly {@link api.ReqBetWeakHand.verify|verify} messages. - * @function encodeDelimited - * @memberof api.ReqBetWeakHand - * @static - * @param {api.IReqBetWeakHand} message ReqBetWeakHand message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ReqBetWeakHand.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a ReqBetWeakHand message from the specified reader or buffer. - * @function decode - * @memberof api.ReqBetWeakHand - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {api.ReqBetWeakHand} ReqBetWeakHand - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ReqBetWeakHand.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.ReqBetWeakHand(); - while (reader.pos < end) { - let tag = reader.uint32(); - switch (tag >>> 3) { - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a ReqBetWeakHand message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof api.ReqBetWeakHand - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {api.ReqBetWeakHand} ReqBetWeakHand - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ReqBetWeakHand.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a ReqBetWeakHand message. - * @function verify - * @memberof api.ReqBetWeakHand - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - ReqBetWeakHand.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - return null; - }; - - /** - * Creates a ReqBetWeakHand message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof api.ReqBetWeakHand - * @static - * @param {Object.} object Plain object - * @returns {api.ReqBetWeakHand} ReqBetWeakHand - */ - ReqBetWeakHand.fromObject = function fromObject(object) { - if (object instanceof $root.api.ReqBetWeakHand) - return object; - return new $root.api.ReqBetWeakHand(); - }; - - /** - * Creates a plain object from a ReqBetWeakHand message. Also converts values to other types if specified. - * @function toObject - * @memberof api.ReqBetWeakHand - * @static - * @param {api.ReqBetWeakHand} message ReqBetWeakHand - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - ReqBetWeakHand.toObject = function toObject() { - return {}; - }; - - /** - * Converts this ReqBetWeakHand to JSON. - * @function toJSON - * @memberof api.ReqBetWeakHand - * @instance - * @returns {Object.} JSON object - */ - ReqBetWeakHand.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - /** - * Gets the default type url for ReqBetWeakHand - * @function getTypeUrl - * @memberof api.ReqBetWeakHand - * @static - * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") - * @returns {string} The default type url - */ - ReqBetWeakHand.getTypeUrl = function getTypeUrl(typeUrlPrefix) { - if (typeUrlPrefix === undefined) { - typeUrlPrefix = "type.googleapis.com"; - } - return typeUrlPrefix + "/api.ReqBetWeakHand"; - }; - - return ReqBetWeakHand; - })(); - - api.ReqBetDiscard = (function() { - - /** - * Properties of a ReqBetDiscard. - * @memberof api - * @interface IReqBetDiscard - */ - - /** - * Constructs a new ReqBetDiscard. - * @memberof api - * @classdesc Represents a ReqBetDiscard. - * @implements IReqBetDiscard - * @constructor - * @param {api.IReqBetDiscard=} [properties] Properties to set - */ - function ReqBetDiscard(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 ReqBetDiscard instance using the specified properties. - * @function create - * @memberof api.ReqBetDiscard - * @static - * @param {api.IReqBetDiscard=} [properties] Properties to set - * @returns {api.ReqBetDiscard} ReqBetDiscard instance - */ - ReqBetDiscard.create = function create(properties) { - return new ReqBetDiscard(properties); - }; - - /** - * Encodes the specified ReqBetDiscard message. Does not implicitly {@link api.ReqBetDiscard.verify|verify} messages. - * @function encode - * @memberof api.ReqBetDiscard - * @static - * @param {api.IReqBetDiscard} message ReqBetDiscard message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ReqBetDiscard.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - return writer; - }; - - /** - * Encodes the specified ReqBetDiscard message, length delimited. Does not implicitly {@link api.ReqBetDiscard.verify|verify} messages. - * @function encodeDelimited - * @memberof api.ReqBetDiscard - * @static - * @param {api.IReqBetDiscard} message ReqBetDiscard message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - ReqBetDiscard.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a ReqBetDiscard message from the specified reader or buffer. - * @function decode - * @memberof api.ReqBetDiscard - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {api.ReqBetDiscard} ReqBetDiscard - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ReqBetDiscard.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.ReqBetDiscard(); - while (reader.pos < end) { - let tag = reader.uint32(); - switch (tag >>> 3) { - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a ReqBetDiscard message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof api.ReqBetDiscard - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {api.ReqBetDiscard} ReqBetDiscard - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - ReqBetDiscard.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a ReqBetDiscard message. - * @function verify - * @memberof api.ReqBetDiscard - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - ReqBetDiscard.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - return null; - }; - - /** - * Creates a ReqBetDiscard message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof api.ReqBetDiscard - * @static - * @param {Object.} object Plain object - * @returns {api.ReqBetDiscard} ReqBetDiscard - */ - ReqBetDiscard.fromObject = function fromObject(object) { - if (object instanceof $root.api.ReqBetDiscard) - return object; - return new $root.api.ReqBetDiscard(); - }; - - /** - * Creates a plain object from a ReqBetDiscard message. Also converts values to other types if specified. - * @function toObject - * @memberof api.ReqBetDiscard - * @static - * @param {api.ReqBetDiscard} message ReqBetDiscard - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - ReqBetDiscard.toObject = function toObject() { - return {}; - }; - - /** - * Converts this ReqBetDiscard to JSON. + * Converts this ReqBetting to JSON. * @function toJSON - * @memberof api.ReqBetDiscard + * @memberof api.ReqBetting * @instance * @returns {Object.} JSON object */ - ReqBetDiscard.prototype.toJSON = function toJSON() { + ReqBetting.prototype.toJSON = function toJSON() { return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; /** - * Gets the default type url for ReqBetDiscard + * Gets the default type url for ReqBetting * @function getTypeUrl - * @memberof api.ReqBetDiscard + * @memberof api.ReqBetting * @static * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") * @returns {string} The default type url */ - ReqBetDiscard.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + ReqBetting.getTypeUrl = function getTypeUrl(typeUrlPrefix) { if (typeUrlPrefix === undefined) { typeUrlPrefix = "type.googleapis.com"; } - return typeUrlPrefix + "/api.ReqBetDiscard"; + return typeUrlPrefix + "/api.ReqBetting"; }; - return ReqBetDiscard; + return ReqBetting; })(); api.ResNoticePlayerLine = (function() { @@ -7570,6 +7314,247 @@ export const api = $root.api = (() => { return ResNoticePlayerLine; })(); + api.ResCalcWinnerChip = (function() { + + /** + * Properties of a ResCalcWinnerChip. + * @memberof api + * @interface IResCalcWinnerChip + * @property {Object.|null} [playersWinChip] ResCalcWinnerChip playersWinChip + */ + + /** + * Constructs a new ResCalcWinnerChip. + * @memberof api + * @classdesc Represents a ResCalcWinnerChip. + * @implements IResCalcWinnerChip + * @constructor + * @param {api.IResCalcWinnerChip=} [properties] Properties to set + */ + function ResCalcWinnerChip(properties) { + this.playersWinChip = {}; + 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]]; + } + + /** + * ResCalcWinnerChip playersWinChip. + * @member {Object.} playersWinChip + * @memberof api.ResCalcWinnerChip + * @instance + */ + ResCalcWinnerChip.prototype.playersWinChip = $util.emptyObject; + + /** + * Creates a new ResCalcWinnerChip instance using the specified properties. + * @function create + * @memberof api.ResCalcWinnerChip + * @static + * @param {api.IResCalcWinnerChip=} [properties] Properties to set + * @returns {api.ResCalcWinnerChip} ResCalcWinnerChip instance + */ + ResCalcWinnerChip.create = function create(properties) { + return new ResCalcWinnerChip(properties); + }; + + /** + * Encodes the specified ResCalcWinnerChip message. Does not implicitly {@link api.ResCalcWinnerChip.verify|verify} messages. + * @function encode + * @memberof api.ResCalcWinnerChip + * @static + * @param {api.IResCalcWinnerChip} message ResCalcWinnerChip message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResCalcWinnerChip.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.playersWinChip != null && Object.hasOwnProperty.call(message, "playersWinChip")) + for (let keys = Object.keys(message.playersWinChip), i = 0; i < keys.length; ++i) + writer.uint32(/* id 9, wireType 2 =*/74).fork().uint32(/* id 1, wireType 0 =*/8).int64(keys[i]).uint32(/* id 2, wireType 0 =*/16).int32(message.playersWinChip[keys[i]]).ldelim(); + return writer; + }; + + /** + * Encodes the specified ResCalcWinnerChip message, length delimited. Does not implicitly {@link api.ResCalcWinnerChip.verify|verify} messages. + * @function encodeDelimited + * @memberof api.ResCalcWinnerChip + * @static + * @param {api.IResCalcWinnerChip} message ResCalcWinnerChip message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ResCalcWinnerChip.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ResCalcWinnerChip message from the specified reader or buffer. + * @function decode + * @memberof api.ResCalcWinnerChip + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {api.ResCalcWinnerChip} ResCalcWinnerChip + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResCalcWinnerChip.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.ResCalcWinnerChip(), key, value; + while (reader.pos < end) { + let tag = reader.uint32(); + switch (tag >>> 3) { + case 9: { + if (message.playersWinChip === $util.emptyObject) + message.playersWinChip = {}; + let end2 = reader.uint32() + reader.pos; + key = 0; + value = 0; + while (reader.pos < end2) { + let tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.int64(); + break; + case 2: + value = reader.int32(); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.playersWinChip[typeof key === "object" ? $util.longToHash(key) : key] = value; + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ResCalcWinnerChip message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof api.ResCalcWinnerChip + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {api.ResCalcWinnerChip} ResCalcWinnerChip + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ResCalcWinnerChip.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ResCalcWinnerChip message. + * @function verify + * @memberof api.ResCalcWinnerChip + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ResCalcWinnerChip.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.playersWinChip != null && message.hasOwnProperty("playersWinChip")) { + if (!$util.isObject(message.playersWinChip)) + return "playersWinChip: object expected"; + let key = Object.keys(message.playersWinChip); + for (let i = 0; i < key.length; ++i) { + if (!$util.key64Re.test(key[i])) + return "playersWinChip: integer|Long key{k:int64} expected"; + if (!$util.isInteger(message.playersWinChip[key[i]])) + return "playersWinChip: integer{k:int64} expected"; + } + } + return null; + }; + + /** + * Creates a ResCalcWinnerChip message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof api.ResCalcWinnerChip + * @static + * @param {Object.} object Plain object + * @returns {api.ResCalcWinnerChip} ResCalcWinnerChip + */ + ResCalcWinnerChip.fromObject = function fromObject(object) { + if (object instanceof $root.api.ResCalcWinnerChip) + return object; + let message = new $root.api.ResCalcWinnerChip(); + if (object.playersWinChip) { + if (typeof object.playersWinChip !== "object") + throw TypeError(".api.ResCalcWinnerChip.playersWinChip: object expected"); + message.playersWinChip = {}; + for (let keys = Object.keys(object.playersWinChip), i = 0; i < keys.length; ++i) + message.playersWinChip[keys[i]] = object.playersWinChip[keys[i]] | 0; + } + return message; + }; + + /** + * Creates a plain object from a ResCalcWinnerChip message. Also converts values to other types if specified. + * @function toObject + * @memberof api.ResCalcWinnerChip + * @static + * @param {api.ResCalcWinnerChip} message ResCalcWinnerChip + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ResCalcWinnerChip.toObject = function toObject(message, options) { + if (!options) + options = {}; + let object = {}; + if (options.objects || options.defaults) + object.playersWinChip = {}; + let keys2; + if (message.playersWinChip && (keys2 = Object.keys(message.playersWinChip)).length) { + object.playersWinChip = {}; + for (let j = 0; j < keys2.length; ++j) + object.playersWinChip[keys2[j]] = message.playersWinChip[keys2[j]]; + } + return object; + }; + + /** + * Converts this ResCalcWinnerChip to JSON. + * @function toJSON + * @memberof api.ResCalcWinnerChip + * @instance + * @returns {Object.} JSON object + */ + ResCalcWinnerChip.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ResCalcWinnerChip + * @function getTypeUrl + * @memberof api.ResCalcWinnerChip + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ResCalcWinnerChip.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/api.ResCalcWinnerChip"; + }; + + return ResCalcWinnerChip; + })(); + return api; })(); diff --git a/src/api/wsapi.js b/src/api/wsapi.js index 1070613..1be9fae 100644 --- a/src/api/wsapi.js +++ b/src/api/wsapi.js @@ -25,3 +25,5 @@ export const reqCancelReady = () => sendPromise(api.ReqCancelReady.create()); export const reqDismissGameTable = () => sendPromise(api.ReqDismissGameTable.create()); // 开始牌局 export const reqGameStart = () => sendPromise(api.ReqGameStart.create()); +// 玩家下注 +export const reqBetting = (betType, betChip) => sendPromise(api.ReqBetting.create({betType, betChip})); diff --git a/src/pages/table/table.jsx b/src/pages/table/table.jsx index d5e6a18..56b83cc 100644 --- a/src/pages/table/table.jsx +++ b/src/pages/table/table.jsx @@ -6,10 +6,10 @@ import cnames from 'classnames' import { reqGameFullStatus, reqKickOutTable, reqLeaveTable, reqReadyStart, reqDismissGameTable, reqGameStart, - reqCancelReady + reqCancelReady, reqBetting } from '@/api/wsapi' import { addMsgListen, removeMsgListener } from '@/api/websocket' -import { ifEmpty } from '@/utils/validator' +import { isEmpty } from '@/utils/validator' import './table.scss' import Title from '@/components/title' @@ -71,6 +71,15 @@ class Table extends Component { players: [], publicCard: [], + + otherPlayers: [], + selfIndex: 0, + selfPlayer: {handCard: [], betRole: {}}, + + betType: 0, + bettingChip: 0, + betConfirmText: '下注', + betSubmitLoading: false, } } @@ -94,14 +103,14 @@ class Table extends Component { showToast({title: '牌桌已解散'}); setTimeout(() => redirectTo({url: '/pages/lobby/lobby'}), 800); }); - // 扣除大盲注(显示3秒) - addMsgListen('api.ResBigBlindChip', res => { - showToast({title: '大盲注:' + res.chip}); - }); - // 扣除小盲注(显示3秒) - addMsgListen('api.ResSmallBlindChip', res => { - showToast({title: '小盲注:' + res.chip}); - }); + // // 扣除大盲注(显示3秒) + // addMsgListen('api.ResBigBlindChip', res => { + // showToast({title: '大盲注:' + res.chip}); + // }); + // // 扣除小盲注(显示3秒) + // addMsgListen('api.ResSmallBlindChip', res => { + // showToast({title: '小盲注:' + res.chip}); + // }); // 查询当前牌桌状态 reqGameFullStatus() @@ -118,6 +127,11 @@ class Table extends Component { } handleResGameFullStatus = res => { + const players = res.players.map((player, index) => ({player, index})); + const otherPlayers = players.filter(({player}) => player.id !== res.playerId); + const self = players.find(({player}) => player.id === res.playerId); + const {index: selfIndex, player: selfPlayer} = self || {player: {handCard: [], betRole: {}}}; + this.setState({ playerId: res.playerId, inGame: !!res.inGame, @@ -131,6 +145,11 @@ class Table extends Component { players: res.players, publicCard: res.publicCard, + + otherPlayers, + selfIndex, + selfPlayer, + bettingChip: this.state.bettingChip !== 0 ? this.state.bettingChip : selfPlayer.betMin }) // console.log('res game', res, res.publicCard[0].dot, ifEmpty(res.publicCard[0].dot, -3)) window.publicCard = res.publicCard @@ -211,18 +230,69 @@ class Table extends Component { .catch(err => showToast({title: err})); } + // 加注 + handleSubPlusBetting(symbol, once) { + const c = this.state.bettingChip || 0; + const {betRole: {betMax}} = this.state.selfPlayer; + if (symbol < 0 && c <= 0) { // 减 + return; + } else if (symbol > 0 && betMax >= 0 && c >= betMax) { // 加 + return; + } + const chip = c + symbol * once; + this.setState({bettingChip: chip, betType: 2}); + } + + // 跟注,弃牌...操作按钮 + handleBetting(betType) { + console.log('betType', betType) + const {betRole: {betMin}} = this.state.selfPlayer; + switch(betType) { + case 1: // 1跟注,2加注(-[0]+),3All-In,4弃牌,5过牌 + this.setState({betType: 1, bettingChip: betMin, betConfirmText: '跟注'}); + break; + case 4: + this.setState({betType: 4, betConfirmText: '弃牌'}); + break; + } + + } + + handleBetConfirm() { + const {betType, bettingChip} = this.state; + if (betType === 0) { + return showToast({title: '请增加下注筹码或其他操作'}); + } + + console.log('confirm', betType, bettingChip) + + this.setState({betSubmitLoading: true}, () => { + reqBetting(betType, bettingChip || 0) + .then(res => { + console.log('betRes', res); + }) + .catch(err => { + showToast({title: err}) + }) + .finally(() => { + this.setState({betSubmitLoading: false, betConfirmText: '下注'}) + }) + }) + } + render() { const { username, nickname, avatar, defaultAvatar } = this.props.user; // useSelector(state => state.user); // const players = [1, 2, 3, 4, 5, 6]; const players = this.state.players.map((player, index) => ({player, index})); - const {inGame, playerId, tableNo, stage, bigBlindPos, smallBlindPos, chip, roundTimes} = this.state; - - // 从玩家中找到自己 TODO 弄到 state, 避免每次render计算 + const { + inGame, playerId, tableNo, + stage, bigBlindPos, smallBlindPos, + chip, roundTimes, otherPlayers, + selfIndex, selfPlayer, + bettingChip, betConfirmText, betSubmitLoading + } = this.state; + const {betMin, betMax, betOpts} = selfPlayer.betRole; // console.log('props', this.props); - const otherPlayers = players.filter(({player}) => player.id !== playerId); - const self = players.find(({player}) => player.id === playerId); - const {index: selfIndex , player: selfPlayer} = self || {player: {handCard: []}}; - // console.log(otherPlayers, self) const playerRows = otherPlayers.reduce((arr, player, idx) => { const row = parseInt(idx / 2); @@ -312,7 +382,7 @@ class Table extends Component { { this.state.publicCard.map((card, i) => ( - + )) } @@ -393,9 +463,15 @@ class Table extends Component { - - - + {isEmpty(betOpts) ? null : this.setState({bettingChip: e.target.value})} + />} + {!isIn(2, betOpts) ? null : } + {!isIn(2, betOpts) ? null : } { stage === 1 ? ( @@ -412,13 +488,27 @@ class Table extends Component { ) : - - - + { + !isIn(4, betOpts) ? + : + } + { + !isIn(5, betOpts)? + : + } + { + !isIn(1, betOpts)? + : + } - - + { + !isIn(3, betOpts)? + : + } + + {isEmpty(betOpts) ? null : } + } diff --git a/src/pages/table/table.scss b/src/pages/table/table.scss index 6b49b8c..e0693ba 100644 --- a/src/pages/table/table.scss +++ b/src/pages/table/table.scss @@ -431,6 +431,7 @@ .control { align-self: flex-end; margin-left: 30px; + margin-bottom: 1px; } .ctl-opt-wrap,.ctl-opt-wrap-cfm { @@ -447,9 +448,12 @@ text-align: center; background-color: #F1D09F; border-radius: 8px; - font-size: 12px; - padding: 4px 0; - color: 3D3D3D; + padding: 2px 0; + } + .amount-input-in { + font-size: 14px; + line-height: 28px; + color: #3D3D3D; } .amount-sub, @@ -472,8 +476,10 @@ height: 13px; } + .ctl-opacity0 { + opacity: 0; + } .ctl-opt {} - .ctl-opt-btn-1, .ctl-opt-btn-2, .ctl-opt-btn-3, diff --git a/src/utils/collect.js b/src/utils/collect.js index 5f6c93e..b278584 100644 --- a/src/utils/collect.js +++ b/src/utils/collect.js @@ -1,5 +1,11 @@ export const isIn = (value, ...values) => { + if (!values) { + return false; + } + if (values.length === 1 && Array.isArray(values[0])) { + values = values[0]; + } for (let i = 0; i < values.length; i++) { if (values[i] === value) { return true;