Ejemplo n.º 1
0
        public void Start(int totalCount, CreateDelegate createDelegate, FinishDelegate finishDelegate)
        {
            List <DicPlayerEntity> list = DicPlayerMgr.GetAllForCache();

            for (int i = 0; i < totalCount; i++)
            {
                try
                {
                    CreateTemplate(list);
                    Dispatcher.Invoke((Action) delegate { createDelegate(true); });
                }
                catch (Exception ex)
                {
                    LogHelper.Insert(ex);
                    Dispatcher.Invoke((Action) delegate { createDelegate(false); });
                }
            }
            Dispatcher.Invoke((Action) delegate { finishDelegate(); });
        }
Ejemplo n.º 2
0
        void BuildCache()
        {
            if (_init)
            {
                return;
            }

            _connection    = ConfigurationManager.ConnectionStrings["Games.NBall.Dal.Properties.Settings.NB_ConfigConnectionString"].ConnectionString;
            _formationList = CacheFactory.FormationCache.GetFormationList();
            _playerList    = DicPlayerMgr.GetAllForCache();
            _equipmentList = DicEquipmentMgr.GetAllForCache();
            var suitList = DicEquipmentsuitMgr.GetAllForCache();
            // _skillList = DicSkillcardMgr.GetAll();

            var willList = DicManagerwillMgr.GetAll();

            _willPlayerDic   = new Dictionary <string, List <int> >();
            _willStrengthDic = new Dictionary <string, int>();
            foreach (var entity in willList)
            {
                if (entity.DriveFlag == (int)EnumSkillDriveType.Active)
                {
                    var ss = entity.PartMap.TrimEnd(',').Split(',');
                    _willStrengthDic.Add(entity.SkillCode, 0);
                    _willPlayerDic.Add(entity.SkillCode, new List <int>());
                    foreach (var s in ss)
                    {
                        var pp    = s.Split('+');
                        var pid   = Convert.ToInt32(pp[0]);
                        var stren = Convert.ToInt32(pp[1]);
                        if (_willStrengthDic[entity.SkillCode] < stren)
                        {
                            _willStrengthDic[entity.SkillCode] = stren;
                        }
                        _willPlayerDic[entity.SkillCode].Add(pid);
                    }
                }
            }

            _suitDic = new Dictionary <int, List <int> >();
            foreach (var entity in suitList)
            {
                if (!_suitDic.ContainsKey(entity.SuitType))
                {
                    _suitDic.Add(entity.SuitType, new List <int>());
                }
                _suitDic[entity.SuitType].Add(entity.Idx);
            }
            //_positionPropertyDic = new Dictionary<int, List<int>>();
            //_positionPropertyDic.Add((int)EnumPosition.Forward,new List<int>(){(int)EnumProperty.Speed,(int)EnumProperty.Shoot,(int)EnumProperty.FreeKick});
            //_positionPropertyDic.Add((int)EnumPosition.Midfielder, new List<int>() { (int)EnumProperty.Dribble, (int)EnumProperty.Pass, (int)EnumProperty.Mentality });
            //_positionPropertyDic.Add((int)EnumPosition.Fullback, new List<int>() { (int)EnumProperty.Aggression, (int)EnumProperty.Disturb, (int)EnumProperty.Interception });
            //_positionPropertyDic.Add((int)EnumPosition.Goalkeeper, new List<int>() { (int)EnumProperty.HandControl, (int)EnumProperty.Response, (int)EnumProperty.Positioning });

            _positionSkillDic = new Dictionary <int, List <int> >();
            _positionSkillDic.Add((int)EnumPosition.Forward, new List <int>()
            {
                (int)EnumSKillActType.Shoot
            });
            _positionSkillDic.Add((int)EnumPosition.Midfielder, new List <int>()
            {
                (int)EnumSKillActType.Through, (int)EnumSKillActType.Organize
            });
            _positionSkillDic.Add((int)EnumPosition.Fullback, new List <int>()
            {
                (int)EnumSKillActType.Defence
            });
            _positionSkillDic.Add((int)EnumPosition.Goalkeeper, new List <int>()
            {
                (int)EnumSKillActType.GoalKeep
            });

            _init = true;


            var allPlayer = DicPlayerMgr.GetAllForCache();

            _playerDic = new Dictionary <string, List <int> >();
            foreach (var item in allPlayer)
            {
                if (item.CardLevel == 6 || item.CardLevel == 5)
                {
                    continue;
                }
                if (!_playerDic.ContainsKey(item.PositionDesc))
                {
                    _playerDic.Add(item.PositionDesc, new List <int>());
                }
                _playerDic[item.PositionDesc].Add(item.Idx);
            }
        }
Ejemplo n.º 3
0
        void InitCache()
        {
            var list = DicPlayerMgr.GetAllForCache();

            _playersDic     = list.ToDictionary(d => d.Idx, d => d);
            _playerEntities = list;
            var list2 = DicStarskillsMgr.GetAllForCache();

            _starskillDic       = new Dictionary <int, List <DicStarskillsEntity> >(list2.Count);
            _starskillPlusList  = new List <string>(list2.Count);
            _starskillplusCount = 0;
            foreach (var entity in list2)
            {
                if (entity.IsValid)
                {
                    if (!_starskillDic.ContainsKey(entity.PlayerId))
                    {
                        _starskillDic[entity.PlayerId] = new List <DicStarskillsEntity>();
                    }
                    _starskillDic[entity.PlayerId].Add(entity);
                    _starskillPlusList.Add(entity.PlusCode);
                    _starskillplusCount++;
                }
            }

            _notSynthesisPlayer = new List <int>();
            var playerString = CacheFactory.AppsettingCache.GetAppSetting(EnumAppsetting.NotSynthesisPlayer);
            var pList        = playerString.Split(',');

            foreach (var p in pList)
            {
                int pid = ConvertHelper.ConvertToInt(p, 0);
                if (pid != 0)
                {
                    _notSynthesisPlayer.Add(pid);
                }
            }
            _playerLinkDetailDic = new Dictionary <int, List <int> >();
            var list3 = DicPlayerlinkMgr.GetAll();

            foreach (var entity in list3)
            {
                if (!_playerLinkDetailDic.ContainsKey(entity.LinkId))
                {
                    _playerLinkDetailDic.Add(entity.LinkId, new List <int>());
                }
                _playerLinkDetailDic[entity.LinkId].Add(entity.Idx);
            }
            foreach (var entity in list3)
            {
                if (!_playerLinkDetailDic.ContainsKey(entity.Idx))
                {
                    _playerLinkDetailDic.Add(entity.Idx, new List <int>());
                }
                _playerLinkDetailDic[entity.Idx].Add(entity.LinkId);
                var links = _playerLinkDetailDic[entity.LinkId];
                foreach (var link in links)
                {
                    if (link != entity.Idx)
                    {
                        _playerLinkDetailDic[entity.Idx].Add(link);
                    }
                }
            }

            _theStarDic = new Dictionary <int, ConfigPlayerthestarEntity>();
            var allTheStar = ConfigPlayerthestarMgr.GetAll();

            _theStarDic = allTheStar.ToDictionary(r => r.Idx, r => r);

            var allPotential = ConfigPotentialMgr.GetAll();

            _potentialDic  = new Dictionary <int, ConfigPotentialEntity>();
            allPotentialId = new List <int>();
            foreach (var item in allPotential)
            {
                if (!allPotentialId.Exists(r => r == item.PotentialId))
                {
                    allPotentialId.Add(item.PotentialId);
                }
                var key = GetKey(item.Level, item.PotentialId);
                if (!_potentialDic.ContainsKey(key))
                {
                    _potentialDic.Add(key, item);
                }
            }

            _potentialCardDic = new Dictionary <string, List <ConfigPotentialcardEntity> >();
            var allcard = ConfigPotentialcardMgr.GetAll();

            foreach (var item in allcard)
            {
                if (!_potentialCardDic.ContainsKey(item.CardLevel))
                {
                    _potentialCardDic.Add(item.CardLevel, new List <ConfigPotentialcardEntity>());
                }
                _potentialCardDic[item.CardLevel].Add(item);
            }
        }
Ejemplo n.º 4
0
        private List <DicItemEntity> SetArenaBagConfig(DicArenabagconfigEntity bagConfig, List <DicItemEntity> itemList)
        {
            List <DicItemEntity>   items   = new List <DicItemEntity>();
            List <DicPlayerEntity> bagList = DicPlayerMgr.GetAllForCache();

            try
            {
                #region 判断每个属性是否符合竞技场卡包配置,现在只能配置(所属赛区,球员位置,卡牌颜色等级,kpi等级,能力值,身高,体重,生日)

                if (!string.IsNullOrEmpty(bagConfig.Area))
                {
                    var      str  = bagConfig.Area;
                    string[] strs = str.Split('|');
                    if (strs.Length > 1)
                    {
                        List <int> dicS = new List <int>();
                        for (int i = 0; i < strs.Length; i++)
                        {
                            int s = ConvertHelper.ConvertToInt(strs[i]);
                            if (!dicS.Contains(s))
                            {
                                dicS.Add(s);
                            }
                        }
                        bagList.RemoveAll(b => (!dicS.Contains(b.Area)));
                    }
                }
                if (!string.IsNullOrEmpty(bagConfig.PositionDesc))
                {
                    var      str  = bagConfig.PositionDesc;
                    string[] strs = str.Split('|');
                    if (strs.Length > 1)
                    {
                        List <string> dicS = new List <string>();
                        for (int i = 0; i < strs.Length; i++)
                        {
                            if (!dicS.Contains(strs[i]))
                            {
                                dicS.Add(strs[i]);
                            }
                        }
                        bagList.RemoveAll(b => (!dicS.Contains(b.PositionDesc)));
                    }
                }

                if (!string.IsNullOrEmpty(bagConfig.CardLevel))
                {
                    var      str  = bagConfig.CardLevel;
                    string[] strs = str.Split('|');
                    if (strs.Length > 1)
                    {
                        List <int> dicS = new List <int>();
                        for (int i = 0; i < strs.Length; i++)
                        {
                            int s = ConvertHelper.ConvertToInt(strs[i]);
                            if (!dicS.Contains(s))
                            {
                                dicS.Add(s);
                            }
                        }
                        bagList.RemoveAll(b => (!dicS.Contains(b.CardLevel)));
                    }
                }
                if (!string.IsNullOrEmpty(bagConfig.KpiLevel))
                {
                    var      str  = bagConfig.KpiLevel;
                    string[] strs = str.Split('|');
                    if (strs.Length > 1)
                    {
                        List <string> dicS = new List <string>();
                        for (int i = 0; i < strs.Length; i++)
                        {
                            if (!dicS.Contains(strs[i]))
                            {
                                dicS.Add(strs[i]);
                            }
                        }
                        bagList.RemoveAll(b => (!dicS.Contains(b.KpiLevel)));
                    }
                }
                if (!string.IsNullOrEmpty(bagConfig.Capacity))
                {
                    var      str  = bagConfig.Capacity;
                    string[] strs = str.Split('|');
                    if (strs.Length == 2)
                    {
                        var min = ConvertHelper.ConvertToInt(strs[0]);
                        var max = ConvertHelper.ConvertToInt(strs[1]);
                        if (max == 0)
                        {
                            bagList.RemoveAll(b => (b.Capacity < min));
                        }
                        else
                        {
                            bagList.RemoveAll(b => (b.Capacity <min || b.Capacity> max));
                        }
                    }
                }
                if (!string.IsNullOrEmpty(bagConfig.Stature))
                {
                    var      str  = bagConfig.Stature;
                    string[] strs = str.Split('|');
                    if (strs.Length == 2)
                    {
                        var min = ConvertHelper.ConvertToInt(strs[0]);
                        var max = ConvertHelper.ConvertToInt(strs[1]);
                        if (max == 0)
                        {
                            bagList.RemoveAll(b => (b.Stature < min));
                        }
                        else
                        {
                            bagList.RemoveAll(b => (b.Stature <min || b.Stature> max));
                        }
                    }
                }
                if (!string.IsNullOrEmpty(bagConfig.Weight))
                {
                    var      str  = bagConfig.Weight;
                    string[] strs = str.Split('|');
                    if (strs.Length == 2)
                    {
                        var min = ConvertHelper.ConvertToInt(strs[0]);
                        var max = ConvertHelper.ConvertToInt(strs[1]);
                        if (max == 0)
                        {
                            bagList.RemoveAll(b => (b.Weight < min));
                        }
                        else
                        {
                            bagList.RemoveAll(b => (b.Weight <min || b.Weight> max));
                        }
                    }
                }
                // 限制生日
                if (!string.IsNullOrEmpty(bagConfig.Birthday))
                {
                    var i = 0;

                    try
                    {
                        var str = bagConfig.Birthday;

                        string[] strs = str.Split('|');

                        if (strs.Length == 2)
                        {
                            if (strs[1] == "0")
                            {
                                i = 1;
                                var min = ConvertHelper.StringToDateTime(strs[0]);
                                i = 2;
                                bagList.RemoveAll(b => (ConvertHelper.StringToDateTime(b.Birthday) < min));
                                i = 3;
                            }
                            else if (strs[0] == "0")
                            {
                                i = 4;
                                var max = ConvertHelper.StringToDateTime(strs[1]);
                                i = 5;
                                bagList.RemoveAll(b => (ConvertHelper.StringToDateTime(b.Birthday) > max));
                                i = 6;
                            }
                            else
                            {
                                var min = ConvertHelper.StringToDateTime(strs[0]);
                                var max = ConvertHelper.StringToDateTime(strs[1]);
                                bagList.RemoveAll(
                                    b => (ConvertHelper.StringToDateTime(b.Birthday) < min || ConvertHelper.StringToDateTime(b.Birthday) > max));
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        SystemlogMgr.Info("bagConfigBirthday", "*" + e.Message + "*竞技场礼包*");
                    }
                }


                #endregion


                foreach (var entity in bagList)
                {
                    items.Add(itemList.Find(d => (d.LinkId == entity.Idx && d.ItemType == 1)));
                }

                return(items);
            }
            catch (Exception)
            {
                return(items);
            }
        }
Ejemplo n.º 5
0
        public static ItemTipsEntity ExportItemTips()
        {
            var            itemList      = DicItemMgr.GetAll();
            var            playerList    = DicPlayerMgr.GetAll();
            var            equipmentList = DicEquipmentMgr.GetAll();
            var            mallList      = DicMallitemMgr.GetAll().FindAll(d => d.MallType != 5);
            var            ballList      = DicBallsoulMgr.GetAll();
            var            willList      = DicManagerwillMgr.GetAll();
            var            starskillList = DicStarskillsMgr.GetAll();
            ItemTipsEntity itemTips      = new ItemTipsEntity();

            itemTips.PlayerCard = new List <PlayerCardDescriptionEntity>(playerList.Count);
            itemTips.Equipment  = new List <EquipmentDescriptionEntity>(equipmentList.Count);
            itemTips.Ballsoul   = new List <BallsoulDescriptionEntity>(0);
            itemTips.MallItem   = new List <MallItemDescriptionEntity>(mallList.Count);
            foreach (var itemEntity in itemList)
            {
                switch (itemEntity.ItemType)
                {
                case (int)EnumItemType.PlayerCard:
                    var playerd = BuildPlayerCardDescription(itemEntity,
                                                             playerList.Find(d => d.Idx == itemEntity.LinkId));
                    var star = starskillList.FindAll(d => d.PlayerId == playerd.PlayerId);
                    if (star.Count > 0)
                    {
                        playerd.Starskill     = "";
                        playerd.StarskillCode = "";
                        foreach (var entity in star)
                        {
                            playerd.Starskill     += entity.Name + ",";
                            playerd.StarskillCode += entity.SkillCode + ",";
                        }
                        playerd.Starskill     = playerd.Starskill.TrimEnd(',');
                        playerd.StarskillCode = playerd.StarskillCode.TrimEnd(',');
                    }


                    var wills =
                        willList.FindAll(d => d.DriveFlag == 1 && d.PartMap.Contains(playerd.PlayerId.ToString()));
                    if (wills != null && wills.Count > 0)
                    {
                        foreach (var entity in wills)
                        {
                            playerd.CombSkill = entity.SkillName + ",";
                        }
                        playerd.CombSkill = playerd.CombSkill.TrimEnd(',');
                    }
                    itemTips.PlayerCard.Add(playerd);
                    break;

                case (int)EnumItemType.Equipment:
                    var equipd = BuildEquipmentDescription(itemEntity,
                                                           equipmentList.Find(d => d.Idx == itemEntity.LinkId));
                    itemTips.Equipment.Add(equipd);
                    break;

                case (int)EnumItemType.MallItem:
                    var malld = BuildMallDescription(itemEntity, mallList.Find(d => d.MallCode == itemEntity.LinkId));
                    itemTips.MallItem.Add(malld);
                    break;
                }
            }
            return(itemTips);
        }