Example #1
0
        public static bool CanLearn(Entity entity, Talent talent)
        {
            bool canLearn = true;

            if (entity.Level < talent.LevelRequirement)
                canLearn = false;

            if (!talent.AllowedClasses.Contains(entity.EntityClass.ToLower()))
                canLearn = false;

            foreach (string s in talent.AttributeRequirements.Keys)
            {
                if (Mechanics.GetAttributeByString(entity, s) < talent.AttributeRequirements[s])
                {
                    canLearn = false;
                    break;
                }
            }

            foreach (string s in talent.TalentPrerequisites)
            {
                if (!entity.Talents.ContainsKey(s))
                {
                    canLearn = false;
                    break;
                }
            }

            return canLearn;
        }
Example #2
0
        public static Talent FromTalentData(TalentData data)
        {
            Talent talent = new Talent();

            talent.Name = data.Name;

            foreach (string s in data.AllowedClasses)
                talent.AllowedClasses.Add(s.ToLower());

            foreach (string s in data.AttributeRequirements.Keys)
                talent.AttributeRequirements.Add(s.ToLower(), data.AttributeRequirements[s]);

            foreach (string s in data.TalentPrerequisites)
                talent.TalentPrerequisites.Add(s);

            talent.LevelRequirement = data.LevelRequirement;
            talent.TalentType = data.TalentType;
            talent.ActivationCost = data.ActivationCost;

            foreach (string s in data.Effects)
                talent.Effects.Add(s);

            return talent;
        }