public void InitiateSpell(JSONObject spellObject) { mName = spellObject.GetString("name"); mSchool = (DnDMagicSchool)spellObject.GetNumber("school"); JSONArray classes = spellObject.GetArray("classes"); foreach (var val in classes) { SpellAttribute attribute = new SpellAttribute(); attribute.attribute = SpellAttributeType.Class; attribute.attributeValue = (int)val.Obj.GetNumber("class"); attribute.rank = (int)val.Obj.GetNumber("rank"); mClasses.Add(attribute); } JSONArray domains = spellObject.GetArray("domains"); foreach (var val in domains) { SpellAttribute attribute = new SpellAttribute(); attribute.attribute = SpellAttributeType.Domain; attribute.attributeValue = (int)val.Obj.GetNumber("domain"); attribute.rank = (int)val.Obj.GetNumber("rank"); mDomains.Add(attribute); } }
public void Deserialize(JSONObject obj) { mName = obj.GetString("name"); mSchool = (DnDMagicSchool)obj.GetNumber("school"); mClasses = new List <SpellAttribute>(); foreach (var value in obj.GetArray("classes")) { SpellAttribute tempAttribute = new SpellAttribute(); tempAttribute.attribute = SpellAttributeType.Class; tempAttribute.attributeValue = (int)value.Obj.GetNumber("class"); tempAttribute.rank = (int)value.Obj.GetNumber("rank"); mClasses.Add(tempAttribute); } mDomains = new List <SpellAttribute>(); foreach (var value in obj.GetArray("domains")) { SpellAttribute tempAttribute = new SpellAttribute(); tempAttribute.attribute = SpellAttributeType.Domain; tempAttribute.attributeValue = (int)value.Obj.GetNumber("domain"); tempAttribute.rank = (int)value.Obj.GetNumber("rank"); mClasses.Add(tempAttribute); } }