Example #1
0
        private static void SearchItemCharacterAttributes()
        {
            PrintColor.InfoLine("{f:Black}{b:Gray}Search for an item or attribute name{r} or {f:Black}{b:Gray}Enter an item's exact name to view its attributes{r}");

            // Get User Input
            PrintColor.Info("Search Term: ");
            string search_phrase = Console.ReadLine();

            // Go Back if User Enters Blank or Spaces
            if (Regex.Replace(search_phrase, @"\s*", "") == "")
            {
                PrintColor.InfoLine("Invalid entry. Canceling Search.");
                return;
            }

            // Blank Separator Line
            PrintColor.InfoLine("");

            /* Item Names */
            // Get Results
            string[] item_results = Search.Simple(ItemDatabase.List, search_phrase);

            // Show Results
            PrintColor.InfoLine("Item results for {b:White}{f:Black} " + search_phrase + " {r}");
            foreach (string item in item_results)
            {
                PrintColor.InfoLine("\t" + item);
                if (search_phrase.ToUpper() == item.ToUpper())
                {
                    Dictionary <string, string> attributes = ItemDatabase.Attributes(item);
                    foreach (string key in attributes.Keys)
                    {
                        PrintColor.InfoLine("\t    \"" + key + "\" " + attributes[key] + "");
                    }

                    if (attributes.Keys.Count == 0)
                    {
                        PrintColor.InfoLine("\t    No Usable Item Attributes Found.");
                    }
                }
            }

            // No Items Found
            if (item_results.Count() == 0)
            {
                PrintColor.InfoLine("\tNo Items Found.");
            }

            // Blank Separator Line
            PrintColor.Info("\n");

            /* Item/Char Attributes */
            // Get Results
            string[] att_results = Search.Simple(AttributeDatabase.Keys, search_phrase);

            // Show Results
            PrintColor.InfoLine("Attribute results for {b:White}{f:Black} " + search_phrase + " {r}");
            foreach (string attribute in att_results)
            {
                PrintColor.InfoLine("\t" + attribute);
            }

            // No Attributes Found
            if (att_results.Count() == 0)
            {
                PrintColor.InfoLine("\tNo Attributes Found.");
            }
        }