/// <summary> /// Whether or not this item builds into the specified item. /// </summary> public static bool BuildsInto(this ItemStatic component, ItemStatic item) { if (component.Into == null) { return(false); } // NOTE: While using item.from would be faster if it were ints, it contains strings, // so we'd have to parse them every time. The item trees aren't deep enough that // traversing into is much slower. return(component.Into.Any(i => { if (item.Id == i) { return true; } ItemStatic componentItem; if (!StaticDataStore.Items.Items.TryGetValue(i, out componentItem)) { return false; } return componentItem.BuildsInto(item); })); }
public MyItem(ItemStatic item) { ItemId = item.Id; Name = item.Name; TotalPrice = item.Gold.TotalPrice; BasePrice = item.Gold.BasePrice; ImageId = item.Image.Full; }
public ImageSource SetItemImageSource(ItemStatic item, ImageSource imageSource) { if (item != null) { return(AppConstants.SetImageSource(new Uri(AppConstants.ItemIconUrl() + item.image.full))); } else { return(null); } }
internal static void RunCorrections(ItemListStatic item) { var keys = new List <int>(item.Items.Keys); foreach (int key in keys) { ItemStatic temp = item.Items[key]; ItemCorrection(temp); } }
/// <summary> /// Gets the final build paths of this item. /// </summary> /// <param name="component"></param> public static IEnumerable <ItemStatic> FinalBuilds(this ItemStatic component) { if (component.Into == null) { return(Enumerable.Empty <ItemStatic>()); } var builds = component.Into.Select(id => StaticDataStore.Items.Items[id]); return(builds.Where(item => item.Into == null || item.Into.Count == 0).Concat( builds.SelectMany(comp => comp.FinalBuilds()) )); }
/// <summary> /// Gets all recipe components that build into this item. /// </summary> public static IEnumerable <ItemStatic> AllComponents(this ItemStatic item) { if (item.From == null) { return(Enumerable.Empty <ItemStatic>()); } var baseItems = item.From.Select(strid => { int o; return(int.TryParse(strid, out o) ? o : -1); }) .Where(i => i != -1) .Select(i => StaticDataStore.Items.Items[i]); return(baseItems.Concat(baseItems.SelectMany(i => i.AllComponents()))); }
/// <summary> /// Whether or not this item builds into the specified item. /// </summary> public static bool BuildsInto(this ItemStatic component, ItemStatic item) { if (component.Into == null) return false; // NOTE: While using item.from would be faster if it were ints, it contains strings, // so we'd have to parse them every time. The item trees aren't deep enough that // traversing into is much slower. return component.Into.Any(i => { if (item.Id == i) return true; ItemStatic componentItem; if (!StaticDataStore.Items.Items.TryGetValue(i, out componentItem)) { return false; } return componentItem.BuildsInto(item); }); }
private void SortRiotItemData(ItemListStatic items) { itemGold_Names.Clear(); //Sort items by price foreach (System.Collections.Generic.KeyValuePair <int, RiotSharp.StaticDataEndpoint.ItemStatic> i in items.Items) { //Removes rengar upgraded trinket from cluttering the Item list, the base rengar tricket desciption has all information needed if (!(i.Value.Gold.Purchasable == false && i.Value.RequiredChampion == "Rengar")) { //Removes the explorer ward from the item list, it might have been available in the past but it doesn't matter much. Same with golden transcendence if (i.Value.Name != "Explorer's Ward" && i.Value.Name != "Golden Transcendence") { //Remove the duplicate free Buiscuit that used to be obtained from mastery, either way this item doesn't matter much if (!(i.Value.Name == "Total Biscuit of Rejuvenation" && i.Value.Gold.TotalPrice == 0)) { //Add Stealth Detection tag where i think it is missing if (i.Value.Description.Contains("Vision Ward")) { if (i.Value.Tags == null) { i.Value.Tags.Add("Stealth"); } else if (!i.Value.Tags.Contains("Stealth")) { i.Value.Tags.Add("Stealth"); } } itemGold_Names.Add(new KeyValuePair <int, int>(i.Value.Id, i.Value.Gold.TotalPrice)); } } } } itemGold_Names.Sort(Compare2); itemsPrepared.Clear(); //Loop through all sorted item names and store item data foreach (var item in itemGold_Names) { ItemStatic i = items.Items[item.Key]; int enchantBaseId = 0; ItemStatic enchantBaseItem; CreateItemDiv newItem = new CreateItemDiv(); if (i.Name.Contains("Enchantment:") && i.From != null) //todo: added && i.From != null { enchantBaseId = Convert.ToInt16(i.From[0]); items.Items.TryGetValue(enchantBaseId, out enchantBaseItem); newItem.SetupItemInformation(i, items.Version, enchantBaseItem); } else { newItem.SetupItemInformation(i, items.Version); } itemsPrepared.Add(newItem); } ItemDataCorrections.RunCorrections(items); version = items.Version; }
public async void RetrieveStaticItemTest() { ItemStatic trinityForce = await creepScore.RetrieveItemData(CreepScore.Region.NA, 3078, StaticDataConstants.ItemListData.None); Assert.Equal("Tons of Damage", trinityForce.plainText); }
private static PurchaseSet getRushItem(List <ItemStatic> items, List <ItemStatic> alreadyOwnedItems) { ItemStatic RushItem = items.FirstOrDefault(x => x.From != null && (x.Into == null || x.Into.Count == 1 && getItem(x.Into.First()).SpecialRecipe != 0) && x.Gold.TotalPrice > 300); if (RushItem == null) { return(null); } var possibleComponents = items.GetRange(0, items.IndexOf(RushItem)); var buildOrder = possibleComponents.Where(x => RushItem.From.Contains(x.Id.ToString())).ToList(); PurchaseSet set = new PurchaseSet() { Name = "Rush " + RushItem.Name, RecMath = true }; foreach (var item in buildOrder) { set.Items.Add(item); set.TotalCost += item.Gold.TotalPrice; } foreach (var from in RushItem.From.ToList()) { if (!set.Items.Any(x => x.Id.ToString() == from)) { var item = getItem(from); set.Items.Add(item); set.TotalCost += item.Gold.TotalPrice; } } var componentTree = RushItem.From.ToList(); while (componentTree.Any()) { var item = getItem(componentTree[0]); componentTree.RemoveAt(0); var dupe = alreadyOwnedItems.FirstOrDefault(x => x.Id == item.Id); if (dupe is ItemStatic) { alreadyOwnedItems.Remove(alreadyOwnedItems.First(x => x.Id == dupe.Id)); if (set.Items.Any(x => x.Id == dupe.Id)) { set.Items.Remove(set.Items.First(x => x.Id == dupe.Id)); } set.TotalCost -= dupe.Gold.TotalPrice; } else { if (item.From != null) { foreach (var key in item.From) { componentTree.Add(key); } } } } set.Items.Add(RushItem); if (RushItem.Into != null && RushItem.Into.Count == 1 && getItem(RushItem.Into.First()).SpecialRecipe != 0) { set.Items.Add(getItem(RushItem.Into.First())); } set.TotalCost += RushItem.Gold.BasePrice; set.Name = set.Name + " (" + set.TotalCost + " gold)"; return(set); }
public ItemDialog(ItemStatic item) : this() { Item = item; }
public ItemListElement(ItemStatic item) { Item = item; ItemName = item.Name; }
public ItemStaticWrapper(ItemStatic item, Language language, ItemData itemData) { ItemStatic = item; Language = language; ItemData = itemData; }
/// <summary> /// Loads a new prototype world. /// </summary> /// <param name="instantiate">Whether to also instantiate all loaded prototypes</param> /// <param name="basePath">The location of the world to load</param> /// <remarks>If this is called on a world that has already been loaded, it will be wiped from the cache and reloaded.</remarks> public World LoadWorld(bool instantiate, string basePath = null) { // Remove the current world from the prototype cache in case it is being reloaded DataAccess.Remove <World>(Prototype, CacheType.Prototype); World newWorld = new World { IsLoading = true, CacheType = CacheType.Prototype }; newWorld.Areas.CacheType = CacheType.Prototype; // Set read path if (basePath == "" || basePath == null) { basePath = DataPersistence.PersistencePath; } if (!basePath.EndsWith(@"\")) { basePath += @"\"; } string[] world; try { world = Directory.GetFiles(basePath + typeof(World).ToString(), @"*.json"); } catch { // No world was found in the filesystem newWorld = NewPrototype(); newWorld.IsLoading = true; world = Directory.GetFiles(basePath + typeof(World).ToString(), @"*.json"); } var areas = new string[0]; var rooms = new string[0]; var containers = new string[0]; var mobs = new string[0]; var potions = new string[0]; var statics = new string[0]; var weapons = new string[0]; if (Directory.Exists(basePath + typeof(Area).ToString())) { areas = Directory.GetFiles(basePath + typeof(Area).ToString(), @"*.json"); } if (Directory.Exists(basePath + typeof(Room).ToString())) { rooms = Directory.GetFiles(basePath + typeof(Room).ToString(), @"*.json"); } if (Directory.Exists(basePath + typeof(EntityContainer).ToString())) { containers = Directory.GetFiles(basePath + typeof(EntityContainer).ToString(), @"*.json"); } if (Directory.Exists(basePath + typeof(Mob).ToString())) { mobs = Directory.GetFiles(basePath + typeof(Mob).ToString(), @"*.json"); } if (Directory.Exists(basePath + typeof(ItemPotion).ToString())) { potions = Directory.GetFiles(basePath + typeof(ItemPotion).ToString(), @"*.json"); } if (Directory.Exists(basePath + typeof(ItemStatic).ToString())) { statics = Directory.GetFiles(basePath + typeof(ItemStatic).ToString(), @"*.json"); } if (Directory.Exists(basePath + typeof(ItemWeapon).ToString())) { weapons = Directory.GetFiles(basePath + typeof(ItemWeapon).ToString(), @"*.json"); } // Load containers foreach (var container in containers) { // Add container prototype var newContainer = new EntityContainer(); DataPersistence.LoadObject(container, out newContainer); newWorld.WorldLoaded += newContainer.World_HandleLoaded; // Add to cache try { DataAccess.Add <EntityContainer>(newContainer, CacheType.Prototype, newContainer.Prototype, false); } catch (ArgumentException ex) { // The container was already added to the cache as a result of creating a new world continue; } } // Load world foreach (var w in world) { DataPersistence.LoadObject(w, out newWorld); try { DataAccess.Add <World>(newWorld, CacheType.Prototype, newWorld.Prototype, false); } catch (ArgumentException ex) { // The world was already added to the cache as a result of creating a new world continue; } } // Load rooms foreach (var room in rooms) { // Add room prototype var newRoom = new Room(); DataPersistence.LoadObject(room, out newRoom); // Add to cache DataAccess.Add <Room>(newRoom, CacheType.Prototype, newRoom.Prototype, false); } // Load areas foreach (var area in areas) { // Add area prototype var newArea = new Area(); DataPersistence.LoadObject(area, out newArea); // Add to cache DataAccess.Add <Area>(newArea, CacheType.Prototype, newArea.Prototype, false); } // Load mobs foreach (var mob in mobs) { var newMob = new Mob(); DataPersistence.LoadObject(mob, out newMob); // Add to cache DataAccess.Add <Mob>(newMob, CacheType.Prototype, newMob.Prototype, false); } // Load items foreach (var item in statics) { var newItem = new ItemStatic(); DataPersistence.LoadObject(item, out newItem); // Add to cache DataAccess.Add <ItemStatic>(newItem, CacheType.Prototype, newItem.Prototype, false); } // Load potions foreach (var item in potions) { var newPotion = new ItemPotion(); DataPersistence.LoadObject(item, out newPotion); // Add to cache DataAccess.Add <ItemStatic>(newPotion, CacheType.Prototype, newPotion.Prototype, false); } // Load weapons foreach (var weapon in weapons) { var newWeapon = new ItemWeapon(); DataPersistence.LoadObject(weapon, out newWeapon); // Add to cache DataAccess.Add <ItemWeapon>(newWeapon, CacheType.Prototype, newWeapon.Prototype, false); } // Add entities to containers // OnWorldLoaded(new EventArgs()); // Fix prototype null exits RoomExits.FixNullExits(CacheType.Prototype); newWorld.IsLoading = false; if (instantiate) { Logger.Info(nameof(World), nameof(LoadWorld), "Instantiating world."); newWorld = newWorld.SpawnAsObject <World>(instantiate, 0); Logger.Info(nameof(World), nameof(LoadWorld), "Finished instantiating world."); } return(newWorld); }
private static void ItemCorrection(ItemStatic temp) { string descriptionMain; List <string> uniqueDescriptions = new List <string>(); if (temp.SanitizedDescription.Contains("UNIQUE")) { descriptionMain = SubstringExtensions.Before(temp.SanitizedDescription, "UNIQUE"); int i = 0; while ((i = temp.Description.IndexOf("UNIQUE", i)) != -1) { int j = temp.Description.IndexOf("<br>", i); if (j == -1) { j = temp.Description.Length; } string uniqueDescription = temp.Description.Substring(i, j - i); if (!uniqueDescription.Contains("UNIQUE Active") && //Todo: All of these should instead of being ignored should be filtered on the Stats Tab and Activatable Items or On/Off !uniqueDescription.Contains("UNIQUE Passive - Point Runner:") && !uniqueDescription.Contains("UNIQUE Passive - Furor:") && !uniqueDescription.Contains("UNIQUE Passive - Captain:") && !uniqueDescription.Contains("UNIQUE Passive - Spellblade:") && !uniqueDescription.Contains("Falling below 50% Health grants")) { uniqueDescriptions.Add(uniqueDescription); } i++; } } else { descriptionMain = temp.SanitizedDescription; } StatCorrection(descriptionMain, temp.Stats); int ind = 0; temp.UniqueStats = new List <KeyValuePair <string, StatsStatic> >(); foreach (string s in uniqueDescriptions) { if (s.Contains("UNIQUE Passive:") || s.Contains("UNIQUE Aura:")) { if (temp.Name.Contains("Ionia")) { string tempNametest = SubstringExtensions.Before(temp.Name, " - "); } else { string tempNametest = temp.Name; } string tempName = (temp.Name.Contains(" - ")) ? SubstringExtensions.Before(temp.Name, " - ") : temp.Name; temp.UniqueStats.Add(new KeyValuePair <string, StatsStatic>(tempName + "~" + s, new StatsStatic())); } else if (s.Contains("UNIQUE Passive - Enhanced Movement")) { temp.UniqueStats.Add(new KeyValuePair <string, StatsStatic>(SubstringExtensions.Before(s, ":"), new StatsStatic())); temp.UniqueStats[ind].Value.FlatMovementSpeedMod = temp.Stats.FlatMovementSpeedMod; temp.Stats.FlatMovementSpeedMod = 0.0; } else { temp.UniqueStats.Add(new KeyValuePair <string, StatsStatic>(SubstringExtensions.Before(s, ":"), new StatsStatic())); } StatCorrection(s, temp.UniqueStats[ind].Value); ind++; } }
public void SetupItemInformation(ItemStatic inputItem, string version, ItemStatic enchantBaseItem = null) { thisVersion = version; thisID = inputItem.Id; //Filter Out Items if (inputItem.Name.Contains("Enchantment:")) { filteredOut = true; } if (inputItem.Gold.Purchasable == false) { filteredOut = true; } if (inputItem.Name.Contains("Bonetooth Necklace")) { filteredOut = true; } // store tags for this item if (inputItem.Tags != null) { foreach (string tag in inputItem.Tags) { thisTags += " " + tag; } if (!inputItem.Tags.Contains("stealth") && (inputItem.Name.Contains("Greater Vision Totem") || inputItem.Name.Contains("Oracle's Lens"))) { thisTags += " " + "Stealth"; } if (!inputItem.Tags.Contains("stealth") && (inputItem.Description.Contains("stealth-detecting"))) { thisTags += " " + "Stealth"; } } if (thisTags == null) { //If there are no tags then store this information thisTags += " " + "noTag"; } //Select the appropriate image for the item string imageUrl = string.Format(@"http://ddragon.leagueoflegends.com/cdn/{0}/img/sprite/item0.png", thisVersion);; switch (inputItem.Image.Sprite) { case "item0.png": imageUrl = string.Format(@"http://ddragon.leagueoflegends.com/cdn/{0}/img/sprite/item0.png", thisVersion); break; case "item1.png": imageUrl = string.Format(@"http://ddragon.leagueoflegends.com/cdn/{0}/img/sprite/item1.png", thisVersion);; break; case "item2.png": imageUrl = string.Format(@"http://ddragon.leagueoflegends.com/cdn/{0}/img/sprite/item2.png", thisVersion);; break; } //Fix enchantment description and name thisItemDisplayName = inputItem.Name; string ItemDesc = inputItem.Description.ToString(); if (enchantBaseItem != null) { if (enchantBaseItem.Tags.Contains("Boots")) { ItemDesc = enchantBaseItem.Description + "<br/><br/>" + ItemDesc; } else { ItemDesc += "<br/><br/>" + enchantBaseItem.Description; } //Todo, inputItem.Description = ItemDesc; inputItem.Name = enchantBaseItem.Name + " - " + thisItemDisplayName.After("Enchantment: "); thisItemDisplayName = enchantBaseItem.Name + " - " + thisItemDisplayName.After("Enchantment: "); } //Update description to include if requires a champion or if requires a map if (inputItem.RequiredChampion != null) { ItemDesc += string.Format(@"<br/><br/> <font color=""#780000""> This item is only available on {0} </font>", inputItem.RequiredChampion); } if (inputItem.Maps != null) { string tempDescMaps = ""; foreach (KeyValuePair <string, bool> map in inputItem.Maps) { if (map.Value == false) { string mapName = ""; foreach (KeyValuePair <string, string> mapID in PublicStaticVariables.StaticMapIDNames) { if (mapID.Key == map.Key) { mapName = mapID.Value; } } tempDescMaps += string.Format(@" {0} <br/>", mapName); } } if (tempDescMaps != "") { tempDescMaps = tempDescMaps.Substring(0, tempDescMaps.Length - 6); ItemDesc += "<br/><br/> <font color=\"#B69B30\"> This item is not available on the following maps: <br/>" + tempDescMaps + "</font>"; } } //Stores the new Item Description while (ItemDesc.EndsWith("<br/>") || ItemDesc.EndsWith("<br>")) { if (ItemDesc.EndsWith("<br/>")) { ItemDesc = ItemDesc.Substring(0, ItemDesc.Length - 5); } else { ItemDesc = ItemDesc.Substring(0, ItemDesc.Length - 4); } } NewDesc = ItemDesc + "<br/>"; //Only actually render the item if it has not been filtered out string ItemID = "Item" + inputItem.Id; //This section is the item image. A border around the image can be added by adding a border style to the div below. string divOfItem = string.Format(@" <span class=""tooltipWrapper{0}""> <a href=""#"" class=""tooltip""> <div ID=""{2}"" onmouseover=""OnHoverDiv('{1}')"" class=""itemImage"" style=""background-image: url('{3}'); background-position: -{4}px -{5}px;""> </div>" , thisTags //0 , inputItem.Id //1 , ItemID //2 , imageUrl //3 , inputItem.Image.X //4 , inputItem.Image.Y //5 ); //This section is the tooltip image and information. tooltipOfItem = string.Format(@" <span class=""itemToolTip""> <div class=""itemImage"" style=""background-image: url('{0}'); background-position: -{1}px -{2}px;""> </div> <div class=""itemToolTipSpacer""> </div> <span class=""itemToolTipTitle"">{3}</span> <br/> <br /> Cost: <span class=""itemToolTipGold"">{4}</span> <br /> <br /> {5} </i></i></i> </span>" //Note: The </i></i></i> above is a percaution because I found unclosed <i> in Descriptions that broke everything if not closed. , imageUrl //0 , inputItem.Image.X //1 , inputItem.Image.Y //2 , thisItemDisplayName //3 , inputItem.Gold.TotalPrice.ToString() //4 , ItemDesc //5 ); string tempDescription = NewDesc; tempDescription = tempDescription.Replace("<consumable>", "<span style='color:#CC3300;'>"); //"<font color='#CC3300'>"); //dark-ish red tempDescription = tempDescription.Replace("</consumable>", "</span>"); //"</font>"); tempDescription = tempDescription.Replace("<groupLimit>", "<span style='color:#FFFFFF;'>"); //"<font color='#FFFFFF'>"); //white tempDescription = tempDescription.Replace("</groupLimit>", "</span>"); //"</font>"); tempDescription = tempDescription.Replace("<stats>", "<span style='color:#66FF99;'>"); //"<font color='#66FF99'>"); //Light green tempDescription = tempDescription.Replace("</stats>", "</span>"); //"</font>"); tempDescription = tempDescription.Replace("<unique>", "<span style='color:#E6E600;'>"); //dull yellow tempDescription = tempDescription.Replace("</unique>", "</span>"); tempDescription = tempDescription.Replace("<active>", "<span style='color:#E6E600;'>"); //dull yellow tempDescription = tempDescription.Replace("</active>", "</span>"); tempDescription = tempDescription.Replace("<passive>", "<span style='color:#E6E600;'>"); //dull yellow tempDescription = tempDescription.Replace("</passive>", "</span>"); tempDescription = tempDescription.Replace("<aura>", "<span style='color:#E6E600;'>"); //dull yellow tempDescription = tempDescription.Replace("</aura>", "</span>"); tempDescription = tempDescription.Replace("<mana>", ""); tempDescription = tempDescription.Replace("</mana>", ""); if (Regex.Matches(tempDescription, "<span>").Count != Regex.Matches(tempDescription, "</span>").Count) { tempDescription = SpanFixer(tempDescription); } //Fix all of Riot's ill-formaed html tempDescription = tempDescription.Replace("<br>", "<br/>"); int iCount = Regex.Matches(tempDescription, "<i>").Count; while (Regex.Matches(tempDescription, "</i>").Count < iCount) { tempDescription += "</i>"; } if (Regex.Matches(tempDescription, "</i>").Count > iCount) { tempDescription = SubstringExtensions.ReplaceLastOccurrence(tempDescription, "</i>", ""); } //This had to be done on one line or else it causes problems htmlToolTipOfItem = string.Format(@"<html><head></head><body>{0}</body></html>", tempDescription); DivText = StringExtensions.BrWrapper(tempDescription); aItem = inputItem; }
public static void AttachStatic(Battle b) { instance = b; SpecialStatic.AttachStatic(); ItemStatic.AttachStatic(); }