Пример #1
0
        public object Clone()
        {
            Crate ReturnVal = new Crate(max_adv_lvl, max_ts_lvl);

            foreach (CrateItem thisItem in this)
            {
                CrateItem tempItem;
                if (thisItem.ItemType == 6)
                {
                    SpellScroll castItem = (SpellScroll)thisItem;
                    tempItem = (SpellScroll)castItem.Clone();
                }
                else
                {
                    RecipeBook castItem = (RecipeBook)thisItem;
                    tempItem = (RecipeBook)castItem.Clone();
                }
                ReturnVal.Add(tempItem);
            }
            if (ReturnVal.Count == Count)
            {
                return(ReturnVal);
            }
            else
            {
                throw new Exception("Unable to ensure cloniness.");
            }
        }
Пример #2
0
        public override object Clone()
        {
            SpellScroll returnVal = new SpellScroll
            {
                ItemIDNum    = ItemIDNum,
                ItemName     = ItemName,
                ItemLevel    = ItemLevel,
                ItemQuantity = ItemQuantity,
                ItemTier     = ItemTier,
                SpellCRC     = SpellCRC,
                ClassIDs     = ClassIDs,
                IsDescribed  = IsDescribed,
                IsHeirloom   = IsHeirloom,
                IsLore       = IsLore
            };

            return(returnVal);
        }
Пример #3
0
        /// <summary>Processes the <see cref="XElement"/> for details about <see cref="CrateItem"/> it represents and returns that CrateItem.</summary>
        /// <param name="ItemElement">The &lt;item&gt; tag, as retrieved from Daybreak Games' Census Server (and selected children).</param>
        /// <returns><see cref="CrateItem"/> that represents the info passed in by the parameter.</returns>
        internal CrateItem ProcessXML(XElement ItemElement)
        {
            const string classes         = "classes";
            const string text            = "text";
            const string reqdskll        = "requiredskill";
            const string tinkering       = "tinkering";
            const string adorning        = "adorning";
            const string level           = "level";
            const string dispname        = "displayname";
            XElement     TypeInfoElement = ItemElement.Element("typeinfo");
            CrateItem    ReturnVal;

            if (short.TryParse(ItemElement.Attribute("typeid").Value, out short ItemType) &&
                short.TryParse(ItemElement.Attribute("tierid").Value, out short TierID))
            {
                Dictionary <string, int> ClassList = new Dictionary <string, int>();
                if (ItemType == 7)
                {
                    List <long> RecipeList    = new List <long>();
                    XElement    RecipeElement = TypeInfoElement.Element("recipe_list");
                    foreach (XElement xElement in RecipeElement.Elements("recipe"))
                    {
                        RecipeList.Add(long.Parse(xElement.Attribute("id").Value));
                    }
                    if (ItemElement.Element(reqdskll) != null)
                    {
                        int skillLevel = int.Parse(ItemElement.Element(reqdskll).Attribute("min_skill").Value);
                        if (ItemElement.Element(reqdskll).Attribute(text).Value == adorning)
                        {
                            ClassList.Add(adorning, skillLevel);
                        }
                        else if (ItemElement.Element(reqdskll).Attribute(text).Value == tinkering)
                        {
                            ClassList.Add(tinkering, skillLevel);
                        }
                    }
                    ReturnVal = new RecipeBook
                    {
                        ItemTier    = TierID,
                        RecipieList = RecipeList,
                        ClassIDs    = ClassList
                    };
                }
                else if (ItemType == 6)
                {
                    foreach (XElement thisElement in TypeInfoElement.Element(classes).Descendants())
                    {
                        ClassList.Add(thisElement.Name.ToString(), int.Parse(thisElement.Attribute(level).Value));
                    }
                    if (!long.TryParse(TypeInfoElement.Attribute("spellid").Value, out long spellID))
                    {
                        throw new CrateException("Unable to extract the spell CRC from the XML.", 1);
                    }
                    ReturnVal = new SpellScroll {
                        SpellCRC = spellID,
                        ItemTier = TierID
                    };
                }
                else
                {
                    throw new CrateException("There was an unexpected item type!", 1);
                }
            }
            else
            {
                throw new CrateException("The item type returned was not short!", 1);
            }
            ReturnVal.ItemName   = DeHtmlText(ItemElement.Attribute(dispname).Value);
            ReturnVal.IsHeirloom = HasHeirloom(ItemElement);
            if (ReturnVal.ClassIDs.Count == 0)
            {
                Dictionary <string, int> ClassDict = new Dictionary <string, int>();
                foreach (XElement MaybeClassNode in TypeInfoElement.Element(classes).Descendants())
                {
                    ClassDict[MaybeClassNode.Attribute(dispname).Value.ToLower()] = int.Parse(MaybeClassNode.Attribute(level).Value);
                }
                ReturnVal.ClassIDs = ClassDict;
            }
            if (long.TryParse(ItemElement.Attribute("id").Value, out long ItemIDNum))
            {
                ReturnVal.ItemIDNum = ItemIDNum;
            }
            else
            {
                throw new CrateException("This item has no ID number!", 1);
            }
            if (short.TryParse(ItemElement.Attribute("tierid").Value, out short ItemTier))
            {
                ReturnVal.ItemTier = ItemTier;
            }
            else
            {
                throw new CrateException("This item has no tier!", 1);
            }
            if (short.TryParse(ItemElement.Attribute("itemlevel").Value, out short ItemLevel))
            {
                ReturnVal.ItemLevel = ItemLevel;
            }
            else
            {
                ReturnVal.ItemLevel = 0;
            }
            ReturnVal.IsDescribed = HasDescription(ItemElement);
            ReturnVal.IsLore      = HasLore(ItemElement);
            return(ReturnVal);
        }