Example #1
0
        // populate _Masteries with data from MasteryPerks.xml
        private void GetMasteryList()
        {
            _Masteries = new List<Mastery>();

            string masteriesDocPath = Path.Combine(DataDirectory, "MasteryPerks.xml");
            XDocument masteriesDoc = XDocument.Load(masteriesDocPath);

            foreach(XElement mastery in masteriesDoc.Root.Elements("Perk"))
            {
                Mastery newMastery = new Mastery()
                {
                    Tree = GetMasteryTree(XMLPal.GetString(mastery.Attribute("tree"))),
                    Tier = XMLPal.GetInt(mastery.Attribute("tier")),
                    Name = XMLPal.GetString(mastery.Attribute("name")),
                    Description = XMLPal.GetString(mastery.Attribute("description")),
                    Maximum = XMLPal.GetInt(mastery.Attribute("maximum"))
                };

                List<Stat> stats = new List<Stat>();

                if(mastery.Element("Stats") != null)
                {
                    foreach(XElement statElement in mastery.Element("Stats").DescendantNodes())
                    {
                        Stat newStat = new Stat()
                        {
                            StatType = GetStatType(XMLPal.GetString(statElement.Attribute("statType"))),
                            Value = XMLPal.GetString(statElement.Attribute("value"))
                        };

                        stats.Add(newStat);
                    }

                    newMastery.Stats = stats.ToArray();
                    _Masteries.Add(newMastery);
                }
            }
        }
Example #2
0
        // populate _Runes with data from Runes.xml
        private void GetRuneList()
        {
            _Runes = new List<Rune>();

            string runesDocPath = Path.Combine(DataDirectory, "Runes.xml");
            XDocument runesDoc = XDocument.Load(runesDocPath);

            foreach(XElement rune in runesDoc.Root.Elements("Rune"))
            {
                List<Stat> stats = new List<Stat>();

                Rune newRune = new Rune()
                {
                    Magnitude = XMLPal.GetString(rune.Attribute("magnitude")),
                    RuneType = GetRuneType(XMLPal.GetString(rune.Attribute("type"))),
                    Descriptor = XMLPal.GetString(rune.Attribute("descriptor"))
                };

                foreach (XElement statElement in rune.Element("Stats").DescendantNodes())
                {
                    Stat stat = new Stat()
                    {
                        StatType = GetStatType(XMLPal.GetString(statElement.Attribute("statType"))),
                        Value = XMLPal.GetString(statElement.Attribute("value"))
                    };

                    stats.Add(stat);
                }

                newRune.Stats = stats.ToArray();
                newRune.Name = newRune.Magnitude + " " + StringBeast.Capitalize(newRune.RuneType.ToString(), true) + " of " + newRune.Descriptor;

                _Runes.Add(newRune);
            }
        }
Example #3
0
        // populate _Items with data from Items.xml
        private void GetItemList()
        {
            _Items = new List<Item>();

            string itemsDocPath = Path.Combine(DataDirectory, "Items.xml");
            XDocument itemsDoc = XDocument.Load(itemsDocPath);
            Dictionary<string, List<string>> itemRelationships = new Dictionary<string,List<string>>();

            foreach(XElement itemElement in itemsDoc.Root.Elements("Item"))
            {
                Item item = new Item()
                {
                    Name = XMLPal.GetString(itemElement.Attribute("name")),
                    Id = XMLPal.GetInt(itemElement.Attribute("id")),
                    Cost = XMLPal.GetInt(itemElement.Attribute("cost")),
                };

                if(itemElement.Element("Stats") != null)
                {
                    List<Stat> stats = new List<Stat>();

                    foreach(XElement statElement in itemElement.Element("Stats").DescendantNodes())
                    {
                        Stat stat = new Stat()
                        {
                            StatType = GetStatType(XMLPal.GetString(statElement.Attribute("statType"))),
                            Value = XMLPal.GetString(statElement.Attribute("value"))
                        };
                        stats.Add(stat);
                    }

                    item.Stats = stats.ToArray();
                }

                if(itemElement.Element("Effects") != null)
                {
                    List<Effect> effects = new List<Effect>();

                    foreach(XElement effectElement in itemElement.Element("Effects").Elements("Effect"))
                    {
                        Effect effect = new Effect()
                        {
                            IsActive = (XMLPal.GetString(effectElement.Attribute("isActive")) == "true" ? true : false),
                            IsAura = (XMLPal.GetString(effectElement.Attribute("isAura")) == "true" ? true : false),
                            IsUnique = (XMLPal.GetString(effectElement.Attribute("isUnique")) == "true" ? true : false),
                            Description = XMLPal.GetString(effectElement)
                        };

                        effects.Add(effect);
                    }

                    item.Effects = effects.ToArray();
                }

                if(itemElement.Elements("BuiltFrom").Count() > 0)
                {
                    List<string> builtFromItems = new List<string>();
                    builtFromItems.AddRange(
                        from subItem in itemElement.Elements("BuiltFrom").Elements("Item")
                        select XMLPal.GetString(subItem.Attribute("slug"))
                    );

                    itemRelationships.Add(Slugger.Slugify(item.Name), builtFromItems);
                }

                _Items.Add(item);
            }

            foreach(string itemSlug in itemRelationships.Keys)
            {
                List<Item> builtFromItems = new List<Item>();
                Item item = _Items.Where(i => Slugger.Slugify(i.Name) == itemSlug).FirstOrDefault();

                foreach(string builtFromItemSlug in itemRelationships[itemSlug])
                {
                    Item builtFromItem = _Items.Where(i => Slugger.Slugify(i.Name) == builtFromItemSlug).FirstOrDefault();
                    builtFromItems.Add(builtFromItem);
                }

                item.BuiltFrom = builtFromItems.ToArray();
            }
        }