Exemple #1
0
        public IPoEItemParser GetParser()
        {
            if (_rawItem == null || !_reItemFormat.IsMatch(_rawItem))
            {
                throw new FormatException("Item text is not in the correct format");
            }

            IPoEItemParser parser       = null;
            PoEItemType    itemCategory = Utils.FindItemType(_rawItem);

            if (itemCategory == PoEItemType.Currency)
            {
                parser = new CurrencyParser(_rawItem);
            }
            else if (itemCategory == PoEItemType.Gem)
            {
                parser = new GemParser(_rawItem);
            }
            else if (itemCategory == PoEItemType.Flask)
            {
                parser = new FlaskParser(_rawItem);
            }
            else if (itemCategory == PoEItemType.Map)
            {
                parser = new MapParser(_rawItem);
            }
            else if (itemCategory.IsArmor())
            {
                parser = new ArmorParser(_rawItem, itemCategory);
            }
            else if (itemCategory.IsAccessory())
            {
                parser = new AccessoryParser(_rawItem, itemCategory);
            }
            else if (itemCategory.IsWeapon())
            {
                parser = new WeaponParser(_rawItem, itemCategory);
            }
            else if (itemCategory == PoEItemType.Fragment ||
                     itemCategory == PoEItemType.Prophecy)
            {
                parser = new PoEItemParser <PoEItem>(_rawItem, itemCategory);
            }

            return(parser);
        }
Exemple #2
0
 public ModdableItemParser(string rawItemText, PoEItemType type) : base(rawItemText, type)
 {
 }
 public WeaponParser(
     string rawItemText,
     PoEItemType itemCategory = (PoEItemType)200) : base(rawItemText, itemCategory)
 {
 }
Exemple #4
0
 public ArmorParser(
     string rawItemText,
     PoEItemType itemCategory = (PoEItemType)400) : base(rawItemText, itemCategory)
 {
 }
Exemple #5
0
        public static bool IsArmor(this PoEItemType type)
        {
            int val = (int)type;

            return(val >= 400 && val < 500);
        }
Exemple #6
0
        public static bool IsAccessory(this PoEItemType type)
        {
            int val = (int)type;

            return(val >= 300 && val < 400);
        }
Exemple #7
0
        public static bool IsWeapon(this PoEItemType type)
        {
            int val = (int)type;

            return(val >= 200 && val < 300);
        }
 public PoEItemParser(string rawItemText, PoEItemType type) : this(rawItemText)
 {
     _item.Category = type;
 }
Exemple #9
0
 public AccessoryParser(
     string rawItemText,
     PoEItemType itemCategory = (PoEItemType)300) : base(rawItemText, itemCategory)
 {
 }
Exemple #10
0
        public static PoEItemType FindItemType(string item)
        {
            PoEItemType type   = PoEItemType.Fragment;
            var         fields = GetItemFields(item);

            if (!fields.ContainsKey("Rarity"))
            {
                return(PoEItemType.Unknown);
            }

            string rarity = fields["Rarity"];

            if (rarity.Equals("Currency"))
            {
                type = PoEItemType.Currency;
            }
            else if (rarity.Equals("Gem"))
            {
                type = PoEItemType.Gem;
            }
            else if (fields.ContainsKey("Attacks per Second"))
            {
                int firstSectionEndIndex = item.IndexOf(new string('-', 8)) + 8;
                // ignore first 2 characters of the section
                int    endIndex   = item.IndexOf('\n', firstSectionEndIndex + 2);
                string weaponType = item.Substring(firstSectionEndIndex, endIndex - firstSectionEndIndex).Trim();

                type = ItemTypeUtils.StringToItemType(weaponType);
            }
            else if (fields.ContainsKey("Chance to Block"))
            {
                type = PoEItemType.Shield;
            }
            else if (item.Contains("Right-click to add this prophecy to your character"))
            {
                type = PoEItemType.Prophecy;
            }
            else
            {
                var    lines = SplitItemSection(item);
                string itemBase;

                // If the third line is a section separator
                if (lines[2][0] == '-')
                {
                    itemBase = lines[1];
                }
                else
                {
                    itemBase = lines[2];
                }

                if (_reAmulet.IsMatch(itemBase))
                {
                    type = PoEItemType.Amulet;
                }
                else if (_reRing.IsMatch(itemBase))
                {
                    type = PoEItemType.Ring;
                }
                else if (_reBelt.IsMatch(itemBase))
                {
                    type = PoEItemType.Belt;
                }
                else if (_reQuiver.IsMatch(itemBase))
                {
                    type = PoEItemType.Quiver;
                }
                else if (_reJewel.IsMatch(itemBase))
                {
                    type = PoEItemType.Jewel;
                }
                else if (_reHelmet.IsMatch(itemBase))
                {
                    type = PoEItemType.Helmet;
                }
                else if (_reGloves.IsMatch(itemBase))
                {
                    type = PoEItemType.Gloves;
                }
                else if (_reBoots.IsMatch(itemBase))
                {
                    type = PoEItemType.Boots;
                }
                else if (_reBodyArmor.IsMatch(itemBase))
                {
                    type = PoEItemType.BodyArmor;
                }
                else if (_reFlask.IsMatch(itemBase))
                {
                    type = PoEItemType.Flask;
                }
                else if (_reMap.IsMatch(itemBase))
                {
                    type = PoEItemType.Map;
                }
            }

            return(type);
        }
 public EnchantableItemParser(string rawItemText, PoEItemType type) : base(rawItemText, type)
 {
 }