コード例 #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
        private void FindFiles()
        {
            listView1.Items.Clear();

            var          dir   = new DirectoryInfo(".");
            var          files = dir.GetFiles("spells_us*.txt*");
            ListViewItem item  = null;

            foreach (var f in files)
            {
                // ignore the spell_us_str file since it also matches
                if (f.Name.StartsWith("spells_us_str"))
                {
                    continue;
                }
                item = new ListViewItem(f.Name);
                item.SubItems.Add(f.Length.ToString("#,#"));
                item.SubItems.Add(SpellParser.CountFields(f.Name).ToString());
                listView1.Items.Add(item);
            }

            if (listView1.Items.Count > 0)
            {
                listView1.Items[0].Selected = true;
            }
            else
            {
                Status.Text = "spells_us.txt was not found. Use the download button or copy a file into " + Directory.GetCurrentDirectory();
            }
        }
コード例 #3
0
        /// <summary>
        /// Download an updated spell file from the patch server. File names will include date (from server timestamp) and patch server type.
        /// </summary>
        private void Download(string server)
        {
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                var path = LaunchpadPatcher.DownloadSpellFilesWithVersioning(server);
                Status.Text = String.Format("Downloaded {0}", path);

                var item = listView1.FindItemWithText(path);
                if (item == null)
                {
                    var info = new FileInfo(path);
                    item = new ListViewItem(path);
                    item.SubItems.Add(info.Length.ToString("#,#"));
                    item.SubItems.Add(SpellParser.CountFields(path).ToString());
                    listView1.Items.Add(item);
                }
                listView1.MultiSelect = false;
                item.EnsureVisible();
                item.Selected         = true;
                listView1.MultiSelect = true;
            }
            catch (Exception ex)
            {
                Status.Text = "ERROR: " + ex.Message;
            }
            Cursor.Current = Cursors.Default;
        }
コード例 #4
0
        public DataProvider(IDatabaseConnection db)
        {
            _db = db;
            //Compendium = new Importer().ImportCompendium(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "Data", "SRD.xml"));
            Compendium = new Importer().ImportCompendium(@"D:\Dateien\OneDrive\Xerios\AllData.xml");
            var monsterParser = new MonsterParser(new SpellcastingParser(), new ActionParser(), new DynamicEnumProvider(db));
            var spellParser   = new SpellParser();
            var allMonsters   = GetAllMonsters();
            var allSpells     = GetAllSpells();

            foreach (var compendiumSpell in Compendium.Spells)
            {
                if (allSpells.Any(m => m.Name.Equals(compendiumSpell.Name)))
                {
                    continue;
                }
                var spell = spellParser.Parse(compendiumSpell);
                db.Add(spell);
            }
            allSpells = GetAllSpells();
            foreach (var compendiumMonster in Compendium.Monsters)
            {
                if (allMonsters.Any(m => m.Name.Equals(compendiumMonster.Name)))
                {
                    continue;
                }
                var monster = monsterParser.Parse(compendiumMonster, allSpells);
                db.Add(monster);
            }
        }
コード例 #5
0
ファイル: Utils.cs プロジェクト: rumstil/eqlogparser
        /// <summary>
        /// Perform timing tests on all trackers.
        /// </summary>
        public static void TimeTrackers(LogReader file, SpellParser spells)
        {
            var parser = new LogParser();

            parser.Player = LogOpenEvent.GetPlayerFromFileName(file.Path);

            // load raw log lines once
            var events = new List <LogEvent>();

            while (true)
            {
                var s = file.ReadLine();
                if (s == null)
                {
                    break;
                }
                var e = parser.ParseLine(s);
                if (e != null)
                {
                    events.Add(e);
                }
            }
            ;
            Console.Error.WriteLine("Loaded {0} events", events.Count);

            // timer trackers
            var trackers = new List <Action <LogEvent> >();
            var chars    = new CharTracker(spells);

            trackers.Add(chars.HandleEvent);
            var fights = new FightTracker(spells, chars);

            trackers.Add(fights.HandleEvent);
            var buffs = new BuffTracker(spells);

            trackers.Add(buffs.HandleEvent);
            var loot = new LootTracker();

            trackers.Add(loot.HandleEvent);

            // time individual trackers
            foreach (var t in trackers)
            {
                var ptimer = Stopwatch.StartNew();
                var pcount = 0;
                foreach (var e in events)
                {
                    t.Invoke(e);
                }
                Console.Error.WriteLine("{0,-20} {1,10} in {2}", t.Method.DeclaringType.Name, pcount, ptimer.Elapsed);
            }

            Console.WriteLine("***");
        }
コード例 #6
0
        public void ZuDebugDebug()
        {
            var room   = new Room("room", "room");
            var player = new Player(0, "player", room);

            player.Point(player);

            var spellstring = "ZU DEBUG DEBUG";
            var parsed      = new SpellParser().Parse(player, spellstring);

            Assert.IsTrue(parsed.IsError);
        }
コード例 #7
0
ファイル: MainForm.cs プロジェクト: theriou/eqspellparser
        private void SearchClass_TextChanged(object sender, EventArgs e)
        {
            // cancel if spells haven't been loaded yet
            if (Cache == null)
            {
                return;
            }

            // only show level filter when a class is selected
            int cls = SpellParser.ParseClass(SearchClass.Text) - 1;

            SearchLevel.Enabled = (cls >= 0);

            SearchText_TextChanged(sender, e);
        }
コード例 #8
0
ファイル: MainForm.cs プロジェクト: rumstil/eqlogparser
 public MainForm()
 {
     InitializeComponent();
     SetDoubleBuffered(lvFights, true);
     config = new RegConfigAdapter();
     //config = new XmlConfigAdapter();
     spells = new SpellParser();
     //parser.MinDate = DateTime.Parse("2020-09-27");
     fightsQueue = new ConcurrentQueue <FightInfo>();
     lootQueue   = new ConcurrentQueue <LootInfo>();
     fightList   = new List <FightInfo>(2000);
     fightStatus = new Dictionary <string, string>();
     lootList    = new List <LootInfo>();
     uploader    = new Uploader(LogInfo);
     _           = ProcessEventsAsync();
 }
コード例 #9
0
        public void ZuDebug()
        {
            var room   = new Room("room", "room");
            var player = new Player(0, "player", room);

            var spellstring = "ZU DEBUG";
            var parsed      = new SpellParser().Parse(player, spellstring);

            if (parsed.IsError)
            {
                Assert.Fail(parsed.Error);
            }
            else
            {
                Assert.IsNotNull(parsed.Result.root.Eval());
            }
        }
コード例 #10
0
        public void ZuBehWithoutReference()
        {
            var room   = new Room("room", "room");
            var player = new Player(0, "player", room);

            var spellstring = "ZU BEH";
            var parsed      = new SpellParser().Parse(player, spellstring);

            if (parsed.IsError)
            {
                Assert.Fail(parsed.Error);
            }
            else
            {
                Assert.IsNotNull(parsed.Result.root.Eval().Success);
            }
        }
コード例 #11
0
        private void ImportXML(IDatabaseConnection db)
        {
            var srd = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "Data", "SRD.xml");

            if (File.Exists(@"D:\Dateien\OneDrive\Xerios\AllData.xml"))
            {
                Compendium = new Importer().ImportCompendium(@"D:\Dateien\OneDrive\Xerios\AllData.xml");
            }
            else if (File.Exists(srd))
            {
                Compendium = new Importer().ImportCompendium(srd);
            }
            else
            {
                return;
            }

            var monsterParser = new MonsterParser(new SpellcastingParser(), new ActionParser());
            var spellParser   = new SpellParser();
            var allMonsters   = GetAllMonsters();
            var allSpells     = GetAllSpells();

            foreach (var compendiumSpell in Compendium.Spells)
            {
                if (allSpells.Any(m => m.Name.Equals(compendiumSpell.Name)))
                {
                    continue;
                }
                var spell = spellParser.Parse(compendiumSpell);
                db.Add(spell);
            }

            allSpells = GetAllSpells();
            foreach (var compendiumMonster in Compendium.Monsters)
            {
                if (allMonsters.Any(m => m.Name.Equals(compendiumMonster.Name)))
                {
                    continue;
                }
                var monster = monsterParser.Parse(compendiumMonster, allSpells);
                db.Add(monster);
            }
        }
コード例 #12
0
        public void ZuBehWithInvalidReferenceInscription()
        {
            var room   = new Room(0, "room", "room");
            var player = new Player(0, "player", room);

            var inscription = new Inscription(0, TargetingKeywords.From("ins"), "ins", "ins", "ins", new RunePhrase(new ZU(player, room)));

            player.Point(inscription);

            var spellstring = "ZU BEH";
            var parsed      = new SpellParser().Parse(player, spellstring);

            if (parsed.IsError)
            {
                Assert.Fail(parsed.Error);
            }
            else
            {
                Assert.IsNotNull(parsed.Result.root.Eval().Success);
            }
        }
コード例 #13
0
        /// <summary>
        /// Search the spell list for matching spells.
        /// </summary>
        static List <Spell> Search(string field, string value)
        {
            IEnumerable <Spell> results = null;

            var q = cache.SpellList;

            if (field == "all")
            {
                results = q;
            }
            //results = list.Where(x => (int)x.TargetRestrict > 0).OrderBy(x => x.TargetRestrict);

            // search by effect type
            if (field == "type" || field == "spa")
            {
                results = q.Where(x => x.HasEffect(value, 0));
            }

            // search by id
            if (field == "id")
            {
                results = q.Where(x => x.ID.ToString() == value);
            }

            // search by group
            if (field == "group")
            {
                results = q.Where(x => x.GroupID.ToString() == value);
            }

            // search by name
            if (field == "name")
            {
                results = q.Where(x => x.Name.IndexOf(value, StringComparison.InvariantCultureIgnoreCase) >= 0).OrderBy(x => x.Name);
            }

            // search by class
            if (field == "class")
            {
                int i = SpellParser.ParseClass(value) - 1;
                if (i < 0)
                {
                    throw new Exception("Unknown class: " + value);
                }
                results = q.Where(x => x.ExtLevels[i] > 0 && x.ExtLevels[i] < 255).OrderBy(x => x.Levels[i]).ThenBy(x => x.ID);
            }

            // search by target
            if (field == "target")
            {
                results = q.Where(x => x.Target.ToString().Equals(value, StringComparison.InvariantCultureIgnoreCase));
            }

            // debugging: search the unknown field
            if (field == "unknown")
            {
                results = q.Where(x => x.Unknown > 0).OrderBy(x => x.Unknown);
            }


            return(results.ToList());
        }
コード例 #14
0
ファイル: Program.cs プロジェクト: rumstil/eqlogparser
        static void Main(string[] args)
        {
            // load spells to give the trackers more context when processing log files
            // this is optional and can be skipped
            Console.Error.WriteLine("Loading spells...");
            var spells = new SpellParser();

            spells.Load("d:/games/everquest/spells_us.txt");

            // generate an open event that stores the player name, server name, and file path
            // all trackers should receive this as their first event to signal that a new log file is being processed
            var open = LogOpenEvent.FromFileName("d:/games/everquest/logs/eqlog_Rumstil_erollisi.txt");

            // create a CharTracker to help the FightTracker determine friends/foes
            var chars = new CharTracker(spells);

            chars.Files = new FileService(Path.GetDirectoryName(open.Path) + @"\..\");
            chars.HandleEvent(open);

            // create a FightTracker to build fight summaries from various combat events
            var fights = new FightTracker(spells, chars);

            fights.HandleEvent(open);
            fights.OnFightStarted  += ShowFight;
            fights.OnFightFinished += ShowFight;

            // create a log parser for converting log lines into events that can be passed to the trackers
            var parser = new LogParser();

            parser.Player = open.Player;
            //parser.MinDate = DateTime.MinValue;
            //parser.MinDate = DateTime.Today.AddDays(-1).ToUniversalTime();

            var timer  = Stopwatch.StartNew();
            var reader = File.OpenText(open.Path);

            while (true)
            {
                var line = reader.ReadLine();
                if (line == null)
                {
                    break;
                }

                // pass line to the parser and convert to an event
                // lines that cannot be parsed will be returned as nulls
                var e = parser.ParseLine(line);
                if (e == null)
                {
                    continue;
                }

                // pass event to the trackers
                chars.HandleEvent(e);
                fights.HandleEvent(e);

                //if (e is LogRawEvent) Console.WriteLine(e);
            }
            ;

            fights.ForceFightTimeouts();
            Console.Error.WriteLine("Parse completed in {0}", timer.Elapsed);
        }