Exemplo n.º 1
0
        /// <summary>
        /// 初始化 技能-卡牌 关系列表
        /// </summary>
        public void SkillData_InitCardRelationLists()
        {
            //  1   包含此技能的卡牌,遍历卡牌,将技能对应卡牌添加进列表
            {
                //  临时列表,方便操作值列表项
                var directIncludedCards   = new Dictionary <ParsedSkillData, List <ParsedCardData> >();
                var indirectIncludedCards = new Dictionary <ParsedSkillData, List <ParsedCardData> >();

                foreach (var card in CardList)
                {
                    var allSkills        = CardData_GetAllSkills(card);
                    var expandSkills     = CardData_GetExpandSkills(card);
                    var onlyExpandSkills = expandSkills.Except(allSkills);

                    //  遍历技能列表,处理直接包含技能的卡牌
                    foreach (var skill in allSkills)
                    {
                        if (directIncludedCards.ContainsKey(skill))
                        {
                            directIncludedCards[skill].Add(card);
                        }
                        else
                        {
                            directIncludedCards.Add(skill, new List <ParsedCardData> {
                                card
                            });
                        }
                    }

                    //  遍历技能差集列表,处理间接包含技能的卡牌
                    foreach (var skill in onlyExpandSkills)
                    {
                        if (indirectIncludedCards.ContainsKey(skill))
                        {
                            indirectIncludedCards[skill].Add(card);
                        }
                        else
                        {
                            indirectIncludedCards.Add(skill, new List <ParsedCardData> {
                                card
                            });
                        }
                    }
                }

                //  将临时列表中的项目复制进永久列表
                foreach (var i in directIncludedCards)
                {
                    SkillData_DirectIncludedCards.TryAdd(i.Key, i.Value.ToArray());
                }
                foreach (var i in indirectIncludedCards)
                {
                    SkillData_IndirectIncludedCards.TryAdd(i.Key, i.Value.ToArray());
                }
            }

            //  2   技能可召唤出的卡牌,只包含召唤技能
            {
                foreach (var skill in SkillList.Where(m => m.IsSummonSkill))
                {
                    var list = new List <ParsedCardData>();
                    foreach (var i in SkillData_GetExpandSkills(skill))
                    {
                        switch (i.AffectType[0])
                        {
                        case 101:       //  召唤
                        case 184:       //  对场召唤
                        {
                            if (i.AffectValue.Length > 1)
                            {
                                list.AddRange(i.AffectValue.Select(m => CardList.FirstOrDefault(n => n.CardId + "" == m || n.CardName == m)));
                            }
                            else
                            {
                                list.Add(CardList.FirstOrDefault(n => n.CardId + "" == i.AffectValue[0] || n.CardName == i.AffectValue[0]));
                                list.Add(CardList.FirstOrDefault(n => n.CardId + "" == i.AffectValue2[0] || n.CardName == i.AffectValue2[0]));
                            }
                            break;
                        }

                        case 180:       //  合体
                        {
                            list.Add(CardList.FirstOrDefault(n => n.CardId + "" == i.AffectValue2[0] || n.CardName == i.AffectValue2[0]));
                            break;
                        }

                        case 193:       //  生成
                        case 203:       //  死亡诅咒
                        {
                            list.AddRange(i.AffectValue2[0].Split('&').Select(m => CardList.FirstOrDefault(n => n.CardId + "" == m || n.CardName == m)));
                            break;
                        }
                        }
                    }
                    var summoneeCards = list.Where(m => m != null).Distinct().ToArray();
                    SkillData_SummoneeCards.TryAdd(skill, summoneeCards);
                }
            }
        }