Beispiel #1
0
        public static void InsertExtraChampData(champions Champ)
        {
            string champJSON = File.ReadAllText(Path.Combine(Client.ExecutingDirectory, "Assets", "data", "en_US", "champion", Champ.name + ".json"));
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            Dictionary<string, object> deserializedJSON = serializer.Deserialize<Dictionary<string, object>>(champJSON);
            Dictionary<string, object> temp = deserializedJSON["data"] as Dictionary<string, object>;
            Dictionary<string, object> champData = temp[Champ.name] as Dictionary<string, object>;

            Champ.Lore = champData["lore"] as string;
            Champ.ResourceType = champData["partype"] as string;
            Champ.Skins = champData["skins"] as ArrayList;
            ArrayList Spells = (ArrayList)champData["spells"];
            Champ.Spells = new List<Spell>();

            foreach (Dictionary<string, object> champSpells in Spells)
            {
                Spell NewSpell = new Spell();
                NewSpell.ID = champSpells["id"] as string;
                NewSpell.Name = champSpells["name"] as string;
                NewSpell.Description = champSpells["description"] as string;
                NewSpell.Tooltip = champSpells["tooltip"] as string;
                NewSpell.MaxRank = champSpells["maxrank"] as string;

                Champ.Spells.Add(NewSpell);
            }
        }
Beispiel #2
0
        public static void InsertExtraChampData(champions Champ)
        {
            string champJSON = File.ReadAllText(Path.Combine(Client.ExecutingDirectory, "Assets", "data", "en_US", "champion", Champ.name + ".json"));
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            Dictionary<string, object> deserializedJSON = serializer.Deserialize<Dictionary<string, object>>(champJSON);
            Dictionary<string, object> temp = deserializedJSON["data"] as Dictionary<string, object>;
            Dictionary<string, object> champData = temp[Champ.name] as Dictionary<string, object>;

            Champ.Lore = champData["lore"] as string;
            Champ.ResourceType = champData["partype"] as string;
            Champ.Skins = champData["skins"] as ArrayList;
            ArrayList Spells = (ArrayList)champData["spells"];
            Champ.Spells = new List<Spell>();

            foreach (Dictionary<string, object> champSpells in Spells)
            {
                Spell NewSpell = new Spell();
                NewSpell.ID = champSpells["id"] as string;
                NewSpell.Name = champSpells["name"] as string;
                NewSpell.Description = champSpells["description"] as string;
                NewSpell.Tooltip = champSpells["tooltip"] as string;
                NewSpell.MaxRank = (int)champSpells["maxrank"];
                Dictionary<string, object> Image = (Dictionary<string, object>)champSpells["image"];
                NewSpell.Image = Image["full"] as string;
                foreach (Dictionary<string, object> x in (ArrayList)champSpells["vars"])
                {
                    string Type = x["link"] as string;
                    Type = Type.Replace("spelldamage", "Ability Power");
                    Type = Type.Replace("bonusattackdamage", "Bonus Attack Damage");
                    Type = Type.Replace("attackdamage", "Total Attack Damage");
                    Type = Type.Replace("armor", "Armor");
                    NewSpell.Tooltip = NewSpell.Tooltip.Replace("{{ " + x["key"] + " }}", Convert.ToString(x["coeff"]) + " " + Type);
                }

                int i = 0;
                foreach (ArrayList x in (ArrayList)champSpells["effect"])
                {
                    string Scaling = "";
                    if (x == null)
                        continue;

                    foreach (var y in x)
                        Scaling += y + "/";

                    Scaling = Scaling.Substring(0, Scaling.Length - 1);

                    i++;
                    NewSpell.Tooltip = NewSpell.Tooltip.Replace("{{ e" + i + " }}", Scaling);
                }

                NewSpell.Tooltip = NewSpell.Tooltip.Replace("<br>", Environment.NewLine);
                NewSpell.Tooltip = Regex.Replace(NewSpell.Tooltip, "<.*?>", string.Empty);

                Champ.Spells.Add(NewSpell);
            }
        }
Beispiel #3
0
        public static void InsertExtraChampData(champions champ)
        {
            var champJson =
                File.ReadAllText(Path.Combine(Client.ExecutingDirectory, "Assets", "data", "en_US", "champion",
                    champ.name + ".json"));

            var serializer = new JavaScriptSerializer();
            var deserializedJson = serializer.Deserialize<Dictionary<string, object>>(champJson);
            //Dictionary<string, object> deserializedJSON = JsonConvert.DeserializeObject<Dictionary<string, object>>(champJSON);
            var temp = deserializedJson["data"] as Dictionary<string, object>;
            if (temp == null)
                return;

            var champData = temp[champ.name] as Dictionary<string, object>;
            //Dictionary<string, object> champData = serializer.Deserialize<Dictionary<string, object>>(temp2);
            if (champData == null)
                return;

            champ.Lore = champData["lore"] as string;
            champ.ResourceType = champData["partype"] as string;
            champ.Skins = champData["skins"] as ArrayList;
            var spells = (ArrayList) champData["spells"];
            champ.Spells = new List<Spell>();

            foreach (Dictionary<string, object> champSpells in spells)
            {
                var newSpell = new Spell
                {
                    ID = champSpells["id"] as string,
                    Name = champSpells["name"] as string,
                    Description = champSpells["description"] as string,
                    Tooltip = champSpells["tooltip"] as string,
                    MaxRank = (int) champSpells["maxrank"]
                };

                var image = (Dictionary<string, object>) champSpells["image"];
                newSpell.Image = image["full"] as string;
                foreach (Dictionary<string, object> x in (ArrayList) champSpells["vars"])
                {
                    var type = x["link"] as string;
                    if (type == null)
                        continue;

                    type = type.Replace("spelldamage", "Ability Power");
                    type = type.Replace("bonusattackdamage", "Bonus Attack Damage");
                    type = type.Replace("attackdamage", "Total Attack Damage");
                    type = type.Replace("armor", "Armor");
                    newSpell.Tooltip = newSpell.Tooltip.Replace("{{ " + x["key"] + " }}",
                        Convert.ToString(x["coeff"]) + " " + type);
                }

                var i = 0;
                foreach (var scaling in from ArrayList x in (ArrayList) champSpells["effect"]
                    where x != null
                    select x.Cast<object>().Aggregate("", (current, y) => current + (y + "/"))
                    into scaling
                    select scaling.Substring(0, scaling.Length - 1))
                {
                    i++;
                    newSpell.Tooltip = newSpell.Tooltip.Replace("{{ e" + i + " }}", scaling);
                }

                newSpell.Tooltip = newSpell.Tooltip.Replace("<br>", Environment.NewLine);
                newSpell.Tooltip = Regex.Replace(newSpell.Tooltip, "<.*?>", string.Empty);

                champ.Spells.Add(newSpell);
            }
        }