Ejemplo n.º 1
0
                // Creates added damage from weapon local mod.
                public static Added Create(DamageSource source, ItemMod itemMod)
                {
                    Match m = ReAddMod.Match(itemMod.Attribute);
                    if (m.Success)
                        return new Added(source, m.Groups[1].Value, itemMod.Value[0], itemMod.Value[1]);
                    else
                    {
                        m = ReAddInHandMod.Match(itemMod.Attribute);
                        if (m.Success)
                            return new Added(source, m.Groups[1].Value, itemMod.Value[0], itemMod.Value[1]) { Hand = m.Groups[2].Value == "Main" ? WeaponHand.Main : WeaponHand.Off };
                    }

                    return null;
                }
Ejemplo n.º 2
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);
                }
            }
        }