Exemplo n.º 1
0
        internal static SkillGroup Get(Skill skill)
        {
            if (skill.SkillGroupObject != null)
            {
                return(skill.SkillGroupObject);
            }

            if (string.IsNullOrWhiteSpace(skill.SkillGroup))
            {
                return(null);
            }

            foreach (SkillGroup skillGroup in skill.CharacterObject.SkillsSection.SkillGroups)
            {
                if (skillGroup._groupName == skill.SkillGroup)
                {
                    if (!skillGroup._affectedSkills.Contains(skill))
                    {
                        skillGroup.Add(skill);
                    }
                    return(skillGroup);
                }
            }

            SkillGroup newGroup = new SkillGroup(skill.CharacterObject, skill.SkillGroup);

            newGroup.Add(skill);
            skill.CharacterObject.SkillsSection.SkillGroups.MergeInto(newGroup, (l, r) => String.Compare(l.DisplayName, r.DisplayName, StringComparison.Ordinal),
                                                                      (l, r) => { foreach (Skill x in r.SkillList.Where(y => !l.SkillList.Contains(y)))
                                                                                  {
                                                                                      l.SkillList.Add(x);
                                                                                  }
                                                                      });

            return(newGroup);
        }
Exemplo n.º 2
0
        public static SkillGroup Get(Skill objSkill)
        {
            if (objSkill.SkillGroupObject != null)
            {
                return(objSkill.SkillGroupObject);
            }

            if (string.IsNullOrWhiteSpace(objSkill.SkillGroup))
            {
                return(null);
            }

            foreach (SkillGroup objSkillGroup in objSkill.CharacterObject.SkillsSection.SkillGroups)
            {
                if (objSkillGroup.Name == objSkill.SkillGroup)
                {
                    if (!objSkillGroup.SkillList.Contains(objSkill))
                    {
                        objSkillGroup.Add(objSkill);
                    }
                    return(objSkillGroup);
                }
            }

            SkillGroup objNewGroup = new SkillGroup(objSkill.CharacterObject, objSkill.SkillGroup);

            objNewGroup.Add(objSkill);
            objSkill.CharacterObject.SkillsSection.SkillGroups.MergeInto(objNewGroup, (l, r) => string.Compare(l.DisplayName, r.DisplayName, StringComparison.Ordinal),
                                                                         (l, r) => { foreach (Skill x in r.SkillList.Where(y => !l.SkillList.Contains(y)))
                                                                                     {
                                                                                         l.SkillList.Add(x);
                                                                                     }
                                                                         });

            return(objNewGroup);
        }