コード例 #1
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);
        }
コード例 #2
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);
        }
コード例 #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
        /// <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);
        }
コード例 #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
ファイル: MainClass.cs プロジェクト: JoeChen999/scut
        private static void InitRanking()
        {
            int timeOut = 3000;

            RankingFactory.Add(new SinglePvpRanking());
            RankingFactory.Start(timeOut);
        }
コード例 #7
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;
            }
        }
コード例 #8
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);
        }
コード例 #9
0
ファイル: LobbyServerUtils.cs プロジェクト: JoeChen999/scut
        public static void InitRanking()
        {
            int timeOut = 3000;

            RankingFactory.Add(new SinglePvpRanking());
            RankingFactory.Add(new PlayerMightRanking());
            RankingFactory.Start(timeOut);
        }
コード例 #10
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;
            }
        }
コード例 #11
0
        /// <summary>
        /// 排行榜加载
        /// </summary>
        private static void InitRanking()
        {
            int timeOut = ConfigUtils.GetSetting("Ranking.timeout", "3600").ToInt();

            RankingFactory.Add(new BeansRanking());
            RankingFactory.Add(new WinRanking());

            RankingFactory.Start(timeOut);
        }
コード例 #12
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);
            }
        }
コード例 #13
0
        public IResultSetFilter Instantiate(IRankingInfo rankingInfo, IEnumerable <IColumnDefinitionLight> columns)
        {
            var groupingFactory = new ByColumnGroupingFactory();
            var grouping        = groupingFactory.Instantiate(columns);

            var rankingFactory = new RankingFactory();
            var ranking        = rankingFactory.Instantiate(rankingInfo);

            return(new FilterGroupByFilter(ranking, grouping));
        }
コード例 #14
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);
        }
コード例 #15
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);
        }
コード例 #16
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);
                            }
                        }
                    }
                }
            }
        }
コード例 #17
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();
            }
        }
コード例 #18
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);
        }
コード例 #19
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();
                });
            }
        }
コード例 #20
0
ファイル: SystemGlobal.cs プロジェクト: zxx0367/Scut-samples
        private static void InitRanking()
        {
            int timeOut = ConfigUtils.GetSetting("Ranking.timeout", "3600").ToInt();

            //RankingFactory.Add(new CombatNumRanking());
            //RankingFactory.Add(new GameCoinRanking());
            //RankingFactory.Add(new ObtainRanking());
            RankingFactory.Add(new UserLvRanking());
            RankingFactory.Add(new CombatRanking());
            RankingFactory.Add(new ShengJiTaRanking());
            //圣吉塔排行
            //int intervalTimes = ConfigEnvSet.GetInt("Rank.SJT") / 3600;
            //RankingFactory.Add(new ShengJiTaRanking(intervalTimes));

            RankingFactory.Start(timeOut);
        }
コード例 #21
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);
 }
コード例 #22
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();
     }
 }
コード例 #23
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);
        }
コード例 #24
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);
        }
コード例 #25
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);
        }
コード例 #26
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();
        }
コード例 #27
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);
        }
コード例 #28
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);
        }
コード例 #29
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);
        }
コード例 #30
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);
        }