public bool Run(NetworkStream stream, string input)
        {
            var args  = Regex.Split(input, @"\s+");
            var type  = ContractInfo.EType.Undefined;
            var value = 0;

            if (!CheckFormat(args) || !CheckValue(args))
            {
                return(false);
            }

            foreach (var enumType in Enum.GetValues(typeof(ContractInfo.EType)))
            {
                if (enumType.ToString().ToLower().Equals(args[1].ToLower()))
                {
                    type = (ContractInfo.EType)enumType;
                }
            }

            if (!args[1].Equals("pass"))
            {
                value = Convert.ToInt32(args[2]);
            }

            var proto = new LobbyContract(type, value);

            stream.Write(proto.ProtobufTypeAsBytes, 0, 2);
            ProtoBuf.Serializer.SerializeWithLengthPrefix(stream, proto, ProtoBuf.PrefixStyle.Fixed32);
            return(true);
        }
        public bool Run(NetworkStream stream, string input)
        {
            var proto = new LobbyContract {
                ContractType = (ContractInfo.EType)Convert.ToInt32(input)
            };

            stream.Write(proto.ProtobufTypeAsBytes, 0, 2);
            ProtoBuf.Serializer.SerializeWithLengthPrefix(stream, proto, ProtoBuf.PrefixStyle.Fixed32);
            return(true);
        }
        private bool HandleContract(LobbyContract command, Client client)
        {
            if (command.ContractType == ContractInfo.EType.Undefined || client.Info.Id != Lobby.Info.Clients[Turn].Id)
            {
                return(false);
            }

            if (command.ContractType == ContractInfo.EType.Pass)
            {
                Lobby.Broadcast(client.Info.Name + " passed.");
                return(true);
            }
            if (Contract != null && Contract.Team == client.Info.Team)
            {
                return(false);
            }
            if (command.ContractType == ContractInfo.EType.Coinche)
            {
                if (Contract == null)
                {
                    return(false);
                }
                if (Contract.Type == ContractInfo.EType.Coinche)
                {
                    Lobby.Broadcast(client.Info.Name + " called recoinche.");
                }
            }
            if (Contract?.Value <= command.ContractValue)
            {
                return(false);
            }

            Contract = new Contract(client.Info.Team, command.ContractType, command.ContractValue);
            Lobby.Broadcast(client.Info.Name + " put a contract " + command.ContractType + " of " +
                            command.ContractValue + ".");
            return(true);
        }