示例#1
0
        static void searchReagents(String searchString, bool strict)
        {
            Reagent r = findReagent(searchString, strict);

            if (r.name != "")
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine($"{r}");
                Console.ResetColor();
            }
        }
示例#2
0
        static Reagent findReagent(String searchString, bool strict)
        {
            Reagent returnReagent = new Reagent();

            foreach (Reagent r in reagentList)
            {
                if (strict ? r.id.Equals(searchString) : r.name.IndexOf(searchString, StringComparison.OrdinalIgnoreCase) >= 0 || r.description.IndexOf(searchString, StringComparison.OrdinalIgnoreCase) >= 0 || r.id.IndexOf(searchString, StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    returnReagent = r;
                }
            }
            return(returnReagent);
        }
示例#3
0
        public string Short()
        {
            String builder = $"{Reagent.Trim(id)} - {Reagent.Trim(name)}, Results: ";

            foreach (KeyValuePair <String, int> x in results)
            {
                builder += $"{Reagent.Trim(x.Key)} - {x.Value}, ";
            }
            builder += $"; Ingredients: ";
            foreach (KeyValuePair <String, int> x in ingredients)
            {
                builder += $"{Reagent.Trim(x.Key)} - {x.Value}, ";
            }
            if (tempNeeded > 0)
            {
                builder += $"; temp: {tempNeeded}";
            }
            return(builder);
        }
示例#4
0
        static void search(String searchString, String prefix, int depth, int maxDepth, bool strict)
        {
            depth++;
            if (depth > maxDepth)
            {
                return;
            }
            bool found = false;

            // let's check that it's not a reagent you can just get in the chemistry dispenser first
            foreach (Reagent r in chemDispenser)
            {
                if (strict ? r.id.Equals(searchString) : r.name.IndexOf(searchString, StringComparison.OrdinalIgnoreCase) >= 0 || r.id.IndexOf(searchString, StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    /*Console.ForegroundColor = ConsoleColor.Red;
                     * Console.WriteLine($"{prefix}{r}");
                     * Console.ResetColor();*/

                    // let's not bother printing the elements if they're in the chem dispenser
                    if (r.upgradeTier <= 1)
                    {
                        return;
                    }
                    // however if they are in a higher tier, let's state that it's availble, but also provide sub recipies
                    Console.ForegroundColor = colorTree[depth];
                    Console.WriteLine($"{prefix}\t\t{Reagent.Trim(searchString)} is available in a {r.upgradeTier} tier dispenser");
                    Console.ResetColor();
                }
            }

            foreach (Recipe r in recipeList)
            {
                if (strict ? r.id.Equals(searchString) : r.name.IndexOf(searchString, StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    // matches a recipe by name
                    Reagent recipe_reagent;
                    if (r.results.Count < 1)
                    {
                        recipe_reagent = new SS13_Chemistry.Reagent();
                    }
                    else
                    {
                        recipe_reagent = findReagent(r.results.First().Key, strict);
                    }
                    Console.ForegroundColor = colorTree[depth];
                    Console.WriteLine($"{prefix}{r.Short()}" + ((depth > 1 || string.IsNullOrWhiteSpace(recipe_reagent.description)) ? "" : $" || Description: {recipe_reagent.description}"));
                    searchSubResults(r, depth, maxDepth);
                    found = true;
                }
                else
                {
                    foreach (KeyValuePair <String, int> result in r.results)
                    {
                        if (strict ? result.Key.Equals(searchString) : result.Key.IndexOf(searchString, StringComparison.OrdinalIgnoreCase) >= 0)  // matches a recipe by product
                        {
                            Console.ForegroundColor = colorTree[depth];
                            Console.WriteLine($"{prefix}{r}");
                            searchSubResults(r, depth, maxDepth);
                            found = true;
                        }
                    }
                }
            }
            if (!found && depth < 2)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                searchReagents(searchString, strict); // match reagent
            }
            Console.ResetColor();
        }