Ejemplo n.º 1
0
        /// <summary>
        /// 设置排名
        /// </summary>
        /// <param name="managerId"></param>
        /// <param name="integral"></param>
        private void SetRank(Guid managerId, int integral)
        {
            ArenaManagerinfoEntity info = null;

            if (!_RankDic.ContainsKey(managerId))
            {
                info = ArenaManagerinfoMgr.GetById(managerId);
            }
            else
            {
                _RankDic.TryGetValue(managerId, out info);
            }
            if (info == null)
            {
                return;
            }
            if (info.Integral == integral && _RankDic.ContainsKey(managerId))
            {
                return;
            }
            info.Integral   = integral;
            info.UpdateTime = DateTime.Now;
            if (_RankDic.ContainsKey(managerId))
            {
                _RankDic[managerId] = info;
            }
            else
            {
                info.UpdateTime = DateTime.Now;
            }
            _RankDic.TryAdd(managerId, info);
            var list     = _RankDic.Values.OrderByDescending(r => r.Integral).ThenBy(r => r.UpdateTime).ToList();
            var rankDic  = new ConcurrentDictionary <Guid, ArenaManagerinfoEntity>();
            int rank     = 0;
            var rankList = new List <ArenaManagerinfoEntity>();

            foreach (var item in list)
            {
                rank++;
                item.Rank = rank;
                if (item.Rank > 10000)
                {
                    item.Rank = 0;
                }
                if (!rankDic.ContainsKey(item.ManagerId))
                {
                    rankDic.TryAdd(item.ManagerId, item);
                }
                if (item.Rank > 0)
                {
                    rankList.Add(item);
                }
            }
            _RankList = rankList;
            _RankDic  = rankDic;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取我的排名详情
        /// </summary>
        /// <param name="managerId"></param>
        /// <returns></returns>
        public ArenaManagerinfoEntity GetRankInfo(Guid managerId)
        {
            ArenaManagerinfoEntity info = null;

            if (!_RankDic.ContainsKey(managerId))
            {
                info = ArenaManagerinfoMgr.GetById(managerId);
            }
            _RankDic.TryGetValue(managerId, out info);
            if (info == null)
            {
                return(null);
            }
            return(info);
        }
Ejemplo n.º 3
0
        public ArenaManagerinfoEntity GetArenaInfo(Guid managerId, string zoneName = "")
        {
            var info = ArenaManagerinfoMgr.GetById(managerId);

            return(info);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 初始化赛季
        /// </summary>
        /// <returns></returns>
        public MessageCode InitSeason()
        {
            try
            {
                DateTime date = DateTime.Now;
                _season = ArenaSeasonMgr.GetSeason(date.Date);
                if (_season == null)
                {
                    return(MessageCode.NbParameterError);
                }
                _seasonInfo = ArenaSeasoninfoMgr.GetSeasonInfo(_season.SeasonId, _domainId);
                DateTime endTime = _season.EndTime.AddDays(1).AddSeconds(-1);
                this.ArenaType = _season.ArenaType;
                //新赛季
                if (_seasonInfo == null)
                {
                    if (_season.SeasonId == 1)
                    {
                        //第一个赛季
                        _seasonInfo = new ArenaSeasoninfoEntity(0, _season.PrepareTime, _season.StartTime,
                                                                endTime, _season.ArenaType, 0, false, date, new Guid(), "", "", new Guid(), "", "", 0,
                                                                date, date, _domainId, _season.SeasonId);
                    }
                    else
                    {
                        //上一赛季
                        var onSeasonInfo = ArenaSeasoninfoMgr.GetSeasonInfo(_season.SeasonId - 1, _domainId);

                        #region 初始化赛季

                        var messageCode = CalculateSeason(onSeasonInfo);
                        if (messageCode != MessageCode.Success)
                        {
                            return(messageCode);
                        }

                        #endregion

                        //上届冠军
                        var onChampionId       = new Guid();
                        var onChampionName     = "";
                        var onChampionZoneName = "";

                        //王者之师
                        var theKingName           = "";
                        var theKingZoneName       = "";
                        var theKingId             = new Guid();
                        var theKingChampionNumber = 0;
                        //获取上届冠军
                        var onChampion = ArenaManagerrecordMgr.GetChampion(_season.SeasonId - 1, _domainId);
                        if (onChampion != null)
                        {
                            onChampionId       = onChampion.ManagerId;
                            onChampionName     = onChampion.ManagerName;
                            onChampionZoneName = onChampion.ZoneName;
                            //冠军次数+1
                            ArenaManagerinfoMgr.SetChampion(onChampion.ManagerId);
                        }
                        //获取得到冠军次数最多的人
                        var maxChampion = ArenaManagerinfoMgr.GetChampionMax(_domainId);
                        if (maxChampion != null)
                        {
                            if (onSeasonInfo != null)
                            {
                                //上一届跟这一届是同一个人
                                if (onSeasonInfo.TheKingId == maxChampion.ManagerId)
                                {
                                    theKingId       = maxChampion.ManagerId;
                                    theKingName     = maxChampion.ZoneName + "." + maxChampion.ManagerName;
                                    theKingZoneName = maxChampion.ZoneName;
                                }
                                else //不是同一人
                                {
                                    //获取上一届王者之师用户信息
                                    var onTheKingInfo = ArenaManagerinfoMgr.GetById(onSeasonInfo.TheKingId);
                                    //先达到的为主
                                    if (onTheKingInfo != null &&
                                        onTheKingInfo.ChampionNumber >= maxChampion.ChampionNumber)
                                    {
                                        theKingId       = onTheKingInfo.ManagerId;
                                        theKingName     = onTheKingInfo.ZoneName + "." + onTheKingInfo.ManagerName;
                                        theKingZoneName = onTheKingInfo.ZoneName;
                                    }
                                    else
                                    {
                                        theKingId       = maxChampion.ManagerId;
                                        theKingName     = maxChampion.ZoneName + "." + maxChampion.ManagerName;
                                        theKingZoneName = maxChampion.ZoneName;
                                    }
                                }
                            }
                            else
                            {
                                theKingId       = maxChampion.ManagerId;
                                theKingName     = maxChampion.ZoneName + "." + maxChampion.ManagerName;
                                theKingZoneName = maxChampion.ZoneName;
                            }
                            theKingChampionNumber = maxChampion.ChampionNumber;
                        }
                        _seasonInfo = new ArenaSeasoninfoEntity(0, _season.PrepareTime, _season.StartTime,
                                                                endTime, _season.ArenaType, 0, false, date, onChampionId, onChampionName,
                                                                onChampionZoneName, theKingId, theKingName, theKingZoneName, theKingChampionNumber, date,
                                                                date, _domainId, _season.SeasonId);
                        //达到开始条件
                        if (_seasonInfo.StartTime.Date <= date.Date && _seasonInfo.Status == 0)
                        {
                            _seasonInfo.Status = 1;
                            ArenaManagerinfoMgr.ClearRecord(_seasonInfo.ArenaType, _domainId);
                        }
                    }

                    if (!ArenaSeasoninfoMgr.Insert(_seasonInfo))
                    {
                        return(MessageCode.NbUpdateFail);
                    }
                    Refresh();
                }
                else
                {
                    //达到开始条件
                    if (_seasonInfo.StartTime.Date <= date.Date && _seasonInfo.Status == 0)
                    {
                        _seasonInfo.Status = 1;
                        ArenaManagerinfoMgr.ClearRecord(_seasonInfo.ArenaType, _domainId);
                        if (!ArenaSeasoninfoMgr.Update(_seasonInfo))
                        {
                            return(MessageCode.NbUpdateFail);
                        }
                        Refresh();
                    }
                }
            }
            catch (Exception ex)
            {
                SystemlogMgr.Error("竞技场初始化赛季", ex);
                return(MessageCode.NbParameterError);
            }
            return(MessageCode.Success);
        }