コード例 #1
0
 void LogHandler(object sender, LogsMonitorEventArgs logsMonitorEventArgs)
 {
     try
     {
         if (collecting)
         {
             bool anyMatched = false;
             foreach (var entry in logsMonitorEventArgs.WurmLogEntries)
             {
                 try
                 {
                     anyMatched |= processor.ProcessEntry(entry, logsMonitorEventArgs.LogType);
                 }
                 catch (Exception exception)
                 {
                     logger.Error(exception, "Error at parsing live log event for combat stats, entry: " + entry);
                 }
             }
             if (anyMatched)
             {
                 OnDataChanged();
             }
         }
     }
     catch (Exception exception)
     {
         logger.Error(exception, "General error at parsing live log event for combat stats.");
     }
 }
コード例 #2
0
        void EventHandler(object sender, LogsMonitorEventArgs logsMonitorEventArgs)
        {
            // note: event needs to be triggered regardless of skill being already known and up to date

            // there is no point in updating skill values, if server is not known
            var currentSvr = currentServer;

            if (currentSvr == null)
            {
                return;
            }

            SkillEntryParser parser    = new SkillEntryParser(logger);
            bool             anyParsed = false;

            foreach (var wurmLogEntry in logsMonitorEventArgs.WurmLogEntries)
            {
                SkillInfo skillInfo = parser.TryParseSkillInfoFromLogLine(wurmLogEntry);
                if (skillInfo != null)
                {
                    skillInfo.Server = currentSvr;
                    changedSkills.Enqueue(skillInfo);
                    skillsMap.UpdateSkill(skillInfo, currentSvr);
                    anyParsed = true;
                }
            }

            if (anyParsed)
            {
                onSkillsChanged.Trigger();
            }
        }
コード例 #3
0
 public override void HandleAnyLogLine(LogsMonitorEventArgs container)
 {
     foreach (var cond in config.TriggerConditions)
     {
         if (cond.LogType == container.LogType)
         {
             ProcessLinesForCooldownTriggers(container.WurmLogEntries.ToList(), cond);
         }
     }
 }
コード例 #4
0
 private void OnNewEventLogEvents(object sender, LogsMonitorEventArgs e)
 {
     foreach (var wurmLogEntry in e.WurmLogEntries)
     {
         if (parentModule.Settings.LogCaptureEnabled)
         {
             creatureUpdateManager.ProcessEventForCreatureUpdates(wurmLogEntry);
         }
     }
 }
コード例 #5
0
        private void HandleEventLogEntries(object sender, LogsMonitorEventArgs logsMonitorEventArgs)
        {
            // this handler may run on arbitrary threads!

            if (logsMonitorEventArgs.CharacterName == characterName)
            {
                if (logsMonitorEventArgs.LogType == LogType.Event)
                {
                    liveEventsToParse.Enqueue(logsMonitorEventArgs.WurmLogEntries.ToArray());
                }
            }
        }
コード例 #6
0
        void OnNewLogEvents(object sender, LogsMonitorEventArgs e)
        {
            try
            {
                var currentServer = currentServerOnTheGroup;
                if (currentServer != null && currentServer.ServerGroup.ServerGroupId == ServerGroupId)
                {
                    if (e.LogType == LogType.Event)
                    {
                        foreach (var timer in timers)
                        {
                            if (timer.InitCompleted)
                            {
                                foreach (var entry in e.WurmLogEntries)
                                {
                                    timer.HandleNewEventLogLine(entry);
                                }
                            }
                        }
                    }
                    if (e.LogType == LogType.Skills)
                    {
                        //call all timers with wurmskill handler
                        foreach (var timer in timers)
                        {
                            if (timer.InitCompleted)
                            {
                                foreach (var line in e.WurmLogEntries)
                                {
                                    timer.HandleNewSkillLogLine(line);
                                }
                            }
                        }
                    }

                    foreach (var timer in timers)
                    {
                        if (timer.InitCompleted)
                        {
                            timer.HandleAnyLogLine(e);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                logger.Error(exception, "Error during OnNewLogEvents at timers group " + this.ToString());
            }
        }
コード例 #7
0
ファイル: LiveLogsDataQueue.cs プロジェクト: imtheman/WurmApi
 private void EventHandler(object sender, LogsMonitorEventArgs logsMonitorEventArgs)
 {
     if (logsMonitorEventArgs.LogType == LogType.Event)
     {
         foreach (var wurmLogEntry in logsMonitorEventArgs.WurmLogEntries)
         {
             var uptime = logEntriesParser.TryParseUptime(wurmLogEntry);
             if (uptime != null)
             {
                 Add(logsMonitorEventArgs.CharacterName, uptime);
             }
             else
             {
                 var datetime = logEntriesParser.TryParseWurmDateTime(wurmLogEntry);
                 if (datetime != null)
                 {
                     Add(logsMonitorEventArgs.CharacterName, datetime);
                 }
             }
         }
     }
 }
コード例 #8
0
 private void EventHandler(object sender, LogsMonitorEventArgs logsMonitorEventArgs)
 {
     if (logsMonitorEventArgs.LogType == LogType.Event)
     {
         foreach (var wurmLogEntry in logsMonitorEventArgs.WurmLogEntries)
         {
             var uptime = logEntriesParser.TryParseUptime(wurmLogEntry);
             if (uptime != null)
             {
                 Add(logsMonitorEventArgs.CharacterName, uptime);
             }
             else
             {
                 var datetime = logEntriesParser.TryParseWurmDateTime(wurmLogEntry);
                 if (datetime != null)
                 {
                     Add(logsMonitorEventArgs.CharacterName, datetime);
                 }
             }
         }
     }
 }
コード例 #9
0
        void EventHandler(object sender, LogsMonitorEventArgs logsMonitorEventArgs)
        {
            foreach (var entry in logsMonitorEventArgs.WurmLogEntries)
            {
                // The pendulum could be improved with some more lump.
                // The scissors could be improved with some more lump.
                // The torch lamp (lit) could be improved with some more lump.
                // The clay jar could be improved with some more clay.
                // The forge could be improved with some more rock shards.
                // The wagon could be improved with some more log.
                // The dioptra could be improved with a lump.
                // The wagon could be improved with a log.
                {
                    var match = Regex.Match(entry.Content, @"The .+ could be improved with (.+)\.", RegexOptions.Compiled);
                    if (match.Success)
                    {
                        currentActionNeeded = match.Groups[1].Value;
                    }
                }

                // The clay flowerpot needs water.
                {
                    var match = Regex.Match(entry.Content, @"The .+ needs (.+)\.", RegexOptions.Compiled);
                    if (match.Success)
                    {
                        currentActionNeeded = match.Groups[1].Value;
                    }
                }

                // The lamp has some dents that must be flattened by a hammer.
                {
                    var match = Regex.Match(entry.Content,
                                            @"The .+ has some dents that must be flattened by (.+)\.",
                                            RegexOptions.Compiled);
                    if (match.Success)
                    {
                        currentActionNeeded = match.Groups[1].Value;
                    }
                }

                // The clay flowerpot has some flaws that must be fixed with a spatula.
                // The clay flowerpot has some flaws that must be fixed with a clay shaper.
                {
                    var match = Regex.Match(entry.Content,
                                            @"The .+ has some flaws that must be fixed with (.+)\.",
                                            RegexOptions.Compiled);
                    if (match.Success)
                    {
                        currentActionNeeded = match.Groups[1].Value;
                    }
                }

                // You will want to polish the lamp with a pelt before you improve it.
                {
                    var match = Regex.Match(entry.Content,
                                            @"You will want to polish the .+ with (.+) before you improve it\.",
                                            RegexOptions.Compiled);
                    if (match.Success)
                    {
                        currentActionNeeded = match.Groups[1].Value;
                    }
                }

                // You need to temper the lamp by dipping it in water while it's hot.
                {
                    var match = Regex.Match(entry.Content,
                                            @"You need to temper the .+ by dipping it in (.+) while it's hot\.",
                                            RegexOptions.Compiled);
                    if (match.Success)
                    {
                        currentActionNeeded = match.Groups[1].Value;
                    }
                }

                // The spirit cottage has some irregularities that must be removed with a stone chisel.
                {
                    var match = Regex.Match(entry.Content,
                                            @"The .+ has some irregularities that must be removed with (.+)\.",
                                            RegexOptions.Compiled);
                    if (match.Success)
                    {
                        currentActionNeeded = match.Groups[1].Value;
                    }
                }

                // A tool for digging. It could be improved with a lump.
                {
                    var match = Regex.Match(entry.Content,
                                            @".+It could be improved with (.+)\.",
                                            RegexOptions.Compiled);
                    if (match.Success)
                    {
                        currentActionNeeded = match.Groups[1].Value;
                    }
                }

                // You damage the lamp a little.
                if (entry.Content.Contains("You damage"))
                {
                    requireRepair = true;
                }

                // You repair the lamp.
                if (entry.Content.Contains("You repair"))
                {
                    requireRepair = false;
                }

                // [11:59:32] You must use a mallet on the knarr in order to improve it.
                {
                    var match = Regex.Match(entry.Content,
                                            @"You must use (.+) on .+ in order to improve it",
                                            RegexOptions.Compiled);
                    if (match.Success)
                    {
                        currentActionNeeded = match.Groups[1].Value;
                    }
                }

                // [12:00:07] You will want to polish the knarr with a pelt to improve it.
                {
                    var match = Regex.Match(entry.Content,
                                            @"You will want to polish .+ with (.+) to improve it",
                                            RegexOptions.Compiled);
                    if (match.Success)
                    {
                        currentActionNeeded = match.Groups[1].Value;
                    }
                }

                // [12:00:25] You notice some notches you must carve away in order to improve the knarr.
                {
                    var match = Regex.Match(entry.Content,
                                            @"You notice some notches you must carve away in order to improve .+",
                                            RegexOptions.Compiled);
                    if (match.Success)
                    {
                        currentActionNeeded = "carving knife";
                    }
                }

                // [12:01:27] You must use a file to smooth out the knarr in order to improve it.
                {
                    var match = Regex.Match(entry.Content,
                                            @"You must use (.+) to smooth out .+ in order to improve it",
                                            RegexOptions.Compiled);
                    if (match.Success)
                    {
                        currentActionNeeded = match.Groups[1].Value;
                    }
                }
            }
        }
コード例 #10
0
 public virtual void HandleAnyLogLine(LogsMonitorEventArgs container)
 {
 }
コード例 #11
0
        private void HandleEventLogEntries(object sender, LogsMonitorEventArgs logsMonitorEventArgs)
        {
            // this handler may run on arbitrary threads!

            if (logsMonitorEventArgs.CharacterName == characterName)
            {
                if (logsMonitorEventArgs.LogType == LogType.Event)
                {
                    liveEventsToParse.Enqueue(logsMonitorEventArgs.WurmLogEntries.ToArray());
                }
            }
        }
コード例 #12
0
 private void OnNewLogEvents(object sender, LogsMonitorEventArgs e)
 {
     HandleNewLogEvents(e.WurmLogEntries, e.LogType);
 }