/// <summary>Get an Item by display name.</summary> /// <param name="localizedName">Localized display name (the one that appears in-game).</param> /// <param name="fuzzy">Perform a fuzzy search if true, otherwise only return an Item with the exact name.</param> public Item?GetItem(string localizedName, bool fuzzy = false) { localizedName = localizedName.Trim().ToLowerInvariant(); if (_tools.ContainsKey(localizedName)) { return(ToolHelper.GetToolFromDescription(_tools[localizedName].index, _tools[localizedName].upgradeLevel)); } else if (GetValue(_items, localizedName, fuzzy) is string item) { return(Utility.getItemFromStandardTextDescription(item, null)); } return(null); }
private static IDictionary <string, ToolDescription> CreateToolMap() { IDictionary <string, ToolDescription> map = new Dictionary <string, ToolDescription>(); Tool[] tools = { new Axe(), new Hoe(), new Pickaxe(), new WateringCan(), new FishingRod(), new Pan(), new Shears(), new MilkPail(), new Wand() }; foreach (Tool tool in tools) { int maxLevel = 0; switch (tool.GetType().Name) { case nameof(Axe): case nameof(Hoe): case nameof(Pickaxe): case nameof(WateringCan): maxLevel = Tool.iridium; break; case nameof(FishingRod): maxLevel = 3; break; } for (int level = 0; level <= maxLevel; level++) { tool.UpgradeLevel = level; map[tool.DisplayName.ToLowerInvariant()] = ToolHelper.GetToolDescription(tool); } } return(map); }