コード例 #1
0
        /// <summary>
        /// 业务逻辑处理
        /// </summary>
        /// <returns>false:中断后面的方式执行并返回Error</returns>
        public override bool TakeAction()
        {
            receipt = new JPRequestRankData();


            UserRank rankInfo = UserHelper.FindRankUser(Current.UserId, RankType.FightValue);

            if (rankInfo != null)
            {
                receipt.SelfRank = rankInfo.RankId;
            }

            int pagecout;
            var ranking = RankingFactory.Get <UserRank>(FightValueRanking.RankingKey);
            var list    = ranking.GetRange(0, 50, out pagecout);

            foreach (var data in list)
            {
                JPRankUserData jpdata = new JPRankUserData()
                {
                    UserID     = data.UserID,
                    NickName   = data.NickName,
                    Profession = data.Profession,
                    AvatarUrl  = data.AvatarUrl,
                    RankId     = data.RankId,
                    UserLv     = data.UserLv,
                    FightValue = data.FightValue,
                    VipLv      = data.VipLv
                };
                receipt.List.Add(jpdata);
            }
            return(true);
        }
コード例 #2
0
        protected override void TakeRemote()
        {
            var rank    = RankingFactory.Get <SinglePvpRankUser>("SinglePvpRanking");
            var players = rank.GetRange(0, 100);

            foreach (var player in players)
            {
                m_ResponsePacket.PlayerInfo.Add(new PBPlayerInfo()
                {
                    Id   = player.UserId,
                    Name = player.Name,
                });
                m_ResponsePacket.ServerId.Add(player.ServerId);
                m_ResponsePacket.Score.Add(player.Score);
            }
            var me = rank.Find(t => t.ServerId == m_RequestPacket.ServerId && t.UserId == m_RequestPacket.UserId);

            if (me == null)
            {
                m_ResponsePacket.MyRank  = -1;
                m_ResponsePacket.MyScore = 0;
            }
            else
            {
                m_ResponsePacket.MyRank  = me.RankId;
                m_ResponsePacket.MyScore = me.Score;
            }
        }
コード例 #3
0
ファイル: Action1303.cs プロジェクト: JoeChen999/scut
        public override bool TakeAction()
        {
            var         rank    = RankingFactory.Get <SinglePvpRankUser>("SinglePvpRanking");
            var         players = rank.GetRange(0, 100);
            PlayerLogic p       = new PlayerLogic();

            foreach (var player in players)
            {
                p.SetUser(player.UserId);
                m_ResponsePacket.PlayerInfo.Add(new PBPlayerInfo()
                {
                    Id           = player.UserId,
                    Name         = p.MyPlayer.Name,
                    Level        = p.MyPlayer.Level,
                    Might        = p.MyPlayer.Might,
                    PortraitType = p.MyPlayer.PortraitType,
                });
                m_ResponsePacket.Score.Add(player.Score);
            }
            var Me = rank.Find(r => r.UserId == m_UserId);

            if (Me == null)
            {
                m_ResponsePacket.MyRank  = -1;
                m_ResponsePacket.MyScore = 0;
            }
            else
            {
                m_ResponsePacket.MyRank  = Me.RankId;
                m_ResponsePacket.MyScore = Me.Score;
            }
            return(true);
        }
コード例 #4
0
        public override bool TakeAction()
        {
            receipt = new List <JPRankUserData>();
            var ranking = RankingFactory.Get <UserRank>(CombatRanking.RankingKey);


            int pagecout;
            var list = ranking.GetRange(0, 50, out pagecout);

            foreach (var data in list)
            {
                JPRankUserData jpdata = new JPRankUserData()
                {
                    UserID     = data.UserID,
                    NickName   = data.NickName,
                    Profession = data.Profession,
                    AvatarUrl  = data.AvatarUrl,
                    RankId     = data.RankId,
                    UserLv     = data.UserLv,
                    FightValue = data.FightValue,
                    VipLv      = data.VipLv
                };

                receipt.Add(jpdata);
            }
            return(true);
        }
コード例 #5
0
        public override bool TakeAction()
        {
            receipt = new LevelRankingTop50Data();

            Ranking <UserRank> ranking  = RankingFactory.Get <UserRank>(LevelRanking.RankingKey);
            UserRank           rankInfo = null;
            int rankID = 0;

            if (ranking.TryGetRankNo(m => (m.UserID == Current.UserId), out rankID))
            {
                rankInfo = ranking.Find(s => (s.UserID == Current.UserId));
            }

            if (rankInfo != null)
            {
                receipt.SelfRank = rankInfo.RankId;
            }

            int pagecout;
            var list = ranking.GetRange(0, 50, out pagecout);

            foreach (var data in list)
            {
                UserRank rank = new UserRank(data);
                receipt.List.Add(rank);
            }
            return(true);
        }
コード例 #6
0
ファイル: Action1019.cs プロジェクト: dongliang/Scut
        public override bool TakeAction()
        {
            Ranking <UserRank> rankList;

            if (rankType == RankType.UserLv)
            {
                rankList = RankingFactory.Get <UserRank>(UserLvRanking.RankingKey);
            }
            else if (rankType == RankType.Obtion)
            {
                rankList = RankingFactory.Get <UserRank>(ObtainRanking.RankingKey);
            }
            else if (rankType == RankType.GameCoin)
            {
                rankList = RankingFactory.Get <UserRank>(GameCoinRanking.RankingKey);
            }
            else if (rankType == RankType.ZhanLi)
            {
                rankList = RankingFactory.Get <UserRank>(CombatNumRanking.RankingKey);
            }
            else
            {
                throw new ArgumentNullException("rankType", string.Format("rankType:{0}", rankType));
            }
            userRankArray = rankList.GetRange(pageIndex, pageSize, out pageCount);
            if (rankList.TryGetRankNo(m => m.UserID == ContextUser.UserID, out currRankID))
            {
            }
            return(true);
        }
コード例 #7
0
        public static Ranking <UserRank> GetRankType(RankType rankType)
        {
            Ranking <UserRank> rankList;

            if (rankType == RankType.UserLv)
            {
                rankList = RankingFactory.Get <UserRank>(UserLvRanking.RankingKey);
            }
            else if (rankType == RankType.Obtion)
            {
                rankList = RankingFactory.Get <UserRank>(ObtainRanking.RankingKey);
            }
            else if (rankType == RankType.GameCoin)
            {
                rankList = RankingFactory.Get <UserRank>(GameCoinRanking.RankingKey);
            }
            else if (rankType == RankType.ZhanLi)
            {
                rankList = RankingFactory.Get <UserRank>(CombatNumRanking.RankingKey);
            }
            else
            {
                throw new ArgumentNullException("rankType", string.Format("rankType:{0}", rankType));
            }
            return(rankList);
        }
コード例 #8
0
        public static void LoadServerRanking()
        {
            try
            {
                var          ranking      = RankingFactory.Get <UserRank>(LevelRanking.RankingKey);
                LevelRanking levelranking = ranking as LevelRanking;
                levelranking.rankingData.RankTime = DateTime.Now;
                levelranking.rankingData.RankList.Clear();


                foreach (var v in ServerSet.Set)
                {
                    string   url   = v.ServerUrl;
                    string[] split = url.Split(':');
                    url = "http://" + split[0] + ":8091/GlobalCommon.aspx?";
                    url = url + HttpUtility.UrlEncode("ID=LevelRankingData");

                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                    request.Timeout = 5000;
                    request.Method  = "GET";
                    WebResponse     webresponse  = request.GetResponse();
                    HttpWebResponse httpResponse = (HttpWebResponse)webresponse;
                    Stream          stream       = httpResponse.GetResponseStream(); //获取响应的字符串流  
                    StreamReader    sr           = new StreamReader(stream);         //创建一个stream读取流  
                    string          data         = sr.ReadToEnd();                   //从头读到尾,放到字符串html  

                    if (data != null && data.Length > 0)
                    {
                        byte[]           bytes = Convert.FromBase64String(data);
                        MessageStructure ms    = new MessageStructure(bytes);

                        int listsize = ms.ReadInt();
                        for (int i = 0; i < listsize; ++i)
                        {
                            UserRank rank = new UserRank();
                            rank.UserID     = ms.ReadInt();
                            rank.NickName   = ms.ReadString();
                            rank.Profession = ms.ReadInt();
                            rank.RankId     = ms.ReadInt();
                            rank.UserLv     = ms.ReadInt();
                            rank.AvatarUrl  = ms.ReadString();
                            rank.FightValue = ms.ReadInt();
                            rank.VipLv      = ms.ReadInt();
                            levelranking.rankingData.RankList.Add(rank);
                        }
                    }
                }


                Ranking <UserRank> levelRanking = RankingFactory.Get <UserRank>(LevelRanking.RankingKey);
                levelRanking.ForceRefresh();
            }
            catch (Exception ex)
            {
                new BaseLog().SaveLog(ex);
                return;
            }
        }
コード例 #9
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);
            }
        }
コード例 #10
0
        public override bool TakeAction()
        {
            Ranking <UserRank> ranking = RankingFactory.Get <UserRank>(CombatRanking.RankingKey);

            int count     = 20;
            int pagecount = 0;

            userRankArray = ranking.GetRange(1, count, out pagecount);
            return(true);
        }
コード例 #11
0
ファイル: PlayerChessLogic.cs プロジェクト: JoeChen999/scut
        private Dictionary <ChessFieldColor, int[]> GetEnemies()
        {
            var        mightRank     = RankingFactory.Get <MightRankUser>("PlayerMightRanking");
            int        myRank        = mightRank.GetRankNo(p => p.UserId == m_UserId);
            var        Candidates    = mightRank.GetRange(myRank - 31, myRank + 31);
            List <int> redPlayers    = new List <int>();
            List <int> yellowPlayers = new List <int>();
            List <int> greenPlayers  = new List <int>();

            foreach (var user in Candidates)
            {
                if (user.UserId == m_UserId)
                {
                    continue;
                }
                if (user.RankId < myRank - 11)
                {
                    redPlayers.Add(user.UserId);
                }
                else if (user.RankId > myRank + 11)
                {
                    greenPlayers.Add(user.UserId);
                }
                else
                {
                    yellowPlayers.Add(user.UserId);
                }
            }
            if (redPlayers.Count < GameConsts.PlayerChess.RedFieldCount)
            {
                int NeedCount = GameConsts.PlayerChess.RedFieldCount - redPlayers.Count;
                for (int i = 0; i < NeedCount; i++)
                {
                    redPlayers.Add(yellowPlayers[0]);
                    yellowPlayers.RemoveAt(0);
                }
            }
            if (greenPlayers.Count < GameConsts.PlayerChess.GreenFieldCount)
            {
                int NeedCount = GameConsts.PlayerChess.GreenFieldCount - greenPlayers.Count;
                for (int i = 0; i < NeedCount; i++)
                {
                    greenPlayers.Add(yellowPlayers[yellowPlayers.Count - 1]);
                    yellowPlayers.RemoveAt(yellowPlayers.Count - 1);
                }
            }
            Dictionary <ChessFieldColor, int[]> retDict = new Dictionary <ChessFieldColor, int[]>();

            retDict[ChessFieldColor.Red]    = GameUtils.RandomChoose(redPlayers, GameConsts.PlayerChess.RedFieldCount);
            retDict[ChessFieldColor.Yellow] = GameUtils.RandomChoose(yellowPlayers, GameConsts.PlayerChess.YellowFieldCount);
            retDict[ChessFieldColor.Green]  = GameUtils.RandomChoose(greenPlayers, GameConsts.PlayerChess.GreenFieldCount);
            return(retDict);
        }
コード例 #12
0
        public static void UserShengJiTaRank()
        {
            Ranking <UserRank> rankList = RankingFactory.Get <UserRank>(ShengJiTaRanking.RankingKey);

            if (rankList != null)
            {
                if (DateTime.Now.Hour == 0)
                {
                    foreach (UserRank userRank in rankList)
                    {
                        GameUser usergame = new PersonalCacheStruct <GameUser>().FindKey(userRank.UserID);
                        if (usergame != null && userRank.ScoreStar > 0)
                        {
                            // 信件通知玩家 “您在XX-XX的“勇闯圣吉塔”活动中名列XX榜第N,排名奖励M金币已经发送到您的账号中,请及时查收!”
                            TjxMailService mailService = new TjxMailService(usergame);
                            var            mail        = new UserMail(Guid.NewGuid());
                            mail.UserId       = userRank.UserID.ToInt();
                            mail.MailType     = (int)MailType.System;
                            mail.ToUserID     = userRank.UserID.ToInt();
                            mail.FromUserName = LanguageManager.GetLang().St_SystemMailTitle;
                            mail.Title        = LanguageManager.GetLang().St_SystemMailTitle;
                            mail.SendDate     = DateTime.Now;

                            IGameLanguage    gameLanguage = LanguageManager.GetLang();
                            SJTRankRewarInfo SJTRankRewar = new ShareCacheStruct <SJTRankRewarInfo>().FindKey(userRank.SJTRankId, userRank.SJTRankType.ToInt());
                            if (SJTRankRewar != null)
                            {
                                if (usergame.UserLv >= 10 && usergame.UserLv < 30)
                                {
                                    usergame.GameCoin = usergame.GameCoin + SJTRankRewar.GiftGold;
                                    mail.Content      = String.Format(gameLanguage.St_ShengJiTaTip, DateTime.Now.ToString("MM-dd"), gameLanguage.St_ShengJiTaQintTong, userRank.SJTRankId, SJTRankRewar.GiftGold);
                                }
                                if (usergame.UserLv >= 30 && usergame.UserLv < 54)
                                {
                                    usergame.GameCoin = usergame.GameCoin + SJTRankRewar.GiftGold;
                                    mail.Content      = String.Format(gameLanguage.St_ShengJiTaTip, DateTime.Now.ToString("MM-dd"), gameLanguage.St_ShengJiTaBaiYin, userRank.SJTRankId, SJTRankRewar.GiftGold);
                                }
                                if (usergame.UserLv >= 55)
                                {
                                    usergame.GameCoin = usergame.GameCoin + SJTRankRewar.GiftGold;
                                    mail.Content      = String.Format(gameLanguage.St_ShengJiTaTip, DateTime.Now.ToString("MM-dd"), gameLanguage.St_ShengJiTaHuangJin, userRank.SJTRankId, SJTRankRewar.GiftGold);
                                }

                                mailService.Send(mail);
                            }
                        }
                    }
                }
            }
        }
コード例 #13
0
        protected override IRanking GetRankingObject(int rankType)
        {
            switch (rankType)
            {
            case 1:
                return(RankingFactory.Get <UserRank>(UserLvRanking.RankingKey));

            case 2:
                return(RankingFactory.Get <UserRank>(CombatRanking.RankingKey));

            default:
                throw new NotImplementedException();
            }
        }
コード例 #14
0
        /// <summary>
        /// 业务逻辑处理
        /// </summary>
        /// <returns>false:中断后面的方式执行并返回Error</returns>
        public override bool TakeAction()
        {
            receipt = new List <GuildRank>();


            int pagecout;
            var ranking = RankingFactory.Get <GuildRank>(GuildRanking.RankingKey);
            var list    = ranking.GetRange(0, 30, out pagecout);

            foreach (var data in list)
            {
                receipt.Add(data);
            }
            return(true);
        }
コード例 #15
0
ファイル: RWPvpResultHandler.cs プロジェクト: JoeChen999/scut
        protected override void TakeRemote()
        {
            PvpPlayer player1 = null;
            PvpPlayer player2 = null;

            if (m_RequestPacket.PlayerIds.Count < 2)
            {
                return;
            }
            for (int i = 0; i < m_RequestPacket.PlayerIds.Count; i++)
            {
                PvpPlayer p = CacheSet.PvpPlayerCache.FindKey(m_RequestPacket.PlayerIds[i], m_RequestPacket.ServerId[i]);
                if (p == null)
                {
                    return;
                }
                if (i == 0)
                {
                    player1 = p;
                }
                else if (i == 1)
                {
                    player2 = p;
                }
            }
            int         p1score = PVPLogic.GetDeltaScore(player1.Score, player2.Score, m_RequestPacket.Result[0]);
            int         p2score = PVPLogic.GetDeltaScore(player2.Score, player1.Score, m_RequestPacket.Result[1]);
            WLPvpResult package = new WLPvpResult();

            for (int i = 0; i < m_RequestPacket.PlayerIds.Count; i++)
            {
                package.PlayerId = m_RequestPacket.PlayerIds[i];
                package.Result   = m_RequestPacket.Result[i];
                package.Score    = i == 0 ? p1score : p2score;
                LobbyServerSender.Send(m_RequestPacket.ServerId[i], "WLPvpResultHandler", package, delegate(RemotePackage callback) {
                    LWPvpResult res = RemoteCommunication.ParseRemotePackage <LWPvpResult>(callback.Message as byte[]);
                    if (res.PlayerId == player1.Id)
                    {
                        player1.Score = res.Score;
                    }
                    else if (res.PlayerId == player2.Id)
                    {
                        player2.Score = res.Score;
                    }
                    RankingFactory.Get <SinglePvpRankUser>("SinglePvpRanking").Refresh();
                });
            }
        }
コード例 #16
0
ファイル: RankingHelper.cs プロジェクト: dongliang/Scut
 /// <summary>
 /// 竞技场奖励是否可领取
 /// </summary>
 /// <param name="userID"></param>
 /// <returns></returns>
 public static bool IsGainSportsReward(string userID)
 {
     if (UserHelper.IsOpenFunction(userID, FunctionEnum.Jingjichang))
     {
         int rankID = 0;
         Ranking <UserRank> ranking = RankingFactory.Get <UserRank>(CombatRanking.RankingKey);
         if (ranking.TryGetRankNo(m => m.UserID == userID, out rankID))
         {
             SportSRewardGain(userID, rankID);
             SportsRewardInfo sportsInfo = new ConfigCacheSet <SportsRewardInfo>().FindKey(rankID);
             if (sportsInfo != null)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
コード例 #17
0
 public void SetUser(int userId)
 {
     m_UserId = userId;
     m_Pvp    = CacheSet.PlayerSinglePvpCache.FindKey(userId);
     if (m_Pvp == null)
     {
         m_Pvp = new PlayerSinglePvp()
         {
             UserId        = userId,
             DeductedScore = 0,
         };
         ResetPvpInfo();
         CacheSet.PlayerSinglePvpCache.Add(m_Pvp);
         RankingFactory.Get <SinglePvpRankUser>("SinglePvpRanking").Refresh();
     }
     if (m_Pvp.LastResetTime - DateTime.UtcNow.Ticks > TimeSpan.TicksPerDay || new DateTime(m_Pvp.LastResetTime).Day != DateTime.UtcNow.Day)
     {
         ResetChallengeCount();
     }
 }
コード例 #18
0
        private static void InitRanking()
        {
            int timeOut = ConfigUtils.GetSetting("Ranking.timeout", "60").ToInt();

            RankingFactory.Add(new CombatRanking());
            RankingFactory.Add(new LevelRanking());
            RankingFactory.Add(new FightValueRanking());
            RankingFactory.Add(new ComboRanking());
            RankingFactory.Add(new GuildRanking());
            RankingFactory.Start(timeOut);

            // 设置通天塔排行不刷新
            Ranking <UserRank> combatRanking = RankingFactory.Get <UserRank>(CombatRanking.RankingKey);

            combatRanking.SetIntervalTimes(int.MaxValue);

            // 设置公会排行不刷新
            Ranking <GuildRank> guildRanking = RankingFactory.Get <GuildRank>(GuildRanking.RankingKey);

            guildRanking.SetIntervalTimes(int.MaxValue);
        }
コード例 #19
0
        public override bool TakeAction()
        {
            PlayerSinglePvpLogic psp = new PlayerSinglePvpLogic();

            psp.SetUser(m_UserId);
            var rank = RankingFactory.Get <SinglePvpRankUser>("SinglePvpRanking").Find(u => u.UserId == m_UserId);

            if (rank == null)
            {
                m_ResponsePacket.Score = 0;
                m_ResponsePacket.Rank  = -1;
            }
            else
            {
                m_ResponsePacket.Score = rank.Score;
                m_ResponsePacket.Rank  = rank.RankId;
            }
            m_ResponsePacket.ChallengeCount = psp.MyPvp.RemainingCount;
            m_ResponsePacket.Season         = PVPLogic.GetSeasonId();
            return(true);
        }
コード例 #20
0
        private MessageStructure verifyDeliver(Dictionary <string, string> parms)
        {
            MessageStructure ms = new MessageStructure();

            try
            {
                while (true)
                {
                    parms.TryGetValue("ID", out _OperateName);

                    if (_OperateName == "LevelRankingData")
                    {
                        int pagecout;
                        var ranking = RankingFactory.Get <UserRank>(LevelRanking.RankingKey);
                        var list    = ranking.GetRange(0, 50, out pagecout);

                        ms.WriteByte(list.Count);
                        foreach (var data in list)
                        {
                            ms.WriteByte(data.UserID);
                            ms.WriteByte(data.NickName);
                            ms.WriteByte(data.Profession);
                            ms.WriteByte(data.RankId);
                            ms.WriteByte(data.UserLv);
                            ms.WriteByte(data.FightValue);
                            ms.WriteByte(data.VipLv);
                        }
                    }
                    break;
                }
            }
            catch (Exception e)
            {
                TraceLog.WriteError(string.Format("{0} {1}", "Url参数格式错误", e));
            }
            return(ms);
        }
コード例 #21
0
        protected override void OnStartAffer()
        {
            TimeListener.Append(PlanConfig.EveryMinutePlan(MsgDispatcher.Dispatcher, "Dispatcher", "00:00", "23:59", 1));

            TimeListener.Append(PlanConfig.EveryMinutePlan(DoEveryDayRefreshDataTask, "EveryDayRefreshDataTask", "00:00", "23:59", 600));
            //TimeListener.Append(PlanConfig.EveryDayPlan(DoEveryDayRefreshDataTask, "EveryDayRefreshDataTask", "03:10"));

            ServerSet.LoadServerConfig();

            RankingFactory.Add(new LevelRanking());
            //RankingFactory.Add(new GuildRanking());
            RankingFactory.Start(60);

            // 设置竞技场排行不刷新
            Ranking <UserRank> levelRanking = RankingFactory.Get <UserRank>(LevelRanking.RankingKey);

            levelRanking.SetIntervalTimes(int.MaxValue);

            //// 设置公会排行不刷新
            //Ranking<GuildRank> guildRanking = RankingFactory.Get<GuildRank>(GuildRanking.RankingKey);
            //guildRanking.SetIntervalTimes(int.MaxValue);

            LevelRankingAllServerSet.LoadServerRanking();
        }
コード例 #22
0
        public override bool TakeAction()
        {
            UserRank rankInfo = null;
            var      ranking  = RankingFactory.Get <UserRank>(CombatRanking.RankingKey);

            rankInfo = UserHelper.FindRankUser(Current.UserId, RankType.Combat);

            if (rankInfo == null)
            {
                rankInfo = new UserRank()
                {
                    UserID   = Current.UserId,
                    NickName = GetBasis.NickName,
                    UserLv   = GetBasis.UserLv,
                    VipLv    = GetBasis.VipLv,
                    RankId   = int.MaxValue,
                    RankDate = DateTime.Now,
                };
                ranking.TryAppend(rankInfo);
                rankInfo = ranking.Find(s => (s.UserID == Current.UserId));
            }

            receipt                = new CombatMatchData();
            receipt.RankId         = GetBasis.CombatRankID;
            receipt.CombatTimes    = GetCombat.CombatTimes;
            receipt.LastFailedDate = Util.ConvertDateTimeStamp(GetCombat.LastFailedDate);
            //UserRank info = null;
            CacheList <int> MachList = new CacheList <int>();

            if (rankInfo.RankId <= MaxCount)
            {
                for (int i = MaxCount; i > 0; --i)
                {
                    MachList.Add(i);
                }
            }
            else if (rankInfo.RankId <= 30)
            {// 前30名去前5位
                int num = 0;
                for (int i = rankInfo.RankId - 1; i > 0 && num < MaxCount; --i)
                {
                    MachList.Add(i);
                    num++;
                }
            }
            else if (rankInfo.RankId <= 100)
            {// 前100名去前10位
                if (rankInfo.RankId <= 30 + MaxCount)
                {
                    for (int i = rankInfo.RankId - 1; i > 30; --i)
                    {
                        MachList.Add(i);
                    }
                    int currcount = MachList.Count;
                    for (int i = 30; i > 30 - (MaxCount - currcount); --i)
                    {
                        MachList.Add(i);
                    }
                }
                else
                {
                    int num = 0;
                    for (int i = rankInfo.RankId - 1; i > 30 && num < 10; --i)
                    {
                        MachList.Add(i);
                        num++;
                    }
                }
            }
            else if (rankInfo.RankId <= 500)
            {// 前500名去前30位
                if (rankInfo.RankId <= 100 + MaxCount)
                {
                    for (int i = rankInfo.RankId - 1; i > 100; --i)
                    {
                        MachList.Add(i);
                    }
                    CacheList <int> temp = new CacheList <int>();
                    for (int i = 100; i > 90; --i)
                    {
                        temp.Add(i);
                    }
                    int mach;
                    int currcount = MachList.Count;
                    for (int i = 0; i < MaxCount - currcount; ++i)
                    {
                        RandMach(ref temp, out mach);
                        MachList.Add(mach);
                    }
                }
                else
                {
                    int num = 0;
                    for (int i = rankInfo.RankId - 1; i > 100 && num < 30; --i)
                    {
                        MachList.Add(i);
                        num++;
                    }
                }
            }
            else if (rankInfo.RankId <= 1000)
            {
                if (rankInfo.RankId <= 500 + MaxCount)
                {
                    for (int i = rankInfo.RankId - 1; i > 500; --i)
                    {
                        MachList.Add(i);
                    }
                    CacheList <int> temp = new CacheList <int>();
                    for (int i = 500; i > 470; --i)
                    {
                        temp.Add(i);
                    }
                    int mach;
                    int currcount = MachList.Count;
                    for (int i = 0; i < MaxCount - currcount; ++i)
                    {
                        RandMach(ref temp, out mach);
                        MachList.Add(mach);
                    }
                }
                else
                {
                    int num = 0;
                    for (int i = rankInfo.RankId - 1; i > 500 && num < 100; --i)
                    {
                        MachList.Add(i);
                        num++;
                    }
                }
            }
            else
            {
                if (rankInfo.RankId <= 1000 + MaxCount)
                {
                    for (int i = rankInfo.RankId - 1; i > 1000; --i)
                    {
                        MachList.Add(i);
                    }
                    CacheList <int> temp = new CacheList <int>();
                    for (int i = 1000; i > 900; --i)
                    {
                        temp.Add(i);
                    }
                    int mach;
                    int currcount = MachList.Count;
                    for (int i = 0; i < MaxCount - currcount; ++i)
                    {
                        RandMach(ref temp, out mach);
                        MachList.Add(mach);
                    }
                }
                else
                {
                    int num = 0;
                    for (int i = rankInfo.RankId - 1; i > 1000 && num < 200; --i)
                    {
                        MachList.Add(i);
                        num++;
                    }
                }
            }
            int mach_tops;

            for (int i = 0; MachList.Count > 0 && i < MaxCount; ++i)
            {
                RandMach(ref MachList, out mach_tops);

                int      rankID   = 0;
                UserRank machinfo = null;
                if (ranking.TryGetRankNo(m => (m.RankId == mach_tops), out rankID))
                {
                    machinfo = ranking.Find(s => (s.RankId == mach_tops));
                }

                if (machinfo != null)
                {
                    UserAttributeCache  attribute = UserHelper.FindUserAttribute(machinfo.UserID);
                    UserEquipsCache     equips    = UserHelper.FindUserEquips(machinfo.UserID);
                    CombatMatchUserData data      = new CombatMatchUserData()
                    {
                        UserId        = machinfo.UserID,
                        NickName      = machinfo.NickName,
                        Profession    = machinfo.Profession,
                        AvatarUrl     = machinfo.AvatarUrl,
                        RankId        = machinfo.RankId,
                        UserLv        = machinfo.UserLv,
                        VipLv         = machinfo.VipLv,
                        FightingValue = attribute.FightValue,
                        Equips        = equips,
                        // SkillCarryList = user.SkillCarryList
                    };

                    receipt.RivalList.Add(data);
                }
            }


            // 日志
            //foreach (CombatLogData data in GetCombat.LogList)
            //{
            //    UserRank info = null;
            //    if (ranking.TryGetRankNo(m => (m.UserID == data.UserId), out rankID))
            //    {
            //        info = ranking.Find(s => (s.UserID == data.UserId));
            //    }

            //    JPCombatLogData cld = new JPCombatLogData();
            //    cld.UserId = data.UserId;
            //    if (info != null)
            //        cld.RivalCurrRankId = info.RankId;
            //    cld.Type = data.Type;
            //    cld.FightResult = data.Status;
            //    cld.Log = UserHelper.FormatCombatLog(data);
            //    receipt.LogList.Add(cld);
            //}

            return(true);
        }
コード例 #23
0
        /// <summary>
        /// 玩家荣誉值升级
        /// </summary>
        /// <param name="user"></param>
        /// <param name="honourNum"></param>
        public static void AddUserLv(GameUser user, int honourNum)
        {
            short generalMaxLv = GameConfigSet.CurrMaxLv.ToShort();

            if (user.UserLv >= generalMaxLv)
            {
                CheckFun(user);
                return;
            }
            short rankLv = user.UserLv;

            user.HonourNum = MathUtils.Addition(user.HonourNum, honourNum);
            short nextLv = MathUtils.Addition(user.UserLv, 1.ToShort());

            while (nextLv <= generalMaxLv)
            {
                GeneralEscalateInfo generalEscalate = new ConfigCacheSet <GeneralEscalateInfo>().FindKey(nextLv, GeneralType.YongHu);
                if (generalEscalate != null && user.HonourNum >= generalEscalate.UpExperience)
                {
                    user.UserLv = nextLv;
                    user.IsLv   = true;
                    UserHelper.OpenMagic(user.UserID, user.UserLv);
                    user.HonourNum = MathUtils.Subtraction(user.HonourNum, generalEscalate.UpExperience);

                    if (generalEscalate.FunctionEnum != null && generalEscalate.FunctionEnum != "")
                    {
                        var feArray = generalEscalate.FunctionEnum.Split(',');
                        foreach (var fun in feArray)
                        {
                            var userFun = _cacheSetUserFun.FindKey(user.UserID, fun);
                            if (userFun == null)
                            {
                                userFun            = new UserFunction();
                                userFun.UserID     = user.UserID;
                                userFun.FunEnum    = fun.ToEnum <FunctionEnum>();
                                userFun.CreateDate = DateTime.Now;
                                _cacheSetUserFun.Add(userFun, GameEnvironment.CacheUserPeriod);
                                _cacheSetUserFun.Update();
                                user.OpenFun.Add(userFun);
                            }
                        }
                    }
                    FestivalHelper.GetUpgradeGiveGift(user.UserID, nextLv);
                    nextLv = MathUtils.Addition(user.UserLv, 1.ToShort());
                }
                else
                {
                    break;
                }
            }
            if (user.UserLv > rankLv)
            {
                Ranking <UserRank> ranking = RankingFactory.Get <UserRank>(CombatRanking.RankingKey);
                UserRank           rankInfo;
                int rankID;
                if (ranking.TryGetRankNo(m => m.UserID == user.UserID, out rankID))
                {
                    rankInfo = ranking.Find(s => s.UserID == user.UserID);
                    if (rankInfo != null)
                    {
                        rankInfo.UserLv         = user.UserLv;
                        rankInfo.TotalCombatNum = user.CombatNum;
                        rankInfo.ObtainNum      = user.ObtainNum;
                    }
                }
            }
            CheckFun(user);
        }
コード例 #24
0
ファイル: RankingProxy.cs プロジェクト: dongliang/Scut
 /// <summary>
 ///
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="key"></param>
 /// <returns></returns>
 public virtual Ranking <T> Get <T>(string key) where T : RankingItem
 {
     return(RankingFactory.Get <T>(key));
 }
コード例 #25
0
        public static void LoadServerRanking()
        {
            try
            {
                new BaseLog().SaveLog("全服排名开始...");
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();

                var          ranking      = RankingFactory.Get <UserRank>(LevelRanking.RankingKey);
                LevelRanking levelranking = ranking as LevelRanking;
                levelranking.rankingData.RankTime = DateTime.Now;
                levelranking.rankingData.RankList.Clear();


                int count = 0;
                for (int i = 0; i < ServerSet.Set.Count; ++i)
                {
                    if (ServerSet.Set[i].ServerUrl.Contains("168.254") ||
                        ServerSet.Set[i].ServerUrl.Contains("192.168"))
                    {
                        continue;
                    }
                    string serverName = ServerSet.Set[i].ServerName;
                    string connectKey = "ServerDB_" + (count++ + 1).ToString();
                    var    dbProvider = DbConnectionProvider.CreateDbProvider(connectKey);
                    string sql        = "SELECT UserID,NickName,ServerID,Profession,UserLv,AvatarUrl,VipLv,LevelRankID FROM UserBasisCache";
                    using (IDataReader reader = dbProvider.ExecuteReader(CommandType.Text, sql))
                    {
                        while (reader.Read())
                        {
                            UserRank rankInfo = new UserRank();
                            rankInfo.UserID     = reader["UserID"].ToInt();
                            rankInfo.NickName   = reader["NickName"].ToString();
                            rankInfo.Profession = reader["Profession"].ToInt();
                            rankInfo.UserLv     = Convert.ToInt16(reader["UserLv"]);
                            rankInfo.VipLv      = reader["VipLv"].ToInt();
                            rankInfo.AvatarUrl  = reader["AvatarUrl"].ToString();
                            rankInfo.RankId     = reader["LevelRankID"].ToInt();
                            rankInfo.ServerID   = reader["ServerID"].ToInt();
                            rankInfo.ServerName = serverName;
                            levelranking.rankingData.RankList.Add(rankInfo);
                        }
                    }

                    sql = "SELECT UserID, FightValue FROM UserAttributeCache";
                    using (IDataReader reader = dbProvider.ExecuteReader(CommandType.Text, sql))
                    {
                        while (reader.Read())
                        {
                            int userId = reader["UserID"].ToInt();
                            var rank   = levelranking.rankingData.RankList.Find(t => t.UserID == userId);
                            if (rank != null)
                            {
                                rank.FightValue = reader["FightValue"].ToInt();
                            }
                        }
                    }
                }


                Ranking <UserRank> levelRanking = RankingFactory.Get <UserRank>(LevelRanking.RankingKey);
                levelRanking.ForceRefresh();

                stopwatch.Stop();
                new BaseLog().SaveLog("全服排名消耗时间:" + stopwatch.Elapsed.TotalMilliseconds + "ms");
            }
            catch (Exception ex)
            {
                new BaseLog().SaveLog(ex);
                return;
            }
        }
コード例 #26
0
        public override bool TakeAction()
        {
            var ranking = RankingFactory.Get <UserRank>(CombatRanking.RankingKey);

            UserRank rankinfo      = null;
            UserRank rivalrankinfo = null;

            rankinfo      = UserHelper.FindRankUser(Current.UserId, RankType.Combat);
            rivalrankinfo = UserHelper.FindRankUser(rivaluid, RankType.Combat);

            if (rankinfo == null || rivalrankinfo == null)
            {
                int erroruid = rankinfo == null ? Current.UserId : rivaluid;
                new BaseLog("Action1402").SaveLog(string.Format("Not found user combat rank. UserId={0}", erroruid));
                ErrorInfo = Language.Instance.CombatRankDataException;
                return(true);
            }

            receipt        = new CombatRivalData();
            receipt.Result = CombatReqRivalResult.OK;
            //if (rankinfo.RankId <= rivalrankinfo.RankId)
            //{
            //    receipt.Result = CombatReqRivalResult.RankOverdue;
            //    return true;
            //}
            if (rivalrankinfo.IsFighting)
            {
                receipt.Result = CombatReqRivalResult.RivalIsFinging;
                return(true);
            }
            if (rankinfo.IsFighting)
            {
                receipt.Result = CombatReqRivalResult.SelfIsFinging;
                return(true);
            }
            if (GetCombat.CombatTimes <= 0)
            {
                receipt.Result = CombatReqRivalResult.NoTimes;
                return(true);
            }

            UserBasisCache rival = UserHelper.FindUserBasis(rivaluid);

            if (rival == null)
            {
                ErrorInfo = Language.Instance.NoFoundUser;
                return(true);
            }


            GetBasis.UserStatus      = UserStatus.Fighting;
            GetCombat.CombatTimes    = MathUtils.Subtraction(GetCombat.CombatTimes, 1, 0);
            rankinfo.IsFighting      = true;
            rankinfo.FightDestUid    = rivaluid;
            rivalrankinfo.IsFighting = true;
            /////rivalrankinfo.FightDestUid = Current.UserId;

            receipt.UserId     = rivaluid;
            receipt.NickName   = rivalrankinfo.NickName;
            receipt.Profession = rivalrankinfo.Profession;
            receipt.AvatarUrl  = rivalrankinfo.AvatarUrl;
            receipt.RankId     = rivalrankinfo.RankId;
            receipt.UserLv     = rivalrankinfo.UserLv;
            receipt.Equips     = UserHelper.FindUserEquips(rivaluid);
            receipt.Attribute  = UserHelper.FindUserAttribute(rivaluid);
            receipt.Skill      = UserHelper.FindUserSkill(rivaluid);
            receipt.ElfID      = UserHelper.FindUserElf(rivaluid).SelectID;
            var pay = UserHelper.FindUserPay(rivaluid);

            receipt.IsAutoFight = pay.MonthCardDays >= 0 || pay.QuarterCardDays >= 0;
            return(true);
        }
コード例 #27
0
        public override bool TakeAction()
        {
            UserRank rankinfo      = null;
            UserRank rivalrankinfo = null;


            rankinfo = UserHelper.FindRankUser(Current.UserId, RankType.Combat);
            if (rankinfo == null)
            {
                new BaseLog("Action1403").SaveLog(string.Format("Not found user combat rank. UserId={0}", Current.UserId));
                ErrorInfo = Language.Instance.CombatRankDataException;
                return(true);
            }
            UserBasisCache rival = UserHelper.FindUserBasis(rankinfo.FightDestUid);

            if (rival == null)
            {
                ErrorInfo = Language.Instance.CombatRankDataException;
                return(true);
            }

            rivalrankinfo = UserHelper.FindRankUser(rankinfo.FightDestUid, RankType.Combat);
            if (rivalrankinfo == null)
            {
                new BaseLog("Action1403").SaveLog(string.Format("Not found user combat rank. UserId={0}", rankinfo.FightDestUid));
                ErrorInfo = Language.Instance.CombatRankDataException;
                return(true);
            }

            //if (GetBasis.CombatRankID <= rival.CombatRankID)
            //{
            //    ErrorInfo = Language.Instance.CombatRankDataException;
            //    return true;
            //}
            if (!rankinfo.IsFighting || !rivalrankinfo.IsFighting)
            {
                ErrorInfo = Language.Instance.CombatRankDataException;
                return(true);
            }



            int fromRankId = GetBasis.CombatRankID;
            int toRankId   = rival.CombatRankID;

            //TraceLog.WriteLine(string.Format("#BEGIN srcId:[{0}] destId:[{1}]", fromid, toid));
            GetBasis.UserStatus = UserStatus.MainUi;



            if (result == EventStatus.Good)
            {
                if (GetBasis.CombatRankID > rival.CombatRankID)
                {
                    var ranking = RankingFactory.Get <UserRank>(CombatRanking.RankingKey);
                    ranking.TryMove(fromRankId, toRankId);
                    GetBasis.CombatRankID = toRankId;
                    rival.CombatRankID    = fromRankId;
                    if (GetBasis.CombatRankID <= 10)
                    {
                        string context = string.Format("恭喜 {0} 挑战 {1} 成功,成为通天塔第{2}名!", GetBasis.NickName, rival.NickName, rankinfo.RankId);
                        //GlobalRemoteService.SendNotice(NoticeMode.World, context);
                        //PushMessageHelper.SendNoticeToOnlineUser(NoticeMode.Game, context);

                        //var chatService = new TryXChatService();
                        //chatService.SystemSend(context);
                        //PushMessageHelper.SendSystemChatToOnlineUser();
                    }
                }
            }
            else
            {
                if (GetBasis.CombatRankID <= rival.CombatRankID)
                {
                    var ranking = RankingFactory.Get <UserRank>(CombatRanking.RankingKey);
                    ranking.TryMove(fromRankId, toRankId);
                    GetBasis.CombatRankID = toRankId;
                    rival.CombatRankID    = fromRankId;
                }
                GetCombat.LastFailedDate = DateTime.Now;
            }

            int rankrise = result == EventStatus.Good ? MathUtils.Subtraction(fromRankId, toRankId, 0) : 0;

            //TraceLog.WriteLine(string.Format("###END srcId:[{0}] destId:[{1}]", GetBasis.CombatData.RankID, rival.CombatData.RankID));

            // 日志
            CombatLogData log = new CombatLogData();

            log.RivalUid       = rankinfo.FightDestUid;
            log.RivalName      = rival.NickName;
            log.RivalAvatarUrl = rival.AvatarUrl;
            log.LogTime        = DateTime.Now;
            log.Type           = EventType.Challenge;
            log.Status         = result;
            log.RankIdDiff     = rankrise;
            log.RankId         = GetBasis.CombatRankID;
            GetCombat.PushCombatLog(log);

            string content = UserHelper.FormatCombatLog(log);

            GlobalRemoteService.SendSystemChat(Current.UserId, content);


            CombatLogData rivallog = new CombatLogData();

            rivallog.RivalUid       = Current.UserId;
            rivallog.RivalName      = GetBasis.NickName;
            rivallog.RivalAvatarUrl = GetBasis.AvatarUrl;
            rivallog.LogTime        = DateTime.Now;
            rivallog.Type           = EventType.PassiveChallenge;
            rivallog.Status         = result;
            rivallog.RankIdDiff     = rankrise;
            rivallog.RankId         = rival.CombatRankID;
            UserHelper.FindUserCombat(rival.UserID).PushCombatLog(rivallog);

            content = UserHelper.FormatCombatLog(rivallog);
            GlobalRemoteService.SendSystemChat(rival.UserID, content);

            rankinfo.IsFighting      = false;
            rankinfo.FightDestUid    = 0;
            rivalrankinfo.IsFighting = false;

            receipt                = new CombatFightEndData();
            receipt.Result         = result;
            receipt.CurrRankId     = GetBasis.CombatRankID;
            receipt.RankRise       = rankrise;
            receipt.LastFailedTime = Util.ConvertDateTimeStamp(GetCombat.LastFailedDate);
            receipt.AwardGold      = "0";

            BigInteger gold       = ConfigEnvSet.GetInt("User.CombatWinAwardGold");
            BigInteger awardValue = Math.Ceiling(GetBasis.UserLv / 50.0).ToInt() * gold;

            if (result == EventStatus.Good)
            {
                receipt.AwardGold = awardValue.ToString();
                UserHelper.RewardsGold(Current.UserId, awardValue, UpdateCoinOperate.NormalReward, true);
            }
            else
            {
                awardValue       /= 4;
                receipt.AwardGold = awardValue.ToString();
                UserHelper.RewardsGold(Current.UserId, awardValue, UpdateCoinOperate.NormalReward, true);
            }


            // 每日
            UserHelper.EveryDayTaskProcess(Current.UserId, TaskType.Combat, 1);

            // 成就
            UserHelper.AchievementProcess(Current.UserId, AchievementType.CombatRandID, "1");

            PushMessageHelper.NewCombatLogNotification(Current);
            PushMessageHelper.NewCombatLogNotification(GameSession.Get(rival.UserID));
            return(true);
        }
コード例 #28
0
        public static UserBasisCache CreateRole(int _UserId, string _Sid, int _ServerID, string _Pid, string _RetailID,
                                                string _UserName, int _profession, string _HeadID)
        {
            // Basis初始化
            UserBasisCache basis = new UserBasisCache(_UserId);

            basis.IsRefreshing   = true;
            basis.SessionID      = _Sid;
            basis.ServerID       = _ServerID;
            basis.Pid            = _Pid;
            basis.RetailID       = _RetailID;
            basis.NickName       = _UserName;
            basis.UserLv         = (short)ConfigEnvSet.GetInt("User.Level");
            basis.RewardsDiamond = ConfigEnvSet.GetInt("User.InitDiamond");
            //bisis.Vit = DataHelper.InitVit;
            basis.VipLv           = ConfigEnvSet.GetInt("User.VipLv");
            basis.Profession      = _profession;
            basis.AvatarUrl       = _HeadID;
            basis.UserStatus      = UserStatus.MainUi;
            basis.LoginDate       = DateTime.Now;
            basis.CreateDate      = DateTime.Now;
            basis.OfflineDate     = DateTime.Now;
            basis.Gold            = ConfigEnvSet.GetString("User.InitGold");
            basis.OfflineEarnings = "0";

            var cacheSet = new PersonalCacheStruct <UserBasisCache>();

            cacheSet.Add(basis);
            cacheSet.Update();

            // 属性初始化
            UserAttributeCache attcache = new UserAttributeCache();

            attcache.UserID = basis.UserID;
            var attributeSet = new PersonalCacheStruct <UserAttributeCache>();

            attributeSet.Add(attcache);
            attributeSet.Update();

            // 装备初始化
            UserEquipsCache equipcache = new UserEquipsCache();

            equipcache.UserID = basis.UserID;
            equipcache.ResetCache();
            var equipsSet = new PersonalCacheStruct <UserEquipsCache>();

            equipsSet.Add(equipcache);
            equipsSet.Update();

            // 背包初始化
            UserPackageCache packagecache = new UserPackageCache();

            packagecache.UserID = basis.UserID;
            packagecache.ResetCache();
            var packageSet = new PersonalCacheStruct <UserPackageCache>();


            packagecache.AddItem(20001, 1);
            packagecache.AddItem(20012, 1);
            packagecache.AddItem(20023, 1);
            packagecache.AddItem(20034, 1);
            packagecache.AddItem(20045, 1);
            packagecache.AddItem(20056, 1);
            packagecache.AddItem(20067, 1);
            //for (int i = 20001; i < 20077; ++i)
            //    packagecache.AddItem(i, 10);
            //for (int i = 30001; i < 30005; ++i)
            //    packagecache.AddItem(i, 9999);
            //for (int i = 40001; i < 40009; ++i)
            //    packagecache.AddItem(i, 1);

            packageSet.Add(packagecache);
            packageSet.Update();

            // 战魂初始化
            UserSoulCache soulcache = new UserSoulCache();

            soulcache.UserID = basis.UserID;
            soulcache.ResetCache();
            var soulSet = new PersonalCacheStruct <UserSoulCache>();

            soulSet.Add(soulcache);
            soulSet.Update();



            // 技能初始化
            UserSkillCache skillcache = new UserSkillCache();

            skillcache.UserID = basis.UserID;
            skillcache.ResetCache(_profession);
            var skillSet = new PersonalCacheStruct <UserSkillCache>();

            skillSet.Add(skillcache);
            skillSet.Update();

            // 好友初始化
            UserFriendsCache friendscache = new UserFriendsCache();

            friendscache.UserID = basis.UserID;
            friendscache.ResetCache();
            var friendsSet = new PersonalCacheStruct <UserFriendsCache>();

            friendsSet.Add(friendscache);
            friendsSet.Update();

            // 成就初始化
            UserAchievementCache achievecache = new UserAchievementCache();

            achievecache.UserID = basis.UserID;
            achievecache.ResetCache();
            var achieveSet = new PersonalCacheStruct <UserAchievementCache>();

            achieveSet.Add(achievecache);
            achieveSet.Update();

            // 充值初始化
            UserPayCache paycache = new UserPayCache();

            paycache.UserID = basis.UserID;
            paycache.ResetCache();
            var paySet = new PersonalCacheStruct <UserPayCache>();

            paySet.Add(paycache);
            paySet.Update();

            // 邮箱初始化
            UserMailBoxCache mailcache = new UserMailBoxCache();

            mailcache.UserID = basis.UserID;
            mailcache.ResetCache();
            var      mailSet = new PersonalCacheStruct <UserMailBoxCache>();
            MailData mail    = new MailData()
            {
                ID      = Guid.NewGuid().ToString(),
                Title   = "恭喜您已获得月卡免费体验资格",
                Sender  = "系统",
                Date    = DateTime.Now,
                Context = "恭喜您已获得月卡免费体验资格,月卡有效期为1天,为了您能获得更好的游戏体验,您可以在充值页面续费成为我们正式的月卡用户!",
            };

            UserHelper.AddNewMail(basis.UserID, mail, false);
            mailSet.Add(mailcache);
            mailSet.Update();

            // 任务初始化
            UserTaskCache taskcache = new UserTaskCache();

            taskcache.UserID = basis.UserID;
            taskcache.ResetCache();
            var taskSet = new PersonalCacheStruct <UserTaskCache>();

            taskSet.Add(taskcache);
            taskSet.Update();


            // 竞技场初始化
            UserCombatCache combatcache = new UserCombatCache();

            combatcache.UserID = basis.UserID;
            combatcache.ResetCache();
            var combatSet = new PersonalCacheStruct <UserCombatCache>();

            combatSet.Add(combatcache);
            combatSet.Update();

            // 活动相关初始化
            UserEventAwardCache eventawardcache = new UserEventAwardCache();

            eventawardcache.UserID = basis.UserID;
            eventawardcache.ResetCache();
            var eventAwardSet = new PersonalCacheStruct <UserEventAwardCache>();

            eventAwardSet.Add(eventawardcache);
            eventAwardSet.Update();

            // 公会初始化
            UserGuildCache guildcache = new UserGuildCache();

            guildcache.UserID = basis.UserID;
            guildcache.ResetCache();
            var guildSet = new PersonalCacheStruct <UserGuildCache>();

            guildSet.Add(guildcache);
            guildSet.Update();

            // 精灵初始化
            UserElfCache elfcache = new UserElfCache();

            elfcache.UserID = basis.UserID;
            elfcache.ResetCache();
            var elfSet = new PersonalCacheStruct <UserElfCache>();

            elfSet.Add(elfcache);
            elfSet.Update();

            // 赠送物品初始化
            UserTransferItemCache transfercache = new UserTransferItemCache();

            transfercache.UserID = basis.UserID;
            transfercache.ResetCache();
            var transferSet = new PersonalCacheStruct <UserTransferItemCache>();

            transferSet.Add(transfercache);
            transferSet.Update();

            // 仇人数据初始化
            UserEnemysCache enemy = new UserEnemysCache();

            enemy.UserID = basis.UserID;
            enemy.ResetCache();
            var enemySet = new PersonalCacheStruct <UserEnemysCache>();

            enemySet.Add(enemy);
            enemySet.Update();

            // 抽奖数据初始化
            UserLotteryCache lottery = new UserLotteryCache();

            lottery.UserID = basis.UserID;
            lottery.ResetCache();
            var lotterySet = new PersonalCacheStruct <UserLotteryCache>();

            lotterySet.Add(lottery);
            lotterySet.Update();

            UserHelper.RefreshUserFightValue(basis.UserID, false);

            // 排行榜初始化
            UserRank combatRank = new UserRank()
            {
                UserID     = basis.UserID,
                NickName   = basis.NickName,
                Profession = basis.Profession,
                UserLv     = basis.UserLv,
                AvatarUrl  = basis.AvatarUrl,
                VipLv      = basis.VipLv,
                FightValue = attcache.FightValue,
                RankId     = int.MaxValue,
                RankDate   = DateTime.Now,
            };
            Ranking <UserRank> combatranking = RankingFactory.Get <UserRank>(CombatRanking.RankingKey);
            var combat = combatranking as CombatRanking;

            combat.TryAppend(combatRank);
            combat.rankList.Add(combatRank);

            UserRank           levelRank    = new UserRank(combatRank);
            Ranking <UserRank> levelranking = RankingFactory.Get <UserRank>(LevelRanking.RankingKey);
            var level = levelranking as LevelRanking;

            level.TryAppend(levelRank);
            level.rankList.Add(levelRank);

            UserRank           fightRank    = new UserRank(combatRank);
            Ranking <UserRank> fightranking = RankingFactory.Get <UserRank>(FightValueRanking.RankingKey);
            var fight = fightranking as FightValueRanking;

            fight.TryAppend(fightRank);
            fight.rankList.Add(fightRank);

            UserRank           comboRank    = new UserRank(combatRank);
            Ranking <UserRank> comboranking = RankingFactory.Get <UserRank>(ComboRanking.RankingKey);
            var combo = comboranking as ComboRanking;

            combo.TryAppend(comboRank);
            combo.rankList.Add(comboRank);


            UserHelper.RestoreUserData(basis.UserID);
            UserHelper.EveryDayTaskProcess(basis.UserID, TaskType.Login, 1, false);
            //UserHelper.AddMouthCardMail(basis.UserID);


            return(basis);
        }
コード例 #29
0
        public override bool TakeAction()
        {
            receipt        = new MatchRivalData();
            receipt.Result = MatchRivalResult.OK;

            if (GetCombat.MatchTimes <= 0)
            {
                receipt.Result = MatchRivalResult.NoTimes;
                return(true);
            }

            int minv, maxv;

            //minv = Math.Max(GetBasis.UserLv - 25, 0);
            //maxv = GetBasis.UserLv + 25;

            //var onlinelist = UserHelper.GetOnlinesList();
            List <int> matchlist = new List <int>();
            //foreach (var v in onlinelist)
            //{
            //    if (v.UserId == Current.UserId)
            //        continue;
            //    var basis = UserHelper.FindUserBasis(v.UserId);
            //    if (basis != null && basis.UserLv >= minv && basis.UserLv <= maxv)
            //        matchlist.Add(v.UserId);
            //}

            var ranking = RankingFactory.Get <UserRank>(LevelRanking.RankingKey);

            int temp  = 25;
            int count = 0;

            while (matchlist.Count == 0)
            {
                count++;
                minv = Math.Max(GetBasis.UserLv - temp * count, 0);
                maxv = GetBasis.UserLv + temp * count;
                var findlist = ranking.FindAll(s => (s.UserLv > minv && s.UserLv <= maxv));
                foreach (var rank in findlist)
                {
                    if (rank.UserID != Current.UserId)
                    {
                        matchlist.Add(rank.UserID);
                    }
                }
            }

            if (matchlist.Count == 0)
            {
                receipt.Result = MatchRivalResult.NoMatchRival;
                return(true);
            }

            int            randv    = random.Next(matchlist.Count);
            int            rivalUid = matchlist[randv];
            UserBasisCache rival    = UserHelper.FindUserBasis(rivalUid);

            GetCombat.MatchTimes = MathUtils.Subtraction(GetCombat.MatchTimes, 1, 0);

            receipt.UserId       = rivalUid;
            receipt.NickName     = rival.NickName;
            receipt.Profession   = rival.Profession;
            receipt.AvatarUrl    = rival.AvatarUrl;
            receipt.CombatRankID = rival.CombatRankID;
            receipt.LevelRankID  = rival.LevelRankID;
            receipt.UserLv       = rival.UserLv;
            receipt.Equips       = UserHelper.FindUserEquips(rivalUid);
            receipt.Attribute    = UserHelper.FindUserAttribute(rivalUid);
            receipt.Skill        = UserHelper.FindUserSkill(rivalUid);
            receipt.ElfID        = UserHelper.FindUserElf(rivalUid).SelectID;
            var pay = UserHelper.FindUserPay(rivalUid);

            receipt.IsAutoFight = pay.MonthCardDays >= 0 || pay.QuarterCardDays >= 0;
            return(true);
        }
コード例 #30
0
        public override bool TakeAction()
        {
            int         exp         = 0;
            short       currMaxLv   = ConfigEnvSet.GetInt("User.CurrMaxLv").ToShort(); //玩家最大等级
            UserGeneral userGeneral = UserGeneral.GetMainGeneral(ContextUser.UserID);
            int         genLv       = 0;

            if (ContextUser.UserLv > currMaxLv)
            {
                genLv = currMaxLv.ToInt();
            }
            else
            {
                genLv = ContextUser.UserLv;
            }
            GeneralPracticeInfo generalpractice = new ShareCacheStruct <GeneralPracticeInfo>().FindKey(genLv);
            var      ranking  = RankingFactory.Get <UserRank>(CombatNumRanking.RankingKey);
            UserRank rankInfo = ranking.Find(m => m.UserID == ContextUser.UserID);

            if (rankInfo != null && rankInfo.TotalCombatNum > 0)
            {
                fightingNum = rankInfo.TotalCombatNum;
            }
            else
            {
                //fightingNum = UserHelper.GetGameUserCombat(ContextUser.UserID);
            }

            int totalTime = 0;

            if (generalpractice == null)
            {
                return(false);
            }
            totalTime = (generalpractice.MaxHour * 60 * 60);
            List <UserQueue> userQueueArray = new PersonalCacheStruct <UserQueue>().FindAll(ContextUser.UserID, m => m.QueueType == QueueType.XiuLian);

            if (userQueueArray.Count > 0 && !userQueueArray[0].IsSuspend)
            {
                UserQueue queueInfo = userQueueArray[0];
                TimeSpan  ts        = DateTime.Now - queueInfo.Timing;
                //practiceTime = (int)ts.TotalSeconds;
                int preExpTime = 0;
                practiceTime = queueInfo.DoRefresh();
                if (practiceTime > 0)
                {
                    if (userQueueArray[0].Timing <= DateTime.Now)
                    {
                        preExpTime = ((int)((DateTime.Now - userQueueArray[0].Timing).TotalSeconds) /
                                      generalpractice.IntervalTime);
                        experience = generalpractice.Exprience * preExpTime;
                        if (experience > 0)
                        {
                            exp = generalpractice.Exprience;
                        }
                    }
                }
                currExperience      = MathUtils.Addition(userGeneral.CurrExperience, exp, int.MaxValue);
                queueInfo.StrengNum = MathUtils.Addition(queueInfo.StrengNum, exp, int.MaxValue);
                //queueInfo.Update();

                userGeneral.CurrExperience = currExperience;
                //userGeneral.Update();
            }
            return(true);
        }