private static bool AddSpecialAttribute(XmlNode attribute, MetaType metatype) { string attName = attribute.Attributes["name"].InnerText; XmlNode attStart = attribute.FindChildByName("Start"); if ((attStart == null || !AttributeLoader.SpecialAttributes.ContainsKey(attName)) && !metatype.SpecialAttributes.ContainsKey(attName)) return false; metatype.SpecialAttributes.Add(attName, new SpecialAttribute(attName, Convert.ToInt16(attStart.InnerText.Trim()))); return true; }
private static bool AddAttribute(XmlNode attribute, MetaType metatype) { string attName = attribute.Attributes["name"].InnerText; XmlNode attStart = attribute.FindChildByName("Start"); XmlNode attNatMax = attribute.FindChildByName("NaturalMax"); XmlNode attAugMax = attribute.FindChildByName("AugmentedMax"); if ((attStart == null || attNatMax == null || attAugMax == null || !AttributeLoader.Attributes.ContainsKey(attName)) && !metatype.Attributes.ContainsKey(attName)) return false; metatype.Attributes.Add(attName, new Attribute(attName, Convert.ToInt16(attStart.InnerText.Trim()), Convert.ToInt16(attNatMax.InnerText.Trim()), Convert.ToInt16(attAugMax.InnerText.Trim()))); return true; }
private static Dictionary<string, MetaType> GetMetatypes(XmlNodeList MetatypeList) { Dictionary<string, MetaType> metatypes = new Dictionary<string, MetaType>(); foreach (XmlNode metaNode in MetatypeList) { string name = metaNode.Attributes["name"].InnerText; int cost = Convert.ToInt32(metaNode.FindChildByName("BPCost").InnerText.Trim()); string desc = metaNode.FindChildByName("Desc").InnerText.Trim(); MetaType metatype = new MetaType(name, cost, desc); //Add all the attributes. If one is missing data we do not want to add it XmlNode attributes = metaNode.FindChildByName("Attributes"); if (attributes == null) continue; bool wasCompleteAtt = true; foreach (XmlNode attribute in attributes.ChildNodes) { if (attribute.Name == "MetaAttribute") wasCompleteAtt = AddAttribute(attribute, metatype); else if (attribute.Name == "MetaSpecialAttribute") wasCompleteAtt = AddSpecialAttribute(attribute, metatype); if (!wasCompleteAtt) break; } if (wasCompleteAtt && !metatypes.ContainsKey(metatype.Name)) { //Add special abilities XmlNode abilities = metaNode.FindChildByName("SpecialAbilities"); if (abilities != null) { foreach (XmlNode ability in abilities.ChildNodes) { metatype.SpecialAbilities.Add(ability.Attributes["name"].InnerText); } } metatypes.Add(metatype.Name, metatype); } } return metatypes; }