Пример #1
0
        public ItemBase(ItemImageService itemImageService, XmlItemBase xmlBase)
        {
            Level                = xmlBase.Level;
            RequiredStrength     = xmlBase.Strength;
            RequiredDexterity    = xmlBase.Dexterity;
            RequiredIntelligence = xmlBase.Intelligence;
            DropDisabled         = xmlBase.DropDisabled;
            InventoryHeight      = xmlBase.InventoryHeight;
            InventoryWidth       = xmlBase.InventoryWidth;

            Name       = xmlBase.Name;
            ItemType   = xmlBase.ItemType;
            ItemGroup  = ItemType.Group();
            MetadataId = xmlBase.MetadataId;

            ImplicitMods   = xmlBase.Implicit.Select(i => new Stat(i, ItemType)).ToList();
            _properties    = xmlBase.Properties.Select(p => new Stat(p, ItemType)).ToList();
            CanHaveQuality = ItemGroup == ItemGroup.OneHandedWeapon || ItemGroup == ItemGroup.TwoHandedWeapon ||
                             ItemGroup == ItemGroup.BodyArmour || ItemGroup == ItemGroup.Boots ||
                             ItemGroup == ItemGroup.Gloves || ItemGroup == ItemGroup.Helmet ||
                             ItemGroup == ItemGroup.Shield;

            Image = new ItemImage(itemImageService, Name, ItemGroup);

            MaximumNumberOfSockets = GetMaximumNumberOfSockets();
        }
Пример #2
0
        /// <summary>
        /// Creates an ItemBase that sets <see cref="ItemClass"/> and <see cref="Tags"/> on
        /// a best effort basis. They might not be set correctly.
        /// <para/>
        /// Only <see cref="Name"/>, <see cref="ItemClass"/> and <see cref="Tags"/> may be called on
        /// ItemBases created via this constructor. It is not meant to produce bases that can exist independent
        /// of the <see cref="Item"/> they are created for.
        /// </summary>
        /// <param name="itemImageService"></param>
        /// <param name="itemSlot">The slot the parent <see cref="Item"/> is slotted into.
        /// <see cref="ItemSlot.Unequipable"/> if is not equipped.</param>
        /// <param name="typeLine">The TypeLine property of the parent <see cref="Item"/>.</param>
        /// <param name="frameType">The frame type of the item.</param>
        public ItemBase(ItemImageService itemImageService, ItemSlot itemSlot, string typeLine, FrameType frameType)
        {
            // These don't matter as we won't create new items from this base.
            Level                = 0;
            RequiredStrength     = 0;
            RequiredDexterity    = 0;
            RequiredIntelligence = 0;
            DropDisabled         = false;
            InventoryHeight      = 0;
            InventoryWidth       = 0;
            MetadataId           = "";
            ImplicitMods         = new List <IMod>();
            _properties          = new List <string>();
            CanHaveQuality       = false;

            Name      = typeLine;
            ItemClass = ItemSlotToClass(itemSlot);
            if (ItemClass == ItemClass.ActiveSkillGem)
            {
                ItemClass = ItemClassEx.ItemClassForGem(typeLine);
            }
            if (ItemClass == ItemClass.Unknown)
            {
                if (frameType == FrameType.Gem)
                {
                    ItemClass = ItemClassEx.ItemClassForGem(typeLine);
                }
                else if (frameType == FrameType.Currency || frameType == FrameType.DivinationCard ||
                         frameType == FrameType.QuestItem || frameType == FrameType.Prophecy)
                {
                    ItemClass = ItemClass.Unknown;
                }
                else if (typeLine.Contains("Quiver"))
                {
                    ItemClass = ItemClass.Quiver;
                }
                else if (typeLine.Contains("Shield") || typeLine.Contains("Buckler"))
                {
                    ItemClass = ItemClass.Shield;
                }
                else if (typeLine.Contains("Amulet") || typeLine.Contains("Talisman"))
                {
                    ItemClass = ItemClass.Amulet;
                }
                else if (typeLine.Contains("Ring"))
                {
                    ItemClass = ItemClass.Ring;
                }
                else if (typeLine.Contains("Belt"))
                {
                    ItemClass = ItemClass.Belt;
                }
            }

            // This might miss some tags, but those are only important for mod crafting,
            // which will not happen with this item.
            Tags = ItemClass.ToTags();

            Image = new ItemImage(itemImageService, ItemClass);
        }
Пример #3
0
        public ItemBase(Options options, XmlItemBase xmlBase)
        {
            Level                = xmlBase.Level;
            RequiredStrength     = xmlBase.Strength;
            RequiredDexterity    = xmlBase.Dexterity;
            RequiredIntelligence = xmlBase.Intelligence;

            Name         = xmlBase.Name;
            ItemType     = xmlBase.ItemType;
            ItemGroup    = ItemType.Group();
            ImplicitMods = xmlBase.Implicit != null
                ? xmlBase.Implicit.Select(i => new Stat(i, ItemType)).ToList()
                : new List <Stat>();

            Properties = xmlBase.Properties != null
                ? xmlBase.Properties.Select(p => new Stat(p, ItemType)).ToList()
                : new List <Stat>();

            CanHaveQuality = ItemGroup == ItemGroup.OneHandedWeapon || ItemGroup == ItemGroup.TwoHandedWeapon ||
                             ItemGroup == ItemGroup.BodyArmour || ItemGroup == ItemGroup.Boots ||
                             ItemGroup == ItemGroup.Gloves || ItemGroup == ItemGroup.Helmet ||
                             ItemGroup == ItemGroup.Shield;

            Image = new ItemImage(options, Name, ItemGroup);
        }
Пример #4
0
 protected ItemImage(ItemImage baseItemImage)
 {
     Options         = baseItemImage.Options;
     _baseName       = baseItemImage._baseName;
     _baseGroup      = baseItemImage._baseGroup;
     _imageSource    = baseItemImage._imageSource;
     _isDefaultImage = baseItemImage._isDefaultImage;
     _defaultImage   = baseItemImage._defaultImage;
 }
Пример #5
0
 protected ItemImage(ItemImage baseItemImage)
 {
     Options = baseItemImage.Options;
     _baseName = baseItemImage._baseName;
     _baseGroup = baseItemImage._baseGroup;
     _imageSource = baseItemImage._imageSource;
     _isDefaultImage = baseItemImage._isDefaultImage;
     _defaultImage = baseItemImage._defaultImage;
 }
Пример #6
0
 public Item(ItemBase itemBase, int width, int height)
 {
     _baseType  = itemBase;
     _itemType  = itemBase.ItemType;
     _itemGroup = itemBase.ItemGroup;
     Width      = width;
     Height     = height;
     RequirementsFromBase();
     _image = itemBase.Image;
 }
Пример #7
0
        public UniqueBase(ItemImageService itemImageService, ItemBase itemBase, XmlUnique xmlUnique)
        {
            UniqueName   = xmlUnique.Name;
            Level        = xmlUnique.Level;
            DropDisabled = xmlUnique.DropDisabled;
            _base        = itemBase;
            ExplicitMods = xmlUnique.Explicit.Select(e => new Stat(e, itemBase.ItemType)).ToList();

            Image = itemBase.Image.AsDefaultForUniqueImage(itemImageService, UniqueName);
        }
Пример #8
0
        public ItemBase(ItemImageService itemImageService, ModDatabase modDatabase, XmlItemBase xmlBase)
        {
            Level                = xmlBase.Level;
            RequiredStrength     = xmlBase.Strength;
            RequiredDexterity    = xmlBase.Dexterity;
            RequiredIntelligence = xmlBase.Intelligence;
            DropDisabled         = xmlBase.DropDisabled;
            InventoryHeight      = xmlBase.InventoryHeight;
            InventoryWidth       = xmlBase.InventoryWidth;

            Name       = xmlBase.Name;
            ItemClass  = xmlBase.ItemClass;
            Tags       = xmlBase.Tags;
            MetadataId = xmlBase.MetadataId;

            ImplicitMods   = xmlBase.Implicit.Select(id => modDatabase.Mods[id]).ToList();
            _properties    = xmlBase.Properties;
            CanHaveQuality = Tags.HasFlag(Tags.Weapon) || Tags.HasFlag(Tags.Armour);

            Image = new ItemImage(itemImageService, Name, ItemClass);

            MaximumNumberOfSockets = GetMaximumNumberOfSockets();
        }
Пример #9
0
 public Item(Item source)
 {
     //_slot, _itemType, _itemGroup, _gems, _keywords, _frame
     _slot      = source._slot;
     _itemType  = source._itemType;
     _itemGroup = source._itemGroup;
     if (source._gems != null)
     {
         _gems = source._gems.ToList();
     }
     if (source._keywords != null)
     {
         _keywords = source._keywords.ToList();
     }
     _frame = source._frame;
     //_properties, _requirements, _explicit-, _implicit-, _craftetMods
     _properties   = source._properties.ToList();
     _requirements = new ObservableCollection <ItemMod>(source._requirements);
     _explicitMods = source._explicitMods.ToList();
     _implicitMods = source._implicitMods.ToList();
     _craftedMods  = source._craftedMods.ToList();
     //_flavourText, _nameLine, _typeLine, _socketGroup, _baseType, _iconUrl, _image
     _flavourText = source.FlavourText;
     _nameLine    = source.NameLine;
     _typeLine    = source.TypeLine;
     _socketGroup = source._socketGroup;
     _baseType    = source._baseType;
     _iconUrl     = source._iconUrl;
     _image       = source._image;
     //JsonBase, _x, _y, Width, Height
     JsonBase = new JObject(source.JsonBase);
     _x       = source._x;
     _y       = source._y;
     Width    = source.Width;
     Height   = source.Height;
 }
Пример #10
0
        public UniqueBase(ItemImageService itemImageService, ModDatabase modDatabase, ItemBase itemBase,
                          XmlUnique xmlUnique)
        {
            UniqueName   = xmlUnique.Name;
            Level        = xmlUnique.Level;
            DropDisabled = xmlUnique.DropDisabled;
            _base        = itemBase;
            _properties  = xmlUnique.Properties;
            var explicits = new List <IMod>();

            foreach (var id in xmlUnique.Explicit)
            {
                Mod mod;
                if (!modDatabase.Mods.TryGetValue(id, out mod))
                {
                    Log.Error($"Unknown mod id {id} on unique {UniqueName}");
                    continue;
                }
                explicits.Add(mod);
            }
            ExplicitMods = explicits;

            Image = itemBase.Image.AsDefaultForUniqueImage(itemImageService, UniqueName);
        }
Пример #11
0
        public Item(IPersistentData persistentData, JObject val, ItemSlot itemSlot = ItemSlot.Unequipable, bool isGem = false)
        {
            JsonBase = val;
            Slot     = itemSlot;

            Width  = val["w"].Value <int>();
            Height = val["h"].Value <int>();
            if (val["x"] != null)
            {
                X = val["x"].Value <int>();
            }
            if (val["y"] != null)
            {
                Y = val["y"].Value <int>();
            }

            if (val["name"] != null)
            {
                NameLine = FilterJsonString(val["name"].Value <string>());
            }

            JToken iconToken;

            if (val.TryGetValue("icon", out iconToken))
            {
                _iconUrl = iconToken.Value <string>();
            }

            Frame    = (FrameType)val["frameType"].Value <int>();
            TypeLine = FilterJsonString(val["typeLine"].Value <string>());
            if (isGem)
            {
                // BaseType will be null for socketed gems.
                _itemGroup = ItemGroup.Gem;
            }
            else
            {
                if (Frame == FrameType.Magic)
                {
                    _baseType = persistentData.EquipmentData.ItemBaseFromTypeline(TypeLine);
                }
                else
                {
                    persistentData.EquipmentData.BaseDictionary.TryGetValue(TypeLine, out _baseType);
                }
                // For known bases, images are only downloaded if the item is unique. All other items should always
                // have the same image. (except alt art non-uniques that are rare enough to be ignored)
                var loadImageFromIconUrl = _iconUrl != null && (_baseType == null || Frame == FrameType.Unique);
                if (_baseType == null)
                {
                    _baseType = new ItemBase(persistentData.Options, itemSlot, TypeLine,
                                             _keywords == null ? "" : _keywords.FirstOrDefault(), Frame);
                }
                _itemType  = BaseType.ItemType;
                _itemGroup = BaseType.ItemGroup;
                if (loadImageFromIconUrl)
                {
                    _image = new ItemImageFromOfficial(_baseType.Image, _iconUrl);
                }
                else
                {
                    _image = _baseType.Image;
                    _image.DownloadMissingImage();
                }

                FixOldItems();
            }

            if (val["properties"] != null)
            {
                foreach (var obj in val["properties"])
                {
                    Properties.Add(ItemModFromJson(obj, false));
                }
                if (Properties.Any(m => !m.Value.Any()))
                {
                    // The name of one property of gems contains the Keywords of that gem.
                    _keywords = Properties.First(m => !m.Value.Any()).Attribute.Split(',').Select(i => i.Trim()).ToList();
                }
            }

            if (val["requirements"] != null)
            {
                var mods = val["requirements"].Select(t => ItemModFromJson(t, true)).ToList();
                if (!mods.Any(m => m.Attribute.StartsWith("Requires ")))
                {
                    var modsToMerge = new []
                    {
                        mods.FirstOrDefault(m => m.Attribute == "Level #"),
                        mods.FirstOrDefault(m => m.Attribute == "# Str"),
                        mods.FirstOrDefault(m => m.Attribute == "# Dex"),
                        mods.FirstOrDefault(m => m.Attribute == "# Int")
                    }.Where(m => m != null).ToList();
                    modsToMerge.ForEach(m => mods.Remove(m));
                    mods.Add(new ItemMod(_itemType, "Requires " + string.Join(", ", modsToMerge.Select(m => m.Attribute)))
                    {
                        Value      = modsToMerge.Select(m => m.Value).Flatten().ToList(),
                        ValueColor = modsToMerge.Select(m => m.ValueColor).Flatten().ToList()
                    });
                }
                _requirements.AddRange(mods);
            }


            if (val["implicitMods"] != null)
            {
                foreach (var s in val["implicitMods"].Values <string>())
                {
                    _implicitMods.Add(new ItemMod(_itemType, s, Numberfilter));
                }
            }
            if (val["explicitMods"] != null)
            {
                foreach (var s in val["explicitMods"].Values <string>())
                {
                    ExplicitMods.Add(new ItemMod(_itemType, s, Numberfilter));
                }
            }
            if (val["craftedMods"] != null)
            {
                foreach (var s in val["craftedMods"].Values <string>())
                {
                    CraftedMods.Add(new ItemMod(_itemType, s, Numberfilter));
                }
            }

            if (val["flavourText"] != null)
            {
                FlavourText = string.Join("\r\n", val["flavourText"].Values <string>().Select(s => s.Replace("\r", "")));
            }


            if (isGem)
            {
                switch (val["colour"].Value <string>())
                {
                case "S":
                    _keywords.Add("Strength");
                    break;

                case "D":
                    _keywords.Add("Dexterity");
                    break;

                case "I":
                    _keywords.Add("Intelligence");
                    break;
                }
            }
            else
            {
                _gems = new List <Item>();
            }

            var sockets = new List <int>();

            if (val["sockets"] != null)
            {
                foreach (var obj in (JArray)val["sockets"])
                {
                    sockets.Add(obj["group"].Value <int>());
                }
            }
            if (val["socketedItems"] != null)
            {
                int socket = 0;
                foreach (JObject obj in (JArray)val["socketedItems"])
                {
                    var item = new Item(persistentData, obj, isGem: true)
                    {
                        _socketGroup = sockets[socket++]
                    };
                    _gems.Add(item);
                }
            }
        }
Пример #12
0
 public ItemImageFromOfficial(ItemImage baseImage, string imageUrl)
     : base(baseImage)
 {
     NewImageSourceTask(LoadFromOfficial(MakeUrl(imageUrl)),
         "Downloading of item image from official url failed.", ImageSource.Result);
 }
Пример #13
0
 public ItemImageFromOfficial(ItemImage baseImage, string imageUrl)
     : base(baseImage)
 {
     NewImageSourceTask(LoadFromOfficial(MakeUrl(imageUrl)),
                        "Downloading of item image from official url failed.", ImageSource.Result);
 }
Пример #14
0
        /// <summary>
        /// Creates an ItemBase that sets <see cref="ItemGroup"/> and <see cref="ItemType"/> on
        /// a best effort basis. They might not be set correctly.
        /// <para/>
        /// Only <see cref="Name"/>, <see cref="ItemGroup"/> and <see cref="ItemType"/> may be called on
        /// ItemBases created via this constructor. It is not meant to produce bases that can exist independent
        /// of the <see cref="Item"/> they are created for.
        /// </summary>
        /// <param name="itemImageService"></param>
        /// <param name="itemSlot">The slot the parent <see cref="Item"/> is slotted into.
        /// <see cref="ItemSlot.Unequipable"/> if is not equipped.</param>
        /// <param name="typeLine">The TypeLine property of the parent <see cref="Item"/>.</param>
        /// <param name="weaponClass">A string representing the weapon class of the parent <see cref="Item"/>.
        /// Can be null or empty if that item is not a weapon. The weapon class generally is a property without value.</param>
        /// <param name="frameType">The frame type of the item.</param>
        public ItemBase(ItemImageService itemImageService,
                        ItemSlot itemSlot, string typeLine, string weaponClass, FrameType frameType)
        {
            // These don't matter as we won't create new items from this base.
            Level                = 0;
            RequiredStrength     = 0;
            RequiredDexterity    = 0;
            RequiredIntelligence = 0;
            DropDisabled         = false;
            InventoryHeight      = 0;
            InventoryWidth       = 0;
            MetadataId           = "";
            ImplicitMods         = new List <Stat>();
            _properties          = new List <Stat>();
            CanHaveQuality       = false;

            Name      = typeLine;
            ItemGroup = ItemSlotToGroup(itemSlot);
            if (ItemGroup != ItemGroup.Unknown)
            {
                // This might be wrong for Armour slots, but the item will most likely not be edited so this is not important.
                ItemType = ItemGroup.Types()[0];
            }
            else if (frameType == FrameType.Gem)
            {
                ItemType = ItemType.Gem;
            }
            else if (frameType == FrameType.Currency || frameType == FrameType.DivinationCard ||
                     frameType == FrameType.QuestItem || frameType == FrameType.Prophecy)
            {
                ItemType = ItemType.Unknown;
            }
            else if (typeLine.Contains("Quiver"))
            {
                ItemType = ItemType.Quiver;
            }
            else if (typeLine.Contains("Shield") || typeLine.Contains("Buckler"))
            {
                ItemType = ItemType.ShieldArmour;
            }
            else if (typeLine.Contains("Amulet") || typeLine.Contains("Talisman"))
            {
                ItemType = ItemType.Amulet;
            }
            else if (typeLine.Contains("Ring"))
            {
                ItemType = ItemType.Ring;
            }
            else if (typeLine.Contains("Belt"))
            {
                ItemType = ItemType.Belt;
            }
            else if (!string.IsNullOrEmpty(weaponClass.Trim()))
            {
                ItemType type;
                if (Enum.TryParse(Regex.Replace(weaponClass.Trim(), "([a-z]) ([A-Z])", "$1$2"), true, out type))
                {
                    ItemType = type;
                }
            }

            if (ItemGroup == ItemGroup.Unknown)
            {
                ItemGroup = ItemType.Group();
            }
            Image = new ItemImage(itemImageService, ItemGroup);
        }
Пример #15
0
        /// <summary>
        /// Creates an ItemBase that sets <see cref="ItemClass"/> and <see cref="Tags"/> on
        /// a best effort basis. They might not be set correctly.
        /// <para/>
        /// Only <see cref="Name"/>, <see cref="ItemClass"/> and <see cref="Tags"/> may be called on
        /// ItemBases created via this constructor. It is not meant to produce bases that can exist independent
        /// of the <see cref="Item"/> they are created for.
        /// </summary>
        /// <param name="itemImageService"></param>
        /// <param name="itemSlot">The slot the parent <see cref="Item"/> is slotted into.
        /// <see cref="ItemSlot.Unequipable"/> if is not equipped.</param>
        /// <param name="typeLine">The TypeLine property of the parent <see cref="Item"/>.</param>
        /// <param name="weaponClass">A string representing the weapon class of the parent <see cref="Item"/>.
        /// Can be null or empty if that item is not a weapon. The weapon class generally is a property without value.</param>
        /// <param name="frameType">The frame type of the item.</param>
        public ItemBase(ItemImageService itemImageService,
                        ItemSlot itemSlot, string typeLine, string weaponClass, FrameType frameType)
        {
            // These don't matter as we won't create new items from this base.
            Level                = 0;
            RequiredStrength     = 0;
            RequiredDexterity    = 0;
            RequiredIntelligence = 0;
            DropDisabled         = false;
            InventoryHeight      = 0;
            InventoryWidth       = 0;
            MetadataId           = "";
            ImplicitMods         = new List <IMod>();
            _properties          = new List <string>();
            CanHaveQuality       = false;

            Name      = typeLine;
            ItemClass = ItemSlotToClass(itemSlot);
            if (ItemClass == ItemClass.ActiveSkillGem)
            {
                ItemClass = ItemClassEx.ItemClassForGem(typeLine);
            }
            if (ItemClass == ItemClass.Unknown)
            {
                if (frameType == FrameType.Gem)
                {
                    ItemClass = ItemClassEx.ItemClassForGem(typeLine);
                }
                else if (frameType == FrameType.Currency || frameType == FrameType.DivinationCard ||
                         frameType == FrameType.QuestItem || frameType == FrameType.Prophecy)
                {
                    ItemClass = ItemClass.Unknown;
                }
                else if (typeLine.Contains("Quiver"))
                {
                    ItemClass = ItemClass.Quiver;
                }
                else if (typeLine.Contains("Shield") || typeLine.Contains("Buckler"))
                {
                    ItemClass = ItemClass.Shield;
                }
                else if (typeLine.Contains("Amulet") || typeLine.Contains("Talisman"))
                {
                    ItemClass = ItemClass.Amulet;
                }
                else if (typeLine.Contains("Ring"))
                {
                    ItemClass = ItemClass.Ring;
                }
                else if (typeLine.Contains("Belt"))
                {
                    ItemClass = ItemClass.Belt;
                }
                else if (!string.IsNullOrWhiteSpace(weaponClass))
                {
                    // This will not catch ThrustingOneHandSword and Sceptre,
                    // but the distinction between those and OneHandSword and OneHandMace only matters for mod crafting
                    var itemClassStr = weaponClass.Replace("Handed", "Hand")
                                       .Replace(" ", "").Trim();
                    ItemClass type;
                    if (Enum.TryParse(itemClassStr, true, out type))
                    {
                        ItemClass = type;
                    }
                }
            }

            // This might miss some tags, but those are only important for mod crafting,
            // which will not happen with this item.
            Tags = ItemClass.ToTags();

            Image = new ItemImage(itemImageService, ItemClass);
        }
Пример #16
0
        /// <summary>
        /// Creates an ItemBase that sets <see cref="ItemGroup"/> and <see cref="ItemType"/> on
        /// a best effort basis. They might not be set correctly.
        /// <para/>
        /// Only <see cref="Name"/>, <see cref="ItemGroup"/> and <see cref="ItemType"/> may be called on
        /// ItemBases created via this constructor. It is not meant to produce bases that can exist independent
        /// of the <see cref="Item"/> they are created for.
        /// </summary>
        /// <param name="options"></param>
        /// <param name="itemSlot">The slot the parent <see cref="Item"/> is slotted into.
        /// <see cref="ItemSlot.Unequipable"/> if is not equipped.</param>
        /// <param name="typeLine">The TypeLine property of the parent <see cref="Item"/>.</param>
        /// <param name="weaponClass">A string representing the weapon class of the parent <see cref="Item"/>.
        /// Can be null or empty if that item is not a weapon. The weapon class generally is a property without value.</param>
        /// <param name="frameType">The frame type of the item.</param>
        public ItemBase(Options options, ItemSlot itemSlot, string typeLine, string weaponClass, FrameType frameType)
        {
            // These don't matter as we won't create new items from this base.
            Level = 0;
            RequiredStrength = 0;
            RequiredDexterity = 0;
            RequiredIntelligence = 0;
            ImplicitMods = new List<Stat>();
            Properties = new List<Stat>();
            CanHaveQuality = false;

            Name = typeLine;
            ItemGroup = ItemSlotToGroup(itemSlot);
            if (ItemGroup != ItemGroup.Unknown)
            {
                // This might be wrong for Armour slots, but the item will most likely not be edited so this is not important.
                ItemType = ItemGroup.Types()[0];
            }
            else if (frameType == FrameType.Gem)
                ItemType = ItemType.Gem;
            else if (frameType == FrameType.Currency || frameType == FrameType.DivinationCard
                || frameType == FrameType.QuestItem || frameType == FrameType.Prophecy)
                ItemType = ItemType.Unknown;
            else if (typeLine.Contains("Quiver"))
                ItemType = ItemType.Quiver;
            else if (typeLine.Contains("Shield") || typeLine.Contains("Buckler"))
                ItemType = ItemType.ShieldArmour;
            else if (typeLine.Contains("Amulet") || typeLine.Contains("Talisman"))
                ItemType = ItemType.Amulet;
            else if (typeLine.Contains("Ring"))
                ItemType = ItemType.Ring;
            else if (typeLine.Contains("Belt"))
                ItemType = ItemType.Belt;
            else if (!string.IsNullOrEmpty(weaponClass.Trim()))
            {
                ItemType type;
                if (Enum.TryParse(Regex.Replace(weaponClass.Trim(), "([a-z]) ([A-Z])", "$1$2"), true, out type))
                    ItemType = type;
            }

            if (ItemGroup == ItemGroup.Unknown)
                ItemGroup = ItemType.Group();
            Image = new ItemImage(options, Name, ItemGroup);
        }
Пример #17
0
        public ItemBase(Options options, XmlItemBase xmlBase)
        {
            Level = xmlBase.Level;
            RequiredStrength = xmlBase.Strength;
            RequiredDexterity = xmlBase.Dexterity;
            RequiredIntelligence = xmlBase.Intelligence;

            Name = xmlBase.Name;
            ItemType = xmlBase.ItemType;
            ItemGroup = ItemType.Group();
            ImplicitMods = xmlBase.Implicit != null
                ? xmlBase.Implicit.Select(i => new Stat(i, ItemType)).ToList()
                : new List<Stat>();
            Properties = xmlBase.Properties != null
                ? xmlBase.Properties.Select(p => new Stat(p, ItemType)).ToList()
                : new List<Stat>();
            CanHaveQuality = ItemGroup == ItemGroup.OneHandedWeapon || ItemGroup == ItemGroup.TwoHandedWeapon
                             || ItemGroup == ItemGroup.BodyArmour || ItemGroup == ItemGroup.Boots
                             || ItemGroup == ItemGroup.Gloves || ItemGroup == ItemGroup.Helmet
                             || ItemGroup == ItemGroup.Shield;

            Image = new ItemImage(options, Name, ItemGroup);
        }