Пример #1
0
        /// <summary>
        /// Search spells and save to [Results]
        /// </summary>
        public void Search()
        {
            AutoSearch.Enabled = false;

            var filter = GetFilter();

            Results = Cache.Search(filter);
            int cls = SpellParser.ParseClass(SearchClass.Text) - 1;

            // optionally add back refs
            if (filter.AddBackRefs)
            {
                Cache.AddBackRefs(Results);
            }
            else
            {
                Results.RemoveAll(x => x.Levels[cls] == 0);     //removes references to spells with level 0 which are effects of other spells.
            }
            // remove excluded ranks (this should be done after back refs are added)
            if (filter.Ranks == "Unranked")
            {
                Results.RemoveAll(x => x.Rank != 0);
            }
            if (filter.Ranks == "Rank 1")
            {
                Results.RemoveAll(x => x.Rank != 1);
            }
            if (filter.Ranks == "Rank 2")
            {
                Results.RemoveAll(x => x.Rank != 2);
            }
            if (filter.Ranks == "Rank 3")
            {
                Results.RemoveAll(x => x.Rank != 3);
            }
            if (filter.Ranks == "Unranked + Rank 1")
            {
                Results.RemoveAll(x => x.Rank != 0 && x.Rank != 1);
            }
            if (filter.Ranks == "Unranked + Rank 2")
            {
                Results.RemoveAll(x => x.Rank != 0 && x.Rank != 2);
            }
            if (filter.Ranks == "Unranked + Rank 3")
            {
                Results.RemoveAll(x => x.Rank != 0 && x.Rank != 3);
            }

            // hide anything that isn't in the results yet. additional spells will only be shown when a link is clicked
            VisibleResults = new HashSet <int>(Results.Select(x => x.ID));

            // if we are filtering by class then auto hide all spells that aren't castable by that class
            //int i = SpellParser.ParseClass(filter.Class) - 1;
            //VisibleResults = new HashSet<int>(i >= 0 ? Results.Where(x => x.Levels[i] != 0).Select(x => x.ID) : Results.Select(x => x.ID));

            // always add forward refs so that links can be clicked
            Cache.AddForwardRefs(Results);

            Cache.Sort(Results, filter);
        }
Пример #2
0
        static void Main(string[] args)
        {
            var path = LaunchpadManifest.SPELL_FILE;

            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.");
                    Thread.Sleep(2000);
                    return;
                }

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

                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);
                    Show(results);
                }
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex);
            }
        }