Пример #1
0
 // Returns true if property/mod is local, false otherwise.
 private static bool DetermineLocal(Item item, string attr)
 {
     return (item.Class != Item.ItemClass.Amulet && item.Class != Item.ItemClass.Ring &&
             item.Class != Item.ItemClass.Belt)
            && ((attr.Contains("Armour") && !attr.EndsWith("Armour against Projectiles"))
                || attr.Contains("Evasion")
                || (attr.Contains("Energy Shield") && !attr.EndsWith("Energy Shield Recharge"))
                || attr.Contains("Weapon Class")
                || attr.Contains("Critical Strike Chance with this Weapon")
                || attr.Contains("Critical Strike Damage Multiplier with this Weapon"))
            || (item.Class == Item.ItemClass.MainHand || item.Class == Item.ItemClass.OffHand)
               && item.Keywords != null // Only weapons have keyword.
               && (attr == "#% increased Attack Speed"
                   || attr == "#% increased Accuracy Rating"
                   || attr == "+# to Accuracy Rating"
                   || attr.StartsWith("Adds ") && (attr.EndsWith(" Damage") || attr.EndsWith(" Damage in Main Hand") || attr.EndsWith(" Damage in Off Hand"))
                   || attr == "#% increased Physical Damage"
                   || attr == "#% increased Critical Strike Chance");
 }
Пример #2
0
 public static List<ItemMod> CreateMods(Item item, string attribute, Regex numberfilter)
 {
     Item.ItemClass ic = item.Class;
     var mods = new List<ItemMod>();
     var values = new List<float>();
     foreach (Match match in numberfilter.Matches(attribute))
     {
         values.Add(float.Parse(match.Value, CultureInfo.InvariantCulture));
     }
     string at = numberfilter.Replace(attribute, "#");
     if (at == "+# to all Attributes")
     {
         mods.Add(new ItemMod
         {
             itemclass = ic,
             Value = values,
             Attribute = "+# to Strength"
         });
         mods.Add(new ItemMod
         {
             itemclass = ic,
             Value = values,
             Attribute = "+# to Dexterity"
         });
         mods.Add(new ItemMod
         {
             itemclass = ic,
             Value = values,
             Attribute = "+# to Intelligence"
         });
     }
     else
     {
         mods.Add(new ItemMod
         {
             itemclass = ic,
             Value = values,
             Attribute = at,
             isLocal = DetermineLocal(item, at)
         });
     }
     return mods;
 }
Пример #3
0
        public Item(ItemClass iClass, RavenJObject val)
        {
            Attributes = new Dictionary<string, List<float>>();
            Mods = new List<ItemMod>();
            Class = iClass;

            Name = val["name"].Value<string>();
            if (Name == "")
                Name = val["typeLine"].Value<string>();
            Type = val["typeLine"].Value<string>();

            if (val.ContainsKey("properties"))
                foreach (RavenJObject obj in (RavenJArray) val["properties"])
                {
                    var values = new List<float>();
                    string s = "";

                    foreach (RavenJArray jva in (RavenJArray) obj["values"])
                    {
                        s += " " + jva[0].Value<string>();
                    }
                    s = s.TrimStart();

                    if (s == "")
                    {
                        Keywords = new List<string>();
                        string[] sl = obj["name"].Value<string>().Split(',');
                        foreach (string i in sl)
                            Keywords.Add(i.Trim());
                        continue;
                    }

                    foreach (Match m in numberfilter.Matches(s))
                    {
                        if (m.Value == "") values.Add(float.NaN);
                        else values.Add(float.Parse(m.Value, CultureInfo.InvariantCulture));
                    }
                    string cs = obj["name"].Value<string>() + ": " + (numberfilter.Replace(s, "#"));

                    Attributes.Add(cs, values);
                }
            if (val.ContainsKey("explicitMods"))
                foreach (string s in val["explicitMods"].Values<string>())
                {
                    List<ItemMod> mods = ItemMod.CreateMods(this, s.Replace("Additional ", ""), numberfilter);
                    Mods.AddRange(mods);
                }
            if (val.ContainsKey("implicitMods"))
                foreach (string s in val["implicitMods"].Values<string>())
                {
                    List<ItemMod> mods = ItemMod.CreateMods(this, s.Replace("Additional ", ""), numberfilter);
                    Mods.AddRange(mods);
                }
            if (val.ContainsKey("craftedMods"))
                foreach (string s in val["craftedMods"].Values<string>())
                {
                    List<ItemMod> mods = ItemMod.CreateMods(this, s.Replace("Additional ", ""), numberfilter);
                    Mods.AddRange(mods);
                }

            if (iClass == ItemClass.Gem)
            {
                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.ContainsKey("sockets"))
                foreach (RavenJObject obj in (RavenJArray) val["sockets"])
                {
                    Sockets.Add(obj["group"].Value<int>());
                }
            if (val.ContainsKey("socketedItems"))
            {
                int socket = 0;
                foreach (RavenJObject obj in (RavenJArray) val["socketedItems"])
                {
                    var item = new Item(ItemClass.Gem, obj);
                    item.SocketGroup = Sockets[socket++];
                    Gems.Add(item);
                }
            }
        }
Пример #4
0
        // Returns gems linked to specified gem.
        public List<Item> GetLinkedGems(Item gem)
        {
            var link = new List<Item>();

            foreach (Item linked in Gems)
                if (linked != gem && linked.SocketGroup == gem.SocketGroup)
                    link.Add(linked);

            return link;
        }
Пример #5
0
 private void AddItem(RavenJObject val, Item.ItemClass iclass)
 {
     Item item = null;
     item = new Item(iclass, val);
     Equip.Add(item);
 }