示例#1
0
        public static bool CanLearn(Entity entity, Spell spell)
        {
            bool canLearn = true;

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

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

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

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

            return canLearn;
        }
示例#2
0
        public static Spell FromSpellData(SpellData data)
        {
            Spell spell = new Spell();
            spell.Name = data.Name;

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

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

            foreach (string s in data.SpellPrerequisites)
                spell.SpellPrerequisites.Add(s);

            spell.LevelRequirement = data.LevelRequirement;
            spell.SpellType = data.SpellType;
            spell.ActivationCost = data.ActivationCost;

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

            return spell;
        }