public void PlayerFound_Who() { var parser = new LogParser(PLAYER); PlayerFoundEvent player = null; parser.OnPlayerFound += (args) => player = args; // anon/role player = null; parser.ParseLine("[Thu May 19 13:37:35 2016] [ANONYMOUS] Rumstil"); Assert.NotNull(player); Assert.Equal("Rumstil", player.Name); Assert.Null(player.Class); // level based class name (basic class name) player = null; parser.ParseLine("[Thu May 19 13:39:00 2016] [105 Huntmaster (Ranger)] Rumstil (Halfling) ZONE: kattacastrumb "); Assert.NotNull(player); Assert.Equal("Rumstil", player.Name); Assert.Equal("Ranger", player.Class); Assert.Equal(105, player.Level); // basic class name player = null; parser.ParseLine("[Thu May 19 13:55:55 2016] [1 Shadow Knight] Scary (Froglok) ZONE: bazaar "); Assert.NotNull(player); Assert.Equal("Scary", player.Name); Assert.Equal("Shadow Knight", player.Class); Assert.Equal(1, player.Level); }
private void TrackPlayer(PlayerFoundEvent player) { Add(player.Name); if (player.Class != null) { Players[player.Name].Class = player.Class; } }
/* * static LogParser() * { * // Collect parsers that are defined in the class * var methods = typeof(Parser).GetMethods(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); * var parsers = methods.Where(x => x.GetCustomAttributes(false).OfType<EventParserAttribute>().Any()); * } */ public LogParser(string player) { Player = new PlayerFoundEvent { Timestamp = DateTime.MinValue, Name = player }; MinDate = DateTime.MinValue; MaxDate = DateTime.MaxValue; Ignore.Add("You haven't recovered yet..."); Ignore.Add("You can't use that command right now..."); Ignore.Add("Your bow shot did double dmg."); Ignore.Add("You unleash a flurry of attacks."); Ignore.Add("Your target is too far away, get closer!"); //Ignore.Add("You strike through your opponent's defenses!"); //Ignore.Add("Your opponent strikes through your defenses!"); Ignore.Add("You can use the ability"); // [Thu May 19 11:10:40 2016] You can use the ability Entropy of Nature again in 0 minute(s) 6 seconds. }
public void PlayerFound_PartyChanged() { var parser = new LogParser(PLAYER); PlayerFoundEvent player = null; parser.OnPlayerFound += (args) => player = args; player = null; parser.ParseLine("[Thu May 19 14:54:55 2016] A lizard hireling has joined the group."); Assert.NotNull(player); Assert.Equal("A lizard hireling", player.Name); Assert.Equal(PlayerPartyStatus.JoinedGroup, player.Status); player = null; parser.ParseLine("[Sat Mar 19 20:47:57 2016] Fourier has left the group."); Assert.NotNull(player); Assert.Equal("Fourier", player.Name); Assert.Equal(PlayerPartyStatus.LeftGroup, player.Status); player = null; parser.ParseLine("[Mon Apr 04 22:33:18 2016] You remove Rumstil from the party."); Assert.NotNull(player); Assert.Equal("Rumstil", player.Name); Assert.Equal(PlayerPartyStatus.LeftGroup, player.Status); player = null; parser.ParseLine("[Sat Mar 19 20:48:12 2016] You have been removed from the group."); Assert.NotNull(player); Assert.Equal(PLAYER, player.Name); Assert.Equal(PlayerPartyStatus.LeftGroup, player.Status); player = null; parser.ParseLine("[Sat Mar 19 20:48:15 2016] You have joined the raid."); Assert.NotNull(player); Assert.Equal(PLAYER, player.Name); Assert.Equal(PlayerPartyStatus.JoinedRaid, player.Status); player = null; parser.ParseLine("[Sat Mar 19 20:51:09 2016] You were removed from the raid."); Assert.NotNull(player); Assert.Equal(PLAYER, player.Name); Assert.Equal(PlayerPartyStatus.LeftRaid, player.Status); }