Example #1
0
        /// <summary>
        /// 获取阵型,计算阵型等级,和球员位置,技能
        /// </summary>
        /// <param name="arenaTeammemberFrame"></param>
        /// <returns></returns>
        public static NbSolutionEntity GetArenaSolution(ArenaTeammemberFrame arenaTeammemberFrame)
        {
            var cacheKey = arenaTeammemberFrame.ArenaType.ToString() + arenaTeammemberFrame.ManagerId.ToString();
            var entity   = MemcachedFactory.ArenaSolutionClient.Get <NbSolutionEntity>(cacheKey);

            if (entity == null)
            {
                entity = NbSolutionMgr.GetById(arenaTeammemberFrame.ManagerId, arenaTeammemberFrame.ZoneName);
                if (entity == null)
                {
                    return(null);
                }
                entity.FormationId = arenaTeammemberFrame.SolutionId;
                var formationData = new FormationDataListEntity(entity.FormationData);
                entity.FormationLevel = formationData.GetLevel(entity.FormationId);
                var formationDetails = CacheFactory.FormationCache.GetFormationDetail(entity.FormationId);
                var playerIdList     = arenaTeammemberFrame.PlayerList;
                var skillList        = arenaTeammemberFrame.SkillList;

                entity.PlayerDic = new Dictionary <int, SolutionPlayerEntity>(playerIdList.Count);
                for (int i = 0; i < playerIdList.Count; i++)
                {
                    if (playerIdList[i] == 0)
                    {
                        continue;
                    }
                    entity.PlayerDic.Add(playerIdList[i],
                                         MatchDataUtil.BuildSolutionPlayer(playerIdList, formationDetails, playerIdList[i], skillList[i]));
                }
                entity.PlayerString = arenaTeammemberFrame.PlayerString;
                entity.SkillString  = arenaTeammemberFrame.SkillString;
                MemcachedFactory.ArenaSolutionClient.Set(cacheKey, entity);
            }
            return(entity);
        }
Example #2
0
        /// <summary>
        /// 获取阵型列表
        /// </summary>
        /// <param name="managerId"></param>
        /// <returns></returns>
        public FormationListResponse GetFormationList(Guid managerId)
        {
            var solution      = GetSolution(managerId);
            var formationData = new FormationDataListEntity(solution.FormationData);
            var formationList = CacheFactory.FormationCache.GetFormationList();

            var response = ResponseHelper.CreateSuccess <FormationListResponse>();

            response.Data = new FormationList();
            response.Data.CurrentFormationId = solution.FormationId;
            response.Data.Formations         = new List <FormationOutEntity>(formationList.Count);
            var manager = ManagerCore.Instance.GetManager(managerId, true);

            if (manager != null)
            {
                response.Data.Kpi = manager.Kpi;
            }
            foreach (var entity in formationList)
            {
                int level        = formationData.GetLevel(entity.Idx);
                int sophisticate = CacheFactory.FormationCache.GetSophisticate(level);
                var outEntity    = new FormationOutEntity(entity.Idx, level, sophisticate);
                response.Data.Formations.Add(outEntity);
            }
            return(response);
        }
Example #3
0
        /// <summary>
        /// 获取阵型,计算阵型等级,和球员位置,技能
        /// </summary>
        /// <param name="managerId"></param>
        /// <returns></returns>
        public static NbSolutionEntity GetSolution(Guid managerId, string siteId = "")
        {
            bool             memFlag = string.IsNullOrEmpty(siteId);
            NbSolutionEntity entity  = null;

            if (memFlag)
            {
                entity = MemcachedFactory.SolutionClient.Get <NbSolutionEntity>(managerId);
            }
            if (entity == null)
            {
                entity = NbSolutionMgr.GetById(managerId, siteId);
                if (entity == null)
                {
                    return(null);
                }
                var formationData = new FormationDataListEntity(entity.FormationData);
                entity.FormationLevel = formationData.GetLevel(entity.FormationId);
                var formationDetails = CacheFactory.FormationCache.GetFormationDetail(entity.FormationId);
                var playerIdList     = FrameUtil.CastIntList(entity.PlayerString, ',');

                ////获取租借球员str,如果与实际阵容的str不同,就用虚拟的替换当前的,不改变实际阵容的str
                //var virtualPlayerIdList = FrameUtil.CastIntList(entity.HirePlayerString, ',');
                //for (int i = 0; i < playerIdList.Count; i++)
                //{
                //    for (int j = 0; j < virtualPlayerIdList.Count; j++)
                //    {
                //        if (playerIdList[i] != virtualPlayerIdList[j] && virtualPlayerIdList[j] != 0)
                //        {
                //            playerIdList[i] = virtualPlayerIdList[j];
                //        }
                //    }
                //}
                var skillList = new string[11];
                if (!string.IsNullOrEmpty(entity.SkillString))
                {
                    skillList = entity.SkillString.Split(',');
                }
                entity.PlayerDic = new Dictionary <int, SolutionPlayerEntity>(playerIdList.Count);
                for (int i = 0; i < playerIdList.Count; i++)
                {
                    entity.PlayerDic.Add(playerIdList[i], MatchDataUtil.BuildSolutionPlayer(playerIdList, formationDetails, playerIdList[i], skillList[i]));
                }
                if (memFlag)
                {
                    MemcachedFactory.SolutionClient.Set(managerId, entity);
                }
            }
            return(entity);
        }