예제 #1
0
 public static int CompareKnowledgeSkills(KnowledgeSkill rhs, KnowledgeSkill lhs)
 {
     if (rhs.Name != null && lhs.Name != null)
     {
         return(string.Compare(rhs.WriteableName, lhs.WriteableName, StringComparison.Ordinal));
     }
     return(0);
 }
예제 #2
0
        internal void RemoveSkills(FilterOptions skills, bool createKnowledge = true)
        {
            string strCategory;

            switch (skills)
            {
            case FilterOptions.Magician:
            case FilterOptions.Sorcery:
            case FilterOptions.Conjuring:
            case FilterOptions.Enchanting:
            case FilterOptions.Adept:
                strCategory = "Magical Active";
                break;

            case FilterOptions.Technomancer:
                strCategory = "Resonance Active";
                break;

            default:
                return;
            }
            // Check for duplicates (we'd normally want to make sure it's enabled, but SpecialSkills doesn't process the Enabled property properly)
            foreach (Improvement objImprovement in _objCharacter.Improvements.Where(x => x.ImproveType == Improvement.ImprovementType.SpecialSkills))
            {
                FilterOptions eLoopFilter     = (FilterOptions)Enum.Parse(typeof(FilterOptions), objImprovement.ImprovedName);
                string        strLoopCategory = string.Empty;
                switch (eLoopFilter)
                {
                case FilterOptions.Magician:
                case FilterOptions.Sorcery:
                case FilterOptions.Conjuring:
                case FilterOptions.Enchanting:
                case FilterOptions.Adept:
                    strLoopCategory = "Magical Active";
                    break;

                case FilterOptions.Technomancer:
                    strLoopCategory = "Resonance Active";
                    break;
                }
                if (strLoopCategory == strCategory)
                {
                    return;
                }
            }

            for (int i = Skills.Count - 1; i >= 0; i--)
            {
                if (Skills[i].SkillCategory == strCategory)
                {
                    Skill skill = Skills[i];
                    _dicSkillBackups.Add(skill.SkillId, skill);
                    Skills.RemoveAt(i);
                    SkillsDictionary.Remove(skill.IsExoticSkill ? skill.Name + " (" + skill.DisplaySpecializationMethod(GlobalOptions.DefaultLanguage) + ')' : skill.Name);

                    if (_objCharacter.Created && skill.TotalBaseRating > 0 && createKnowledge)
                    {
                        KnowledgeSkill kno = new KnowledgeSkill(_objCharacter)
                        {
                            Type          = skill.Name == "Arcana" ? "Academic" : "Professional",
                            WriteableName = skill.Name,
                            Base          = skill.Base,
                            Karma         = skill.Karma
                        };
                        kno.Specializations.AddRange(skill.Specializations);
                        KnowledgeSkills.MergeInto(kno, (x, y) => string.Compare(x.Type, y.Type, StringComparison.Ordinal) == 0 ? CompareSkills(x, y) : (string.Compare(x.Type, y.Type, StringComparison.Ordinal) == -1 ? -1 : 1), (objExistSkill, objNewSkill) =>
                        {
                            if (objNewSkill.Base > objExistSkill.Base)
                            {
                                objExistSkill.Base = objNewSkill.Base;
                            }
                            if (objNewSkill.Karma > objExistSkill.Karma)
                            {
                                objExistSkill.Karma = objNewSkill.Karma;
                            }
                            objExistSkill.Specializations.MergeInto(objNewSkill.Specializations, (x, y) => x.Free == y.Free ? string.Compare(x.DisplayName(GlobalOptions.Language), y.DisplayName(GlobalOptions.Language), StringComparison.Ordinal) : (x.Free ? 1 : -1));
                        });
                    }
                }
            }
            if (!_objCharacter.Created)
            {
                // zero out any skillgroups whose skills did not make the final cut
                foreach (SkillGroup objSkillGroup in SkillGroups)
                {
                    if (!objSkillGroup.SkillList.Any(x => SkillsDictionary.ContainsKey(x.Name)))
                    {
                        objSkillGroup.Base  = 0;
                        objSkillGroup.Karma = 0;
                    }
                }
            }
        }