예제 #1
0
        //protected override bool ValidateElement()
        //{
        //    return UserHelper.GetKeyWordSubstitution(UserName);

        //}
        protected override bool CreateUserRole(out IUser user)
        {
            user = null;
            int MaxLength = ConfigEnvSet.GetInt("User.MaxLength");
            int length    = System.Text.Encoding.Default.GetByteCount(UserName);

            if (UserHelper.GetKeyWordSubstitution(UserName))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1005_RegistNameKeyWord;
                return(false);
            }
            if (GameUser.IsNickName(UserName))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1005_Rename;
                return(false);
            }
            if (length <= 0 || length > MaxLength)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = string.Format(LanguageManager.GetLang().St1005_KingNameTooLong, MaxLength);
                return(false);
            }
            Regex re = new Regex(@"^[\u4e00-\u9fa5\w]+$");

            if (!re.IsMatch(UserName))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1005_RegistNameExceptional;
                return(false);
            }
            if (!Pid.ToLower().StartsWith("z"))
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1005_PassportError;
                return(false);
            }
            GeneralInfo general = new ConfigCacheSet <GeneralInfo>().FindKey(generalID);

            if (general == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return(false);
            }
            CareerInfo careerInfo = new ConfigCacheSet <CareerInfo>().FindKey(general.CareerID);

            if (careerInfo == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1005_Professional;
                return(false);
            }

            GameUser userEntity = new GameDataCacheSet <GameUser>().FindKey(Uid);

            if (userEntity != null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1005_RoleExist;
                return(false);
            }
            bool userSex = Sex == 0 ? false : true;

            if (new GameDataCacheSet <GameUser>().FindKey(Uid) == null)
            {
                userEntity = CreateGameUser(userSex);
                user       = new SessionUser(userEntity);
                NoviceHelper.RetailLoginDaysReceive(userEntity); //渠道登录奖励
                CreateGeneral(careerInfo);
                CreateMagic(userEntity);
                //每日限制次数
                CreateDailyRestrain();
                //开启默认功能
                EnableFunction();
                //SendGifItem();
                UserPrayHelper.AddUserPray(Uid.ToInt(), PrayType.SanTianQiDao);
                UserPackHelper.AddUserPack(Uid);
                UserLoginLog userLoginLog = new UserLoginLog();
                userLoginLog.UserId     = Uid;
                userLoginLog.SessionID  = Sid;
                userLoginLog.MobileType = MobileType;
                userLoginLog.ScreenX    = ScreenX;
                userLoginLog.ScreenY    = ScreenY;
                userLoginLog.RetailId   = RetailID;
                userLoginLog.AddTime    = DateTime.Now;
                userLoginLog.State      = LoginStatus.Logined;
                userLoginLog.DeviceID   = DeviceID;
                userLoginLog.Ip         = this.GetRealIP();
                userLoginLog.Pid        = userEntity.Pid;
                userLoginLog.UserLv     = userEntity.UserLv;
                var sender = DataSyncManager.GetDataSender();
                sender.Send(userLoginLog);
                BackPackHelper.AddBack(userEntity);
                UserHelper.OpenMagic(Uid, 1);
                //封测注册发放礼包
                UserItemHelper.AddUserItem(Uid, 1704, 1, ItemStatus.BeiBao);
            }
            else
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1005_RoleExist;
                return(false);
            }
            PlotHelper.EnablePlot(Uid, ConfigEnvSet.GetInt("UserPlot.OpenLockPlotID"));
            return(true);
        }