コード例 #1
0
        private ESpreadState SpreadTelCodeVerify(GameClient client, string telCode)
        {
            lock (client.ClientData.LockSpread)
            {
                //开放
                SpreadData spreadData = GetSpreadInfo(client);
                if (!spreadData.IsOpen)
                {
                    return(ESpreadState.ENoOpen);
                }
                //填写验证码
                SpreadVerifyData verifyData = client.ClientData.MySpreadVerifyData;
                if (verifyData == null || string.IsNullOrEmpty(verifyData.VerifyCode))
                {
                    return(ESpreadState.EVerifyCodeNull);
                }
                //手机号空
                if (string.IsNullOrEmpty(verifyData.Tel))
                {
                    return(ESpreadState.ETelNull);
                }
                //手机超时
                if (DateTime.Now > verifyData.TelTime.AddSeconds(TEL_CODE_VERIFY_SECOND))
                {
                    return(ESpreadState.ETelCodeOutTime);
                }
                //手机code错误
                if (!IsTelCode(telCode))
                {
                    return(ESpreadState.ETelCodeWrong);
                }
                //if (verifyData.TelCode<=0 || telCode != verifyData.TelCode) return ESpreadState.ETelCodeWrong;

                int          code   = int.Parse(telCode);
                ESpreadState result = HTelCodeVerify(client, code);
                if (result != ESpreadState.Success)
                {
                    return(result);
                }

                int isVip   = client.ClientData.VipLevel >= _vipLimit ? 1 : 0;
                int isLevel = client.ClientData.ChangeLifeCount * 100 + client.ClientData.Level >= _levelLimit ? 1 : 0;
                if (isVip > 0)
                {
                    Global.UpdateRoleParamByName(client, RoleParamName.SpreadIsVip, "1", true);
                }
                if (isLevel > 0)
                {
                    Global.UpdateRoleParamByName(client, RoleParamName.SpreadIsLevel, "1", true);
                }

                spreadData.VerifyCode = verifyData.VerifyCode;
                client.ClientData.MySpreadVerifyData = null;

                Global.UpdateRoleParamByName(client, RoleParamName.VerifyCode, verifyData.VerifyCode, true);

                return(ESpreadState.Success);
            }
        }
コード例 #2
0
        private ESpreadState SpreadTelCodeGet(GameClient client, string tel)
        {
            lock (client.ClientData.LockSpread)
            {
                //开放
                SpreadData spreadData = GetSpreadInfo(client);
                if (!spreadData.IsOpen)
                {
                    return(ESpreadState.ENoOpen);
                }
                //填写验证码
                SpreadVerifyData verifyData = client.ClientData.MySpreadVerifyData;
                if (verifyData == null || string.IsNullOrEmpty(verifyData.VerifyCode))
                {
                    return(ESpreadState.EVerifyCodeNull);
                }
                //手机号空
                if (string.IsNullOrEmpty(tel))
                {
                    return(ESpreadState.ETelNull);
                }
                //手机号错误
                if (!IsTel(tel))
                {
                    return(ESpreadState.ETelWrong);
                }

                //手机超时&& verifyData.Tel.Equals(tel)
                if (!string.IsNullOrEmpty(verifyData.Tel) &&
                    DateTime.Now < verifyData.TelTime.AddSeconds(TEL_CODE_VERIFY_SECOND))
                {
                    return(ESpreadState.Success);
                }

                //验证手机并发送验证码
                ESpreadState result = HTelCodeGet(client, tel);
                if (result != ESpreadState.Success)
                {
                    return(result);
                }
                //获取失败
                if (string.IsNullOrEmpty(tel))
                {
                    return(ESpreadState.ETelCodeGet);
                }

                verifyData.Tel     = tel;
                verifyData.TelTime = DateTime.Now;

                return(ESpreadState.Success);
            }
        }
コード例 #3
0
        private ESpreadState SpreadVerifyCode(GameClient client, string verifyCode)
        {
            lock (client.ClientData.LockSpread)
            {
                //空
                if (string.IsNullOrEmpty(verifyCode))
                {
                    return(ESpreadState.EVerifyCodeNull);
                }
                //开放
                SpreadData data = GetSpreadInfo(client);
                if (!data.IsOpen)
                {
                    return(ESpreadState.ENoOpen);
                }
                //已验证推荐
                if (!string.IsNullOrEmpty(data.VerifyCode))
                {
                    return(ESpreadState.EVerifyCodeHave);
                }
                //超出推荐时间
                DateTime regTime = Global.GetRegTime(client.ClientData);
                if (regTime < _createDate)
                {
                    return(ESpreadState.EVerifyOutTime);
                }
                //推荐码错误
                string[] codes = verifyCode.Split('#');
                if (codes.Length < 2)
                {
                    return(ESpreadState.EVerifyCodeWrong);
                }

                int pzoneID = StringUtil.SpreadCodeToID(codes[0]);
                int proleID = StringUtil.SpreadCodeToID(codes[1]);
                //自己
                if (pzoneID == client.ClientData.ZoneID && proleID == client.ClientData.RoleID)
                {
                    return(ESpreadState.EVerifySelf);
                }

                ESpreadState checkState = HCheckVerifyCode(client, pzoneID, proleID);
                if (checkState == ESpreadState.EVerifyCodeHave)
                {
                    GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client,
                                                             StringUtil.substitute(Global.GetLang("同一账号下只能有1个角色被推广")), GameInfoTypeIndexes.Error, ShowGameInfoTypes.ErrAndBox, (int)HintErrCodeTypes.None);

                    return(ESpreadState.EVerifyCodeHave);
                }
                else if (checkState != ESpreadState.Success)
                {
                    return(checkState);
                }

                SpreadVerifyData verifyData = new SpreadVerifyData();
                verifyData.VerifyCode = verifyCode;

                client.ClientData.MySpreadVerifyData = verifyData;

                return(ESpreadState.Success);
            }
        }