Ejemplo n.º 1
0
        public override bool TakeAction()
        {
            try
            {
                int maxLength = ConfigEnvSet.GetInt("User.MaxLength");

                if (_nickName.Trim().Length == 0 || Encoding.Default.GetByteCount(_nickName) > maxLength)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = string.Format(LanguageManager.GetLang().St1005_KingNameTooLong, maxLength);
                    return(false);
                }

                if (GameUser.IsNickName(_nickName))
                {
                    ErrorCode = 1;
                    ErrorInfo = LanguageManager.GetLang().St1005_Rename;
                    return(false);
                }
                return(true);
            }
            catch (Exception ex)
            {
                SaveLog(ex);
                return(false);
            }
        }
Ejemplo n.º 2
0
        public override bool TakeAction()
        {
            try
            {
                MaxLength = ConfigEnvSet.GetInt("User.MaxLength");
                itemID    = ConfigEnvSet.GetInt("UserName.ItemID");
                int length = System.Text.Encoding.Default.GetByteCount(_nickName);
                if (length <= 0 || length > MaxLength)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = string.Format(LanguageManager.GetLang().St1005_KingNameTooLong, MaxLength);
                    return(false);
                }
                if (GameUser.IsNickName(_nickName))
                {
                    ErrorCode = 1;
                    ErrorInfo = LanguageManager.GetLang().St1005_Rename;
                    return(false);
                }
                //UserItemLog userItem = UserItemLog.FindKey(itemID);
                var          package  = UserItemPackage.Get(Uid);
                UserItemInfo userItem = package.ItemPackage.Find(m => !m.IsRemove && m.ItemID == itemID);
                if (userItem == null || userItem.Num <= 0)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    return(false);
                }
                ContextUser.NickName = _nickName;

                int                rankID = 0;
                UserRank           rankInfo;
                Ranking <UserRank> ranking = RankingFactory.Get <UserRank>(CombatRanking.RankingKey);
                if (ranking.TryGetRankNo(m => m.UserID == ContextUser.UserID, out rankID))
                {
                    rankInfo = ranking.Find(s => s.UserID == ContextUser.UserID);
                    if (rankInfo != null)
                    {
                        rankInfo.NickName = _nickName;
                    }
                }
                //ContextUser.Update();
                //UserGeneral usergen = UserGeneral.GetMainGeneral(ContextUser.UserID);
                //if (usergen != null)
                //{
                //    usergen.GeneralName = _nickName;
                //    //usergen.Update();
                //}
                UserItemHelper.UseUserItem(ContextUser.UserID, itemID, 1);

                return(true);
            }
            catch (Exception ex)
            {
                SaveLog(ex);
                return(false);
            }
        }
Ejemplo n.º 3
0
        protected override bool CreateUserRole(out IUser user)
        {
            user = null;
            if (UserName.Length < 2 || UserName.Length > 12)//如果名字过长或过短
            {
                ErrorCode = Language.Instance.ErrorCode;
                ErrorInfo = Language.Instance.St1005_UserNameNotEnough;
                return(false);
            }

            if (GameUser.IsNickName(UserName))
            {
                ErrorCode = Language.Instance.ErrorCode;
                ErrorInfo = Language.Instance.St1005_UserNameNotEnough;
                return(false);
            }

            var      userCache = new PersonalCacheStruct <GameUser>();
            GameUser gameUser;

            if (userCache.TryFindKey(UserId.ToString(), out gameUser) == LoadingStatus.Success)
            {
                if (gameUser == null)
                {
                    gameUser = new GameUser
                    {
                        UserId     = UserId,
                        PassportId = Pid,
                        NickName   = UserName,
                        Sex        = Sex,
                    };
                }
                gameUser.Exp       = 0;
                gameUser.Lv        = 1;
                gameUser.LoginTime = DateTime.Now;
                gameUser.Action    = 100;
                gameUser.Gold      = 5000;
                gameUser.Ingot     = 100;
                userCache.Add(gameUser);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 4
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);
        }