Esempio n. 1
0
 /// <summary>
 /// Show list to console.
 /// </summary>
 static void Show(IEnumerable <Spell> list)
 {
     foreach (Spell spell in list)
     {
         Console.WriteLine(spell);
         foreach (string s in spell.Details())
         {
             Console.WriteLine(cache.InsertRefNames(s));
         }
         if (!String.IsNullOrEmpty(spell.Desc))
         {
             Console.WriteLine(spell.Desc);
         }
         Console.WriteLine();
     }
 }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var path   = LaunchpadManifest.SPELL_FILE;
            var format = "text";

            try
            {
                int dec = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalDigits;
                if (dec < 2)
                {
                    Console.Error.WriteLine("Your system has been configured to display {0} decimal digits. Some values will be rounded.", dec);
                }

                if (args.Length == 0)
                {
                    Console.Error.WriteLine("You must include a search parameter on the command-line.");
                    Console.Error.WriteLine("e.g. to dump all spells try: parser all");
                    Thread.Sleep(2000);
                    return;
                }

                if (args[0] == "update")
                {
                    var server = args.Length >= 2 ? args[1] : null;
                    LaunchpadPatcher.DownloadSpellFiles(server);
                    return;
                }

                if (args.Any(x => x == "csv"))
                {
                    format = "csv";
                }

                if (File.Exists(args[0]))
                {
                    path    = args[0];
                    args[0] = "all";
                }

                if (!File.Exists(path))
                {
                    LaunchpadPatcher.DownloadSpellFiles();
                }

                Console.Error.Write("Loading {0}... ", path);
                cache = new SpellCache();
                cache.LoadSpells(path);
                Console.Error.WriteLine("{0} spells", cache.SpellList.Count());

                // perform search based on command line parameters
                var type  = args.Length >= 1 ? args[0].ToLower() : null;
                var value = args.Length >= 2 ? args[1] : null;
                Console.Error.Write("Searching for {0} {1}... ", type, value);
                var results = Search(type, value);

                if (results != null)
                {
                    Console.Error.WriteLine("{0} results", results.Count);
                    Console.Error.WriteLine();
                    cache.AddForwardRefs(results);

                    if (format == "csv")
                    {
                        SpellWriter.ToCsv(results, s => Console.Out.WriteLine(cache.InsertRefNames(s)));
                    }
                    else
                    {
                        SpellWriter.ToText(results, Console.Out.WriteLine);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex);
            }
        }