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; }
public static bool CanLearn(Entity entity, Spell spell) { bool canLearn = true; if (entity.Level < spell.LevelRequirement) canLearn = false; string entityClass = entity.EntityClass.ToLower(); if (!spell.AllowedClasses.Contains(entityClass)) 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.Spells.ContainsKey(s)) { canLearn = false; break; } } return canLearn; }