Exemple #1
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;
     }
     var userCache = new PersonalCacheStruct<GameUser>();
     var roleCache = new PersonalCacheStruct<UserRole>();
     GameUser gameUser;
     if (userCache.TryFindKey(UserId.ToString(), out gameUser) == LoadingStatus.Success)
     {
         if (gameUser == null)
         {
             gameUser = new GameUser
             {
                 UserId = UserId,
                 PassportId = Pid,
                 RetailId = RetailID,
                 NickName = Pid
             };
             userCache.Add(gameUser);
         }
         user =new SessionUser(gameUser);
         UserRole role;
         if (roleCache.TryFind(gameUser.PersonalId, r => r.RoleName == UserName, out role) == LoadingStatus.Success)
         {
             if (role == null)
             {
                 role = new UserRole()
                 {
                     RoleId = (int)roleCache.GetNextNo(),
                     UserId = UserId,
                     RoleName = UserName,
                     HeadImg = HeadID,
                     Sex = Sex.ToBool(),
                     LvNum = 1,
                     ExperienceNum = 0,
                     LifeNum = 100,
                     LifeMaxNum = 100
                 };
                 roleCache.Add(role);
                 gameUser.CurrRoleId = role.RoleId;
             }
             return true;
         }
     }
     return false;
 }
Exemple #2
0
        protected override bool DoSuccess(int userId, out IUser user)
        {
            user = null;
            var cacheSet = new PersonalCacheStruct<GameUser>();
            var roleCache = new PersonalCacheStruct<UserRole>();
            var roleList = roleCache.FindAll(userId.ToString());
            GameUser gameUser = cacheSet.FindKey(userId.ToString());
            if (gameUser == null || roleList.Count == 0)
            {
                //通知客户跳转到创建角色接口
                GuideId = 1005;
                return true;
            }
            user = new SessionUser(gameUser);
            if (gameUser.CurrRoleId == 0)
            {
                gameUser.CurrRoleId = roleList[0].RoleId;
            }

            return true;
        }
Exemple #3
0
        protected override bool CreateUserRole(out IUser user)
        {
            user = null;
            GameUser gameUser = new GameDataCacheSet<GameUser>().FindKey(UserId.ToString());
            if (gameUser == null)
            {
                var roleFunc = new RoleFunc();
                string msg;

                if (roleFunc.VerifyRange(UserName, out msg) ||
                    roleFunc.VerifyKeyword(UserName, out msg) ||
                    roleFunc.IsExistNickName(UserName, out msg))
                {
                    ErrorCode = Language.Instance.ErrorCode;
                    ErrorInfo = msg;
                    return false;
                }
                gameUser = CreateRole();
                roleFunc.OnCreateAfter(gameUser);
            }
            user = new SessionUser(gameUser);
            UserLoginLog userLoginLog = new UserLoginLog();
            userLoginLog.UserId = UserId.ToString();
            userLoginLog.SessionID = Sid;
            userLoginLog.MobileType = (short)MobileType;
            userLoginLog.ScreenX = ScreenX;
            userLoginLog.ScreenY = ScreenY;
            userLoginLog.RetailId = RetailID;
            userLoginLog.AddTime = DateTime.Now;
            userLoginLog.State = (short)LoginStatus.Logined;
            userLoginLog.DeviceID = DeviceID;
            userLoginLog.Ip = GetRealIP();
            userLoginLog.Pid = gameUser.Pid;
            userLoginLog.UserLv = gameUser.UserLv;
            var sender = DataSyncManager.GetDataSender();
            sender.Send(new[] { userLoginLog });

            return true;
        }
Exemple #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 ShareCacheStruct<GeneralInfo>().FindKey(generalID);
            if (general == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return false;
            }
            CareerInfo careerInfo = new ShareCacheStruct<CareerInfo>().FindKey(general.CareerID);
            if (careerInfo == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1005_Professional;
                return false;
            }

            GameUser userEntity = new PersonalCacheStruct<GameUser>().FindKey(UserId.ToString());
            if (userEntity != null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1005_RoleExist;
                return false;
            }
            bool userSex = Sex == 0 ? false : true;

            if (new PersonalCacheStruct<GameUser>().FindKey(UserId.ToString()) == null)
            {
                userEntity = CreateGameUser(userSex);
                user = new SessionUser(userEntity);
                NoviceHelper.RetailLoginDaysReceive(userEntity); //渠道登录奖励
                CreateGeneral(careerInfo);
                CreateMagic(userEntity);
                //每日限制次数
                CreateDailyRestrain();
                //开启默认功能
                EnableFunction();
                //SendGifItem();
                UserPrayHelper.AddUserPray(UserId, PrayType.SanTianQiDao);
                UserPackHelper.AddUserPack(UserId.ToString());
                UserLoginLog userLoginLog = new UserLoginLog();
                userLoginLog.UserId = UserId.ToString();
                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(UserId.ToString(), 1);
                //封测注册发放礼包
                UserItemHelper.AddUserItem(UserId.ToString(), 1704, 1, ItemStatus.BeiBao);
            }
            else
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St1005_RoleExist;
                return false;
            }
            PlotHelper.EnablePlot(UserId.ToString(), ConfigEnvSet.GetInt("UserPlot.OpenLockPlotID"));
            return true;
        }
        protected override bool DoSuccess(int userId, out IUser user)
        {
            user = null;
            //原因:重登录时,数据会回档问题
            var cacheSet = new GameDataCacheSet<GameUser>();
            GameUser userInfo = cacheSet.FindKey(userId.ToString());
            if (userInfo != null)
            {
                //原因:还在加载中时,返回
                if (userInfo.IsRefreshing)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().ServerLoading;
                    return false;
                }
            }
             
            if (userInfo == null ||
                string.IsNullOrEmpty(userInfo.SessionID) ||
                !userInfo.IsOnline)
            {
                UserCacheGlobal.Load(userId.ToString()); //重新刷缓存
                userInfo = cacheSet.FindKey(userId.ToString());
            }
            if (userInfo != null)
            {
                if (userInfo.UserStatus == UserStatus.FengJin)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1004_IDDisable;
                    return false;
                }
                user = new SessionUser(userInfo);
                //todo
                //NoticeHelper.RankNotice(userInfo); //公告
                CombatHelper.LoadProperty(userInfo);
                //todo
                //NoviceHelper.OldFriendPack(Uid, userInfo.LoginTime); //好友礼包
                UserLoginLog userLoginLog = new UserLoginLog();
                userLoginLog.UserId = userInfo.UserID;
                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 = userInfo.Pid;
                userLoginLog.UserLv = userInfo.UserLv;
                //原因:报表统计
                userLoginLog.PlotID = userInfo.PlotProgress;
                PlotInfo plotInfo = new ConfigCacheSet<PlotInfo>().FindKey(userInfo.PlotProgress);
                if (plotInfo != null)
                {
                    userLoginLog.PlotName = plotInfo.PlotName;
                }

                var sender = DataSyncManager.GetDataSender();
                sender.Send(userLoginLog);

                //int vipLv;
                //var vipLvArray = new ConfigCacheSet<VipLvInfo>().FindAll(u => u.PayGold <= userInfo.PayGold);
                //vipLv = vipLvArray.Count > 0 ? vipLvArray[vipLvArray.Count - 1].VipLv : (short)0;

                userInfo.LoginTime = DateTime.Now;
                userInfo.SessionID = Sid;
                userInfo.IsOnline = true;
                //userInfo.VipLv = vipLv;
                userInfo.GameId = GameType;
                userInfo.ServerId = ServerID;
                userInfo.ChatVesion = 0;
                userInfo.ChatDate = DateTime.MinValue;
                userInfo.BroadcastVesion = 0;
                if (userInfo.DailyLoginTime == MathUtils.SqlMinDate ||
                    userInfo.DailyLoginTime.Date != DateTime.Now.Date)
                {
                    userInfo.DailyLoginTime = DateTime.Now;
                }
                //todo
                RankingHelper.DailySportsRankPrize(userInfo);
            }
            else
            {
                user = new SessionUser()
                {
                    UserId = userId,
                    PassportId = PassportId
                };
                ErrorCode = 1005;
                ErrorInfo = LanguageManager.GetLang().St1005_RoleCheck;
            }
            return true;
        }
Exemple #6
0
        protected override bool DoSuccess(int userId, out IUser user)
        {
            user = null;
            var cacheSet = new GameDataCacheSet<GameUser>();
            GameUser gameUser = cacheSet.FindKey(userId.ToString());
            if (gameUser == null ||
                string.IsNullOrEmpty(gameUser.SessionID) ||
                (Current.User != null && !Current.User.IsOnlining))
            {
                gameUser = cacheSet.FindKey(userId.ToString());
            }

            if (gameUser != null)
            {
                //原因:还在加载中时,返回
                if (gameUser.Property.IsRefreshing)
                {
                    ErrorCode = Language.Instance.ErrorCode;
                    ErrorInfo = Language.Instance.ServerLoading;
                    return false;
                }

            }

            var nowTime = DateTime.Now;
            if (gameUser == null)
            {
                user = new SessionUser() { PassportId = PassportId, UserId = userId };
                this.ErrorCode = 1005;
                return true;
            }
            user = new SessionUser(gameUser);
            if (gameUser.UserStatus == UserStatus.FengJin)
            {
                ErrorCode = Language.Instance.TimeoutCode;
                ErrorInfo = Language.Instance.AcountIsLocked;
                return false;
            }
            gameUser.SessionID = Sid;
            gameUser.OnlineDate = nowTime;
            gameUser.LoginDate = nowTime;
            gameUser.Property.GameId = this.GameType;
            gameUser.Property.ServerId = this.ServerID;
            gameUser.Property.ChatVesion = 0;
            //gameUser.OnLine = true;
            //gameUser.Logoff = true;


            System.Threading.Tasks.Task.Factory.StartNew(() =>
            {
                //登录日志
                UserLoginLog userLoginLog = new UserLoginLog();
                userLoginLog.UserId = gameUser.UserId.ToString();
                userLoginLog.SessionID = Sid;
                userLoginLog.MobileType = this.MobileType.ToShort();
                userLoginLog.ScreenX = this.ScreenX;
                userLoginLog.ScreenY = this.ScreenY;
                userLoginLog.RetailId = this.RetailID;
                userLoginLog.AddTime = nowTime;
                userLoginLog.State = LoginStatus.Logined.ToInt();
                userLoginLog.DeviceID = this.DeviceID;
                userLoginLog.Ip = this.GetRealIP();
                userLoginLog.Pid = gameUser.Pid;
                userLoginLog.UserLv = gameUser.UserLv;
                var sender = DataSyncManager.GetDataSender();
                sender.Send(new[] { userLoginLog });
            });
            return true;
        }